The following lets -rdynamic work on OpenBSD. Added to every OpenBSD target that defines LIB_SPEC.
Gerald Pfeifer has previously volunteered to apply my patches based on maintainer approval. 2011-10-22 Jonathan Gray <j...@openbsd.org> * config/openbsd.opt (rdynamic): New Driver option. * config/sparc/openbsd64.h (LINK_SPEC): Handle -rdynamic. * config/i386/openbsdelf.h (LINK_SPEC): Handle -rdynamic. * config/mips/openbsd.h (LINK_SPEC): Handle -rdynamic. Index: gcc/config/sparc/openbsd64.h =================================================================== --- gcc/config/sparc/openbsd64.h (revision 180322) +++ gcc/config/sparc/openbsd64.h (working copy) @@ -70,6 +70,7 @@ %{shared:-shared} %{R*} \ %{static:-Bstatic} \ %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ %{assert*} \ -dynamic-linker /usr/libexec/ld.so" Index: gcc/config/i386/openbsdelf.h =================================================================== --- gcc/config/i386/openbsdelf.h (revision 180322) +++ gcc/config/i386/openbsdelf.h (working copy) @@ -128,6 +128,7 @@ %{shared:-shared} %{R*} \ %{static:-Bstatic} \ %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ %{assert*} \ -dynamic-linker /usr/libexec/ld.so" Index: gcc/config/openbsd.opt =================================================================== --- gcc/config/openbsd.opt (revision 180322) +++ gcc/config/openbsd.opt (working copy) @@ -33,4 +33,7 @@ pthread Driver +rdynamic +Driver + ; This comment is to ensure we retain the blank line above. Index: gcc/config/mips/openbsd.h =================================================================== --- gcc/config/mips/openbsd.h (revision 180322) +++ gcc/config/mips/openbsd.h (working copy) @@ -81,7 +81,10 @@ %{!shared: -non_shared} \ -dynamic-linker /usr/libexec/ld.so \ %{!nostdlib:%{!r:%{!e*:-e __start}}} -dc -dp \ - %{static:-Bstatic} %{!static:-Bdynamic} %{assert*}" + %{static:-Bstatic} \ + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*}" /* -G is incompatible with -KPIC which is the default, so only allow objects in the small data section if the user explicitly asks for it. */