This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Fwd: [PATCH] COFF Compliant .ctors and .dtors sections
- From: Nick Clifton <nickc at redhat dot com>
- To: Martell Malone <martellmalone at gmail dot com>
- Cc: binutils at sourceware dot org, Kai Tietz <ktietz70 at gmail dot com>
- Date: Thu, 10 Aug 2017 13:24:03 +0100
- Subject: Re: Fwd: [PATCH] COFF Compliant .ctors and .dtors sections
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=nickc at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8A60590C91
- References: <CAOpLJ7wg8097ud3uPtAftcGq++-M=M4GdWgC0SKJo0CB5Hk27Q@mail.gmail.com> <CAOpLJ7w=8RBTEFqcmYb5s5Q2+Vi=hp_WPqh4qq1A0A+HkjPsTA@mail.gmail.com> <e4e2e8ae-8af2-7abf-184c-ea53bb935d7a@redhat.com> <CAOpLJ7wJ4GdrADW2zMZ7ZeJzA+wbnuUh1DYPGNEez4WaoihkaA@mail.gmail.com>
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