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

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

 



"R. Diez" <rdiezmail-gcc@xxxxxxxx> writes:

> 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.


The --eh-frame-hdr option will work provided you have a way to locate
the exception frame header at runtime.  The --eh-frame-hdr option
creates a new PT_GNU_EH_FRAME program segment.  At runtime the library
will call dl_iterate_phdr to find that segment (in _Unwind_Find_FDE in
unwind-dw2-fde-glibc.c).  Your realtime OS probably does not provide
dl_iterate_phdr, and you probably don't load the program segments onto
the embedded system anyhow.

So you can use something very similar to --eh-frame-hdr, but you will
probably have to invent some new way to locate the information at
runtime.  And when you do that you will have to change crtstuff.c and
some unwind-dw2-XX.c file as well.

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