public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: John Marino <gnugcc@marino.st>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: dl_iterate_phdr support
Date: Mon, 14 Feb 2011 08:11:00 -0000	[thread overview]
Message-ID: <mcrd3mvcibd.fsf@google.com> (raw)
In-Reply-To: <4D56F3A4.7010808@marino.st> (John Marino's message of "Sat, 12	Feb 2011 21:55:00 +0100")

John Marino <gnugcc@marino.st> writes:

> FreeBSD and openBSD have had dl_iterate_phdr support in their runtime
> linker since 2007.  NetBSD-current added it in late 2010 and I just
> patched Dragonfly's RTLD to support it as well, which means the
> feature is fully supported by *BSD.
>
> I was a bit surprised when I checked the gcc configure log and saw the
> check for dl_iterate_phdr came back "unknown" so I checked the
> gcc/configure script.
>
> Basically the logic in the configure script is this:
> If target <> solaris2 then gcc_cv_target_dl_iterate_phdr=unknown
>
> Basically that means this feature is only possibly used by gcc when
> Solaris is the target.
>
> Is this intentional?
> Why are not Linux and BSD targets being tested?
>
> Is the problem only a deficient configure script, or is there missing
> support within gcc itself?  I was told on the gcc-help mail list that
> using dl_iterate_phdr was a more efficient method of propagating
> exceptions and I'd like GNAT to take advantage of that.

The test in gcc/configure.ac is unfortunately rather misleading.  That
result of that test is currently only used on Solaris.

The relevant code can be found in two places: gcc/unwind-dw2-fde-glibc.c
and gcc/crtstuff.c.  In unwind-dw2-fde-glibc.c it looks like this:

#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
    && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
	|| (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
# define USE_PT_GNU_EH_FRAME
#endif

#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
    && defined(__FreeBSD__) && __FreeBSD__ >= 7
# define ElfW __ElfN
# define USE_PT_GNU_EH_FRAME
#endif

#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
    && defined(TARGET_DL_ITERATE_PHDR) \
    && defined(__sun__) && defined(__svr4__)
# define USE_PT_GNU_EH_FRAME
#endif

The idea is that USE_PT_GNU_EH_FRAME should be defined on any system for
which the linker supports --eh-frame-hdr and the library supports
dl_iterate_phdr.  As you can see, the test is being done based on the
library version.  It is done this way because when gcc is being used to
build the C library, particularly when building a cross-compiler, there
is no way to test the features that the C library supports.

Ian

  reply	other threads:[~2011-02-14  5:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-13  2:15 John Marino
2011-02-14  8:11 ` Ian Lance Taylor [this message]
2011-02-14 15:48   ` John Marino
2011-02-14 17:46     ` Ian Lance Taylor

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=mcrd3mvcibd.fsf@google.com \
    --to=iant@google.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=gnugcc@marino.st \
    /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).