PATCH: ld/1467: Orphaned section is put in the odd place

Nick Clifton nickc@redhat.com
Fri Oct 14 09:00:00 GMT 2005


Hi H.J.

> +++ binutils/ld/ld.texinfo	2005-10-13 08:02:20.000000000 -0700
> @@ -4626,6 +4626,9 @@ SECTIONS
>  Now, the orphan @code{.rodata} section will be placed between
>  @code{end_of_text} and @code{start_of_data}.
>  
> +For ELF targets, linker will place the orphan section together with
> +sections of the same section type.

I think that we need more documentation than this.  In fact I think that 
we need a whole new node in the linker manual.  Something like this maybe:

    Orphaned Sections

    Orphaned sections are sections present in the input files which
    are not explicitly placed into the output file by the linker
    script.  The linker will still copy these sections into the
    output file, but it has to guess as to where they should be
    placed.  The linker uses a simple heuristic to do this.  It
    attempts to place orphaned sections after non-orphaned
    sections of the same type(1).  If there is not enough room to
    do this then it places at the end of the file.  Within a group
    of orphaned sections it orders them alphabetically by their
    name.

    Footnote (1):  In this context the type of the section are
    its attributes such as code vs data, loadable vs non-loadable,
    etc.  For ELF based targets the type also includes the sh_type
    field of the ELF section header.

>        if (look->bfd_section != NULL)
> -	flags = look->bfd_section->flags;
> +	{
> +	  flags = look->bfd_section->flags;
> +	  if (!bfd_match_sections_by_type (output_bfd,
> +					   look->bfd_section,
> +					   sec->owner, sec))
> +	    continue;
> +	}

The curly parentheses are unnecessary.

Cheers
   Nick




More information about the Binutils mailing list