gold patch committed: Reverse .ctors in .init_array

Cary Coutant ccoutant@google.com
Mon Jun 27 19:00:00 GMT 2011


> Alan pointed out that when a .ctors sections which has multiple words is
> mapped to a .init_array section, we need to reverse the order of the
> entries in the .ctors section.  This is because .ctors and .init_array
> are executed in reverse order, and we don't want the linker to change
> the order in which the constructors are executed.  The same applies to
> .dtors mapped to .fini_array.  This patch implements that in gold.
> Committed to mainline.

I asked about this in the comment string for PR 46770, about HJ's
patch for ld. The answer there was that the compiler generates a
single function that calls the constructors in the right order, so it
wasn't necessary to reverse the contents of the .ctors section. What's
different here? Will gold and gnu ld give different behavior now?

-cary



More information about the Binutils mailing list