public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: gcc-help@gcc.gnu.org
Cc: Shlom Marom <devshlom@gmail.com>
Subject: Re: Exception handling on AIX5.3 with gcc 3.4.6
Date: Wed, 26 Mar 2008 01:26:00 -0000	[thread overview]
Message-ID: <m38x065l8u.fsf@google.com> (raw)
In-Reply-To: <47E29267.AAFEF6F1@dessent.net> (Brian Dessent's message of "Thu\, 20 Mar 2008 09\:35\:51 -0700")

Brian Dessent <brian@dessent.net> writes:

> Shlom Marom wrote:
>
>> If I compiled the program with shared lib-gcc and with the pthread
>> libstdc++ - everything works fine and also the base exception is being
>> caught as it should.
>> ...
>> Shared linking: gcc -o tester_shared main.cpp -pthread -I.
>> -shared-libgcc -L/usr/lib -ldl -lpthread -lstdc++
>> Static linking: gcc -o tester_static main.cpp -L/usr/lib/threads
>> -pthread -I. -static-libgcc -L/usr/lib -ldl -lpthread `gcc
>
> A shared libgcc is pretty much required for proper exception handling, I
> just don't think you're going to be able to get around that.  This
> should hold true for pretty much every target so the fact that it works
> with static libgcc on Linux is by accident, or perhaps luck.

Brian's answer is in general correct.  However, there is a case where
it works.  You can use -static-libgcc when throwing exceptions across
shared library boundaries if:

1) gcc is configured to use unwind-dw2-glibc-fde.c instead of
   unwind-dw2-glibc.c (this happens on GNU/Linux systems and some
   others--look for uses of t-linux or t-libunwind-elf in
   gcc/config.gcc).

2) gcc is configured to pass --eh-frame-hdr to the linker (this
   happens automatically if the linker available when configuring gcc
   supports this option).

3) The executable and all shared libraries were in fact built by a gcc
   which passes --eh-frame-hdr to the linker.

4) Your C library has a working copy of dl_iterate_phdr (this is true
   for recent versions of glibc on GNU/Linux).

If all those conditions are true, then unwind information does not
need to be registered at program startup.  Instead, the unwind library
will find it at runtime using dl_iterate_phdr to look for
PT_GNU_EH_FRAME segments created by the linker.  And in that case
-static-libgcc will work.

Ian

  parent reply	other threads:[~2008-03-26  1:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-20 15:28 Shlom Marom
2008-03-20 16:36 ` Brian Dessent
2008-03-21 23:36   ` Shlom Marom
2008-03-22  3:26     ` Brian Dessent
2008-03-23  9:22       ` Shlom Marom
2008-03-26  1:26   ` Ian Lance Taylor [this message]
2008-03-20 17:23 ` David Edelsohn

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=m38x065l8u.fsf@google.com \
    --to=iant@google.com \
    --cc=devshlom@gmail.com \
    --cc=gcc-help@gcc.gnu.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).