How do I enable C++ exception handling with --eh-frame-hdr for an embedded target?

R. Diez rdiezmail-gcc@yahoo.de
Tue Jul 12 07:40:00 GMT 2011


Hi there:

I am trying to enable C++ exception handling with the new --eh-frame-hdr method on my GCC 4.5.3 + newlib cross-compiler for an embedded PowerPC EABI target.

I found this logic in file gcc/unwind-dw2-fde-glibc.c :

#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

I guess that means the --eh-frame-hdr method will only work for glibc and FreeBSD, and nothing else.

However, I would like to use --eh-frame-hdr in my embedded application too, which uses a small realtime OS and newlib. I thought support for --eh-frame-hdr depended on the linker, and not on the libc or the operating system. Or am I missing something?

If that's the case, I guess I could patch that file to always define USE_PT_GNU_EH_FRAME. Or is there anything else I should be aware of? I wonder if GCC needs a new ./configure switch like "--enable-eh-frame-hdr-support", as hard-coding this logic does not seem like a good idea, given the great number of operating systems and libraries out there.

Please copy me on the answer, as I'm not subscribed to this list.

Thanks in advance,
  R. Diez



More information about the Gcc-help mailing list