* Question on ld's SORT capability in 2.10
@ 2000-07-21 6:11 Bruce Trull
2000-07-21 8:06 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: Bruce Trull @ 2000-07-21 6:11 UTC (permalink / raw)
To: binutils
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Question on ld's SORT capability in 2.10
2000-07-21 6:11 Question on ld's SORT capability in 2.10 Bruce Trull
@ 2000-07-21 8:06 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2000-07-21 8:06 UTC (permalink / raw)
To: trull; +Cc: binutils
Date: Fri, 21 Jul 2000 09:10:31 -0400
From: Bruce Trull <trull@zko.dec.com>
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?
The SORT keyword sorts on section names, not routine names.
It implements C++ constructor priorities, assuming you use the gcc
-finit-priority option to generate constructors in sections with
appropriate names.
In the default script, SORT only applies to .ctors.*, so it should not
affect the section in crtend.o, which is named .ctors.
Ian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-07-21 8:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-21 6:11 Question on ld's SORT capability in 2.10 Bruce Trull
2000-07-21 8:06 ` Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).