This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fwd: [PATCH] COFF Compliant .ctors and .dtors sections


Hi Martell,

  [Sorry for the delay in responding - I was caught up with other issues].

> I wanted to follow up with an issue.
> After some extra testing between mingw-w64 lld and ld it seems only
> the following works.

> Which would mean removing KEEP (*(.ctors)); and KEEP(*(.dtors));
> I don't quite understand the original intention of those two lines.
> Wouldn't they be covered by KEEP(*(SORT_BY_NAME(.ctors.*))); and
> KEEP(*(SORT_BY_NAME(.dtors.*))); respectively?

No.  Well at least not in theory anyway.  In linker scripts section 
matching patterns the period character is not a meta-character, but 
rather it just matches itself.  So ".ctors" will match any section
that is called ".ctors" and nothing else.  (So "Zctors" for example
would not match).

An asterisk is a meta-character, but it acts on its own, it does not 
refer to the previous character.  So ".ctors.*" matches any sections 
with ".ctors." as a prefix to their name, but it does not match 
".ctors" on its own.


> With those 2 lines included strangely the dtors section appears before
> the ctors section and only the closing LONG(0) ends up in the section.
> The following dump is from a simple program that has one constructor
> and one destructor attributed function
> Bug maybe?

Maybe, but something else strange is happening here:

> Disassembly of section .dtors:
> __DTOR_LIST__:
>    404000:       ff ff  <unknown>

Where does this .dtors section come from ?  The linker script is supposed
to gather together all the incoming constructor and destructor sections 
and place them at the end of the .text section of the output file.  So 
there should not be a .dtors section in the output at all!

Please can you provide a testcase so that I can investigate further ?

Cheers
  Nick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]