[PATCH] D17120: ELF: Implement the correct semantics of .[cd]tors.
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 11 13:45:48 PST 2016
On Friday, 12 February 2016, Rui Ueyama <ruiu at google.com> wrote:
> On Wed, Feb 10, 2016 at 11:08 PM, Simon Atanasyan <simon at atanasyan.com
> <javascript:_e(%7B%7D,'cvml','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.
>
But in the test case first bytes are c1 and c2 which come from
ctors_dtors_priority3.s
which becomes %t-crtend.o. Am I miss something?
--
Simon Atanasyan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160212/4b3d673b/attachment.html>
More information about the llvm-commits
mailing list