This is the mail archive of the binutils@sources.redhat.com 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]

Question on ld's SORT capability in 2.10



I have a couple of questions regarding the SORT feature in 2.10 ld.
I'm trying to sort initialization routines (ala ctors) on linux
alpha using the elf64alpha.x script.  Taking the .ctors section
from the script:

  .ctors   : 
  {
    /* gcc uses crtbegin.o to find the start of
       the constructors, so we make sure it is
       first.  Because this is a wildcard, it
       doesn't matter if the user does not
       actually link against crtbegin.o; the
       linker won't look for a file to match a
       wildcard.  The wildcard also means that it
       doesn't matter which directory crtbegin.o
       is in.  */
    KEEP (*crtbegin.o(.ctors))
    /* We don't want to include the .ctor section from
       from the crtend.o file until after the sorted ctors.
       The .ctor section from the crtend file contains the
       end of ctors marker and it must be last */
    KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
    KEEP (*(SORT(.ctors.*)))
    KEEP (*(.ctors))
  }

I consistently get the initializers invoked as though SORT weren't
present (ie, in reverse order as detected across the command line).
The only way I could get the ctors SORTed was to modify the script
as follows (comments removed):

  .ctors   : 
  {
    KEEP (*crtbegin.o(.ctors))
    KEEP (SORT(*)(.ctors))       
    KEEP (*(.ctors))
  }

Of course, this has the problem of including *crtend.o in the sort -
which means it _may_ not be invoked last, as it should.  Are SORT
and EXCLUDE_FILE mutually-exclusive?  Are the input ctor sections
placed in the output section at the time the EXCLUDE_FILE is
specified, such that the SORT has the effect of sorting only those
items that are remaining (excluded)?

I doesn't appear that sorting on routine-name is allowed (just
module names).  Is that true?  Is it a goal to sort on routine-name?

thanks,
bruce

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