Fwd: [PATCH] COFF Compliant .ctors and .dtors sections
Nick Clifton
nickc@redhat.com
Thu Aug 10 12:25:00 GMT 2017
Hi Martell,
>> In fact to be clearer - and more consistent - I would suggest changing
>> the names of the start and end constructor sections to be something like:
>> .ctors$start and .ctors$end.
>
> LLD and LINK.exe do not have any notion of a linker script and will
> organise the section in the following order.
> .ctors
> .ctors.AAAAA
> .ctors.zzz
Ah - OK - in which case the original section names are OK. But it would be
nice if you included a comment in the crtexe.c source file explaining why
those particular names are chosen.
> Technically someone could add extra z's which would then never get
> called so I am relying on people not doing something so ridiculous.
Never trust users :-)
But I agree - it is particularly unlikely to happen.
> With that in mind would the following be acceptable to you.
>
> ${CONSTRUCTING+
> PROVIDE(__CTOR_LIST__ = .);
> PROVIDE(___CTOR_LIST__ = .);
> LONG(-1);
> KEEP (*(.ctors));
> KEEP (*(.ctor));
> KEEP (*(SORT_BY_NAME(.ctors.*)));
> LONG(0);
> }
Yup - that works for me. In fact I have now checked this change into the
mainline development sources.
> For my question I also wanted to ask while I we are in discussion on
> the linker scripts how would I make an alias name to __image_base__ to
> __ImageBase?
Assignment should work. Something like this:
__image_base__ = __ImageBase;
Alternatively you could just use the --image-base=<value> linker command
line option. This takes care of setting both __image_base__ and __ImageBase
to <value>.
Cheers
Nick
More information about the Binutils
mailing list