Re: dl_iterate_phdr support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John Marino <gnugcc@xxxxxxxxx> 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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux