Link problem of ". rodata. str1.4"

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.