public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Edelsohn <dje.gcc@gmail.com>
To: Jeff Law <law@redhat.com>
Cc: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>,
		GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Real fix for AIX exception handling
Date: Wed, 29 Mar 2017 21:11:00 -0000	[thread overview]
Message-ID: <CAGWvny=bwzvsuv2o7VtVMEp3yDeD8jWxdRKQj_jhwcRac6xDCQ@mail.gmail.com> (raw)
In-Reply-To: <b27a4102-c1a5-1969-d058-7ec437535ddb@redhat.com>

On Wed, Mar 29, 2017 at 4:48 PM, Jeff Law <law@redhat.com> wrote:
> On 03/29/2017 02:21 PM, David Edelsohn wrote:
>>
>>
>> The problem is GCC EH tables and static linking.  libstdc++ and the
>> main application are ending up with two separate copies of the tables
>> to register EH frames.
>>
>> Static linking worked in GCC 4.8, but not in GCC 4.9.  I have been
>> trying to understand what changed and if GCC 4.8 worked by accident.
>>
>> Note that AIX does not install a separate libstdc++ static archive and
>> instead statically links against the shared object.  libstdc++
>> apparently uses the EH table referenced when it was bound by collect2
>> and the application uses the one created when the executable is
>> created -- the libgcc_eh.a solution doesn't work.  Again, the question
>> is why this apparently functioned correctly for GCC.4.8.
>>
>> There was a change to constructor order around that time and that may
>> have affected where EH frames were recorded.
>
> Hmm, the act of statically linking against the shared libstdc++ certainly
> adds a wrinkle here.
>
> It's been a *long* time since I had to think about this stuff for a non-ELF
> system.  Please correct me if I goof anything up.
>
> Since we build a shared libstdc++, doesn't that set up a library ctor which
> should register the EH tables for the library as a whole?
>
> When we link against that library statically, we have to arrange to run the
> library's ctor from the main program's global ctors.  Right?  ie, it should
> be OK to have separate copies -- we just have to get them all registered
> properly?  Right?

GCC has to get them all of the EH frames registered into one table,
otherwise libgcc walks the frames to find a catcher for an exception
and doesn't find the address of the program counter in the sorted
table because that range was recorded in the other table.

One can understand how this ended up broken, but I am trying to
understand how it worked correctly in GCC 4.8.  And, as we all know,
GDB functionality on AIX is limited.

Thanks, David

  reply	other threads:[~2017-03-29 20:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-27 15:44 David Edelsohn
2017-03-29 20:21 ` Jeff Law
2017-03-29 20:24   ` David Edelsohn
2017-03-29 20:49     ` Jeff Law
2017-03-29 21:11       ` David Edelsohn [this message]
2017-03-29 21:23         ` Jeff Law
2017-03-29 21:27           ` David Edelsohn
2017-03-29 22:29             ` Jeff Law
2017-03-30 10:37     ` Michael Haubenwallner
2017-03-30 13:10       ` David Edelsohn
2017-03-31 15:05       ` Jeff Law
  -- strict thread matches above, loose matches on Subject: below --
2017-03-27 10:49 Michael Haubenwallner

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='CAGWvny=bwzvsuv2o7VtVMEp3yDeD8jWxdRKQj_jhwcRac6xDCQ@mail.gmail.com' \
    --to=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=michael.haubenwallner@ssi-schaefer.com \
    /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).