[PATCH] D17120: ELF: Implement the correct semantics of .[cd]tors.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 11 13:29:41 PST 2016
On Wed, Feb 10, 2016 at 11:08 PM, Simon Atanasyan <simon at atanasyan.com>
wrote:
> atanasyan added a comment.
>
> GNU ld 2.22 has the following default linker script for `.ctors/.dtors`
> sections. I am sure that other versions have the same declarations.
>
> .ctors :
> {
> KEEP (*crtbegin.o(.ctors))
> KEEP (*crtbegin?.o(.ctors))
> /* We don't want to include the .ctor section 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 *crtend?.o ) .ctors))
> KEEP (*(SORT(.ctors.*)))
> KEEP (*(.ctors))
> }
> .dtors :
> {
> KEEP (*crtbegin.o(.dtors))
> KEEP (*crtbegin?.o(.dtors))
> KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
> KEEP (*(SORT(.dtors.*)))
> KEEP (*(.dtors))
> }
>
> So the order should be follow:
>
> 1. .ctors section from *crtbegin.o
> 2. .ctors section from *crtbegin?.o
> 3. .ctors sections from other object files except *crtend.o and *crtend?.o
> 4. .ctors.* from any files sorted by priority
> 5. .ctors sections from *crtend.o and *crtend?.o
>
I think my patch implements that order except it doesn't distinguish case 1
and 2, which is not significant I believe.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160211/6441ffc0/attachment.html>
More information about the llvm-commits
mailing list