【求助】Keil编译时,【字符串不被认成RO-DATA】的问题
Keil版本: Keil MDK4有如下代码:
void func()
{
//...do something
printf("I hope to be recognized as RO-DATA!\n");
}
但是查看编译之后的.map和反汇编,发现该字符串未被认成RO-DATA section,反汇编如下:
------------------------------------------------------------------------------------------------------------------
func
0x00002c44: b510 .. PUSH {r4,lr}
0x00002c46: a013 .. ADR r0,{pc}+0x4e ; 0x2c94
0x00002c48: f000fc9a .... BL printf ; 0x3580
;;some other codes for RO-CODE section
$d
;;the string is here!
0x00002c94: 6f682049 I ho DCD 1869094985
0x00002c98: 74206570 pe t DCD 1948280176
0x00002c9c: 6562206f o be DCD 1700929647
0x00002ca0: 63657220 rec DCD 1667592736
0x00002ca4: 696e676f ogni DCD 1768843119
0x00002ca8: 2064657a zed DCD 543450490
0x00002cac: 52207361 as R DCD 1377858401
0x00002cb0: 41442d4f O-DA DCD 1094987087
0x00002cb4: 0a214154 TA!. DCD 169951572
0x00002cb8: 00000000 .... DCD 0
------------------------------------------------------------------------------------------------------------------
于是,造成我无法通过scatter file来分离RO-CODE和RO-DATA到不同的区域(我本想将这个字符串放在0x100000地址处的)。
请教一下各位高手,如何做才能使linker将这个字符串认成RO-DATA?谢谢!
const unsigned char str = "I hope to be recognized as RO-DATA!\n";
printf(str); 这个方法我试过,白搭。而且即使可以的话用着也太不方便了。
我看ARM官网上说,$d区域是inline数据区,用来存放文字池、short string一类的东西,紧跟所属函数的RO-CODE区;而RO-DATA区是对$d区的补充。
这可要了我亲命了,如何才能将string从$d区中挪出来啊~~~~~~~{:mad:} 我就不信:
char str[]="I hope to be recognized as RO-DATA!\n";
printf(str); 回楼上,这个方法还真不行。不信您可以试一下,Keil4。
我看ARM官网的资料都看吐了,也没找到有什么方法可以将字符串从func尾部的$d区拿掉。 摘抄一个ARM官网的例子——
Example 2. fromelf output for Dhrystone including the library
** Object/Image Component Sizes
Code (inc. data) RO Data RW Data ZI Data Debug Object Name
15412 2278 476 64 10536 4020 dhry.axf
15412 2278 476 64 0 0 ROM Totals for dhry.axf
The first column shows the application code size in bytes which includes the size of inline data shown in the second column. The inline data is located in the code section and comprises literal pools, case-branch offset tables and short strings.
页:
[1]