<div style="font-family: arial, helvetica, sans-serif"><font size="2"><div class="gmail_quote">On Mon, Jun 18, 2012 at 10:49 AM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> The GNU linker has support to merge .ctor's into init_array.  Does the<br>
> gold linker have the same feature?  This seems more like the real fix<br>
> rather than just hacking around the issue.<br>
<br>
Recent version have it. I found the bug when using gold 2.21 which<br>
doesn't. What seems to happen is:<br>
<br>
* In an old linux system, the linker leaves ctors in .ctors,<br>
crtbeginS.o has a call to __do_global_dtors_aux. The net result is<br>
that _init calls the constructors.<br>
* In an all new linux system, the compiler uses .init_array (or the<br>
linker moves it there) and crtbeginS.o has nothing to do with<br>
constructors.<br>
* If we have a compiler that doesn't use .init_array and gold 2.21 in<br>
a new linux system, we hit the bug.<br>
<br>
So this is not as bad as I was expecting (old programs still work),<br>
but it is still a somewhat annoying ABI change to handle.</blockquote><div><br></div><div>Thanks to Andrew for explaining some of this to Rafael, and thanks to Rafael for breaking it down and getting it through my thick skull. =] I now understand what's going on much better. It is indeed not as bad as I was expecting.</div>
<div><br></div><div>However, as Rafael says, this is an annoying ABI change to handle. It seems that the song-and-dance to maintain backwards compatibility has been achieved, but the cost has been to introduce a pretty nasty dependency on newer versions of ld / gold in order to cope with '.o' files built by old compilers (which we are sometimes stuck with).</div>
<div><br></div><div>In figuring out how best to support this situation, the question I'm left with, and would love if someone from the GCC community familiar with the initial change could answer is: why was this change worth the cost we're now paying? What is the expected upside to putting constructors in .init_array?</div>
<div><br></div><div>Thanks,</div><div>-Chandler</div></div></font></div>