Patchwork Use dl_iterate_phdr() on OpenBSD

login
register
mail settings
Submitter Mark Kettenis
Date Sept. 15, 2012, 9:57 a.m.
Message ID <201209150957.q8F9v5Ob027803@glazunov.sibelius.xs4all.nl>
Download mbox | patch
Permalink /patch/184075/
State New
Headers show

Comments

Mark Kettenis - Sept. 15, 2012, 9:57 a.m.
Split out from <http://gcc.gnu.org/ml/gcc-patches/2012-09/msg00208.html>.

Makes exception handling in shared libraries actually work.  OpenBSD
doesn't have <elf.h> so this slightly inceases the #ifdef spaghetti.

Tested on i386-*-openbsd5.2 and amd64-*-openbsd5.2.  Turns quite a few
exception handling FAILs into PASSes.


2012-09-02  Mark Kettenis  <kettenis@openbsd.org>

        * config.host (*-*-openbsd*): Add t-eh-dw2-dip to tmake_file.
        * unwind-dw2-fde-dip.c: Don't include <elf.h> on OpenBSD.
        (USE_PT_GNU_EH_FRAME): Define for OpenBSD.
        (ElfW): Likewise.
Ian Taylor - Sept. 15, 2012, 10:39 p.m.
On Sat, Sep 15, 2012 at 2:57 AM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>
> 2012-09-02  Mark Kettenis  <kettenis@openbsd.org>
>
>         * config.host (*-*-openbsd*): Add t-eh-dw2-dip to tmake_file.
>         * unwind-dw2-fde-dip.c: Don't include <elf.h> on OpenBSD.
>         (USE_PT_GNU_EH_FRAME): Define for OpenBSD.
>         (ElfW): Likewise.

This is OK.

Thanks.

Ian
Gerald Pfeifer - Oct. 5, 2012, 11:37 p.m.
On Sat, 15 Sep 2012, Ian Lance Taylor wrote:
>> 2012-09-02  Mark Kettenis  <kettenis@openbsd.org>
>>
>>         * config.host (*-*-openbsd*): Add t-eh-dw2-dip to tmake_file.
>>         * unwind-dw2-fde-dip.c: Don't include <elf.h> on OpenBSD.
>>         (USE_PT_GNU_EH_FRAME): Define for OpenBSD.
>>         (ElfW): Likewise.
> This is OK.

Thanks, Ian, and thanks Mark for reducing the gap between 
mainline GCC and OpenBSD.  I just applied this to trunk.

Gerald

Patch

Index: config.host
===================================================================
--- config.host	(revision 191120)
+++ config.host	(working copy)
@@ -213,7 +213,7 @@ 
   esac
   ;;
 *-*-openbsd*)
-  tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic"
+  tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip"
   case ${target_thread_file} in
     posix)
       tmake_file="$tmake_file t-openbsd-thread"
Index: unwind-dw2-fde-dip.c
===================================================================
--- unwind-dw2-fde-dip.c	(revision 191120)
+++ unwind-dw2-fde-dip.c	(working copy)
@@ -33,7 +33,7 @@ 
 
 #include "tconfig.h"
 #include "tsystem.h"
-#ifndef inhibit_libc
+#if !defined(inhibit_libc) && !defined(__OpenBSD__)
 #include <elf.h>		/* Get DT_CONFIG.  */
 #endif
 #include "coretypes.h"
@@ -65,6 +65,12 @@ 
 #endif
 
 #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+    && defined(__OpenBSD__)
+# define ElfW(type) Elf_##type
+# 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