This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: orphan section logic


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]