ld changing section names with attr "a" (ALLOC)

Nick Clifton nickc@redhat.com
Fri Jul 23 16:32:00 GMT 2004


Hi Atul,

> "GNU ld version 2.13.1" Cross-compiled for MIPS on x86.

First off, when reporting bugs, please use the latest release of 
binutils (which in this case is 2.15) or, even better, the current 
sources in the CVS repository.

As it happens this bug is present in the current sources as well, but it 
is always best to use the most up-to-date sources that you can.

> [3] mips-elf-ld --section-start .new_section=0x8000 test.o -o
> test_cmdline.exe
> 
> I case of command [3] I see that linker adds the suffix ".1"
> to the my new section name:
> (and does *not* place it at the address I want)

Well strictly speaking it does place a section called .new.section at 
address 0x8000, it is just that this section does not have the contents 
(or attributes) of .new.section from the test.o input file.  Instead 
these are given to a newly created new.section.1.

The problem is a bug in the place_orphans() function which assumes that 
since the .new.section in the test.o input file was not named in the 
linker map it will have to create a section in the output file to hold 
its contents.  It tries to create a section called .new.section but 
discovers that the linker has already created a section by this name. 
So it assumes that the linker did not use this section because a 
mismatch in the section's attributes and so it goes on to create a brand 
new section name .new.section.1.

The patch below resolves this problem by teaching the place_orphan 
function that it is OK to use a section name that already exists 
provided that that section does not have any flags set.  Such a section 
will have been created by the linker in response to a --section-start 
switch.

Cheers
   Nick

ld/ChangeLog
2004-07-23  Nick Clifton  <nickc@redhat.com>

	* emultempl/elf32.em (_place_orphan): Use an already existing
	section name if that section does not have any flags set.





-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: elf32.em.patch
URL: <https://sourceware.org/pipermail/binutils/attachments/20040723/927b3d3f/attachment.ksh>


More information about the Binutils mailing list