About ". rodata. str1.4 "connection problem [Problem description] recently I am writing some embedded underlying-related programs, including the following section (the compiler is arm-Linux-GCC 3.4.1 ):
while(1){unsigned char* s="abcd";uart0_puts(s);}
However, the following problems occur during compilation:
/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]
[Problem Analysis]
This. rodata. str1.4 occurs only when-O2 is optimized. It is not available without the optimization option. The following information is found on 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 cocould be a matter of GCC versions. apparently, GCC versions prior to 3.1.x didn't generate. rodata. strx. Y sections.
. Rodata. str1.4 is produced by GCC to support LD merging of repeated constants and strings. The old version of GCC does not generate this segment. If LD does not support this segment, the new version of GCC does not. This is a GCC version issue. Obviously, GCC versions earlier than 3.1.x do not generate. rodata. strx. y segments.
[Solution]
No. rodata. str1 is added to the original connection script. For example:
SECTIONS{. =0x00000000;.text :{*(.text)*(.rodata.str1.4)*(.rodata)}. =ALIGN(32);.data :{*(.data)}. =ALIGN(32);__bss_start__ = .;.bss :{*(.bss)}__bss_end__ = .;}
[Others]
If. rodata. str1.4 is not added to the connection script, the following error may occur:
/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'
[References]
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