PATCH: PR ld/12730: regression] crash when allocating in a static constructor
Alan Modra
amodra@gmail.com
Thu May 5 14:13:00 GMT 2011
On Thu, May 05, 2011 at 06:26:15AM -0700, H.J. Lu wrote:
> On Thu, May 5, 2011 at 1:27 AM, Alan Modra <amodra@gmail.com> wrote:
> > On Wed, May 04, 2011 at 10:18:32PM -0700, H.J. Lu wrote:
> >> When we put .ctors into .init_array, we have to reverse copy .ctors secton.
> >> Otherwise, constructor function may not work with C++ run-time library
> >> correctly. Â OK for trunk?
> >
> > What about .dtors? Â You have the same problem there. Â I suspect, but
>
> You are right. Here is the updated patch to handle .dtors sections
> with the updated testcase. OK for trunk?
No.
> > haven't verified, that .ctors.* and .dtors.* also need reversing. Â If
> > that is true then it would be better to do your reversing trick for
> > anything going to the .init_array output section that isn't named
> > .init_array* and similarly for .fini_array.
Are you sure there is no need to reverse .ctors.* and .dtors.*?
The reason I recommended testing the output section is that limits
section reversal to that particular output section. I will not
approve a patch that ignores this recommendation. You also should
remove reverse_copy_ctors. That's plain wrong. Consider people
linking using a custom (old) script that does not put .ctors into
.init_array.
> > You also need to reverse any dynamic relocations applying to the
> > sections you are reversing.
>
> It isn't a problem since we apply relocations on the input sections
> first and copy relocated input sections to output where I reverse
> copy .ctors/.dtors sections if needed.
Try compiling your testcase as a PIE or shared lib on a target that
uses RELA. I haven't tried it, but I think the dynamic RELATIVE
relocs you'll get in .ctors will undo your section reversing.
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list