“.rodata.str1.4”的连接(link)问题
来源:互联网 发布:淘宝如何权重 编辑:程序博客网 时间:2024/06/05 14:08
关于“.rodata.str1.4”的连接(link)问题
while(1){unsigned char* s="abcd";uart0_puts(s);}但在编译的时候出现了如下问题:
/usr/local/arm/3.4.1/bin/../lib/gcc/arm-linux/3.4.1/../../../../arm-linux/bin/ld: section .rodata.str1.4 [00000080 -> 0000008c] overlaps section .text [00000000 -> 0000044f]
【问题分析】
这个 .rodata.str1.4 是 -O2 优化时才出现的,不带优化选项时没有。在google上找到了如下一些资料:
Sections like .rodata.str1.4 are generated by gcc to support merging of duplicate constants and strings by ld. Older gcc's won't do this, nor will a newer gcc built for a system without the requisite ld support. it could be a matter of gcc versions. Apparently, gcc versions prior to 3.1.x didn't generate .rodata.strx.y sections.
大意为: .rodata.str1.4 是gcc为了支持ld合并重复的常量和字符串而产生的。老版本的gcc不会产生这个段,如果ld不支持,新版本的gcc也不会产生这个段,这是一个gcc版本问题。显然,3.1.x版本前的gcc不会产生 .rodata.strx.y段。
【解决办法】
在原来的连接脚本里边没加上 .rodata.str1。比如:
SECTIONS{. =0x00000000;.text :{*(.text)*(.rodata.str1.4)*(.rodata)}. =ALIGN(32);.data :{*(.data)}. =ALIGN(32);__bss_start__ = .;.bss :{*(.bss)}__bss_end__ = .;}【其他】
如果没有在在连接脚本里边加上 .rodata.str1.4 还可能出现如下错误:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/bin/ld: error: no memory region specified for loadable section `.rodata.str1.4'
【参考资料】
http://telltruth.blogbus.com/logs/15705483.html
http://blog.chinaunix.net/uid-121788-id-2955078.html
http://blog.21ic.com/user1/2983/archives/2008/53972.html
- “.rodata.str1.4”的连接(link)问题
- str1==str2和str1.equals(str2)的问题
- J-LINK连接不上的问题
- 链接脚本当中的rodata和data段分布问题
- stract函数的实现 连接str2到str1的后面
- J-Link不能连接EFM32调试的问题
- MySQL连接池“Communications link failure”的问题
- J-LINK连产品出现连接不上的问题
- 第十三周项目五字符串的操作(2)将str1和str2连接起来,仍存放在str1中
- 常见的link问题
- link的问题
- 第17周项目2字符串str1与 str2的连接
- .libs/alloc.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared
- 第16周项目1-1对字符串的操作将str1和str2连接,并将结果保存在str1中
- 笔试题目4 字符串连接函数 char *strcat(char *str1,const char *str2)
- mysql 中的字符串连接 CONCAT(str1,str2,...)
- 16-1.5 str1 str2字符串连接
- 关于 LINK : warning LNK4075: ignoring /INCREMENTAL due to /option 的连接警告问题
- 光线追踪(RayTracing)算法理论与实践(一)入门
- 自动生成的 菜单程序,一会分析一下
- iOS 6 Game Center之新功能第1部分
- android安装时遇到的问题
- Openfiler 配置 NFS 示例
- “.rodata.str1.4”的连接(link)问题
- iOS 6 Game Center之新功能第2部分
- Oracle数据库中保存文件(C#)
- Qt creator 问题 during startup program exited with code 0x0的折中解决
- 高手博客列表
- CKEDITOR 中<p>标签引发的问题
- C++著名程序库的比较和学习经验
- Objective-c 的 @property 详解
- AsyncTask的使用