This is the mail archive of the
mailing list for the binutils project.
Re: Unexpected behavior regarding linking sections
- From: Alan Modra <amodra at gmail dot com>
- To: Felix von Leitner <felix at fefe dot de>
- Cc: binutils at sourceware dot org
- Date: Thu, 13 Dec 2018 10:18:34 +1030
- Subject: Re: Unexpected behavior regarding linking sections
- References: <20181211152750.GA19360@qarx.de> <20181211224226.GB28455@bubble.grove.modra.org> <20181212014453.GB3220@qarx.de> <20181212040523.GD28455@bubble.grove.modra.org> <20181212162302.GA19761@qarx.de>
On Wed, Dec 12, 2018 at 05:23:02PM +0100, Felix von Leitner wrote:
> > > > Have a look at your default ld scripts (link with -Wl,--verbose).
> > > > Very likely you have a linker configured with --enable-initfini-array
> > > > which will put .ctors and .dtors from all but the various flavours of
> > > > crtbegin/end.o into .init_array and .fini_array.
> > > I don'd understand what that means.
> > If you don't understand what I said above then it's not very likely I
> > can help you further.
> Please print out this email and revisit it in a few years.
> First rule in conversation: Assume your opposite knows something you
[snip lots of frustration]
> Is it clearer now?
Yes, it's clear that you "know" some things about linker operation
that aren't true. One misconception in particular stands out, that
.ctors in input files are always mapped to .ctors in an output file.
That isn't true. It is also not true of other named sections. A
linker may take a section from an input file and place it in a
differently named output section. This is not a rare occurrence. For
example, you'll see it happen with input sections like ".text.hot" and
".rodata.cst4". GNU ld generally performs mapping of input to output
sections under control of a linker script.
For the record, I understand what you are trying to do. I not only
read your email but I linked your testcase myself, after fixed an
error or two (%d vs. %ld). I also know exactly why GNU ld is behaving
as it is regarding .ctors/.dtors. That behaviour is reasonable given
that it is desirable to move the entire toolchain from using
.ctors/.dtors to the ELF gABI standard of .init_array/.fini_array but
GNU ld must support mixing old and new object files in a way that
keeps proper constructor/destructor ordering.
Australia Development Lab, IBM