public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Binutils <binutils@sourceware.org>
Subject: Re: PATCH: PR ld/12730: regression] crash when allocating in a static constructor
Date: Fri, 06 May 2011 13:23:00 -0000	[thread overview]
Message-ID: <BANLkTi=nhJSWTC2z+gxxOTBDODm_wM78gQ@mail.gmail.com> (raw)
In-Reply-To: <20110505141230.GJ7018@bubble.grove.modra.org>

On Thu, May 5, 2011 at 7:12 AM, Alan Modra <amodra@gmail.com> wrote:
> 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.
>

I will fix it.

-- 
H.J.

  reply	other threads:[~2011-05-06 13:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-05  5:19 H.J. Lu
2011-05-05  8:27 ` Alan Modra
2011-05-05 13:27   ` H.J. Lu
2011-05-05 14:13     ` Alan Modra
2011-05-06 13:23       ` H.J. Lu [this message]
2011-05-06 16:16         ` H.J. Lu
2011-05-07  8:11           ` Alan Modra
2011-05-07 13:40             ` H.J. Lu
2011-05-07 14:05               ` Alan Modra
2011-05-09 13:53                 ` Alan Modra
2011-05-09 14:09                   ` H.J. Lu
2011-06-19 19:18               ` Thomas Schwinge
2011-06-21 15:14                 ` Nick Clifton
2011-05-15 10:14 Craig Southeren
2011-05-16  0:15 ` Alan Modra
2011-05-16  0:37   ` Craig Southeren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='BANLkTi=nhJSWTC2z+gxxOTBDODm_wM78gQ@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).