This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: orphan section logic
- From: Alan Modra <amodra at gmail dot com>
- To: DJ Delorie <dj at redhat dot com>
- Cc: binutils at sourceware dot org
- Date: Tue, 12 Jan 2010 13:12:28 +1030
- Subject: Re: orphan section logic
- References: <201001120214.o0C2EdNW010505@greed.delorie.com>
On Mon, Jan 11, 2010 at 09:14:39PM -0500, DJ Delorie wrote:
>
> If you have a section .foo in your object, and a .foo output
> statement, yet the .foo output statement doesn't specify any objects,
> ld fails to allocate the .foo section to the .foo output statement
> (although it seems it used to). Instead, it creates a *new* .foo
> output section elsewhere in the memory space.
>
> *Should* it allocate it that way?
Probably not.
> @@ -1837,8 +1838,19 @@ gld${EMULATION_NAME}_place_orphan (asect
> lang_add_section (&os->children, s, os);
> return os;
> }
> +
> + if (strcmp (os->name, secname) == 0)
You don't need to check the name here, but you should check that
os->bfd_section is NULL, I think. Otherwise you might mash together
sections with incompatible flags.
> + match_by_name = os;
> }
>
> + /* Failing that, look for an output section by name that might not
> + have sections yet. */
> + if (match_by_name)
> + {
> + lang_add_section (&match_by_name->children, s, match_by_name);
> + return os;
return match_by_name;
--
Alan Modra
Australia Development Lab, IBM