fix gcc -rdynamic

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

fix gcc -rdynamic

Jonathan Gray
The following fixes the gcc link spec so that gcc -rdynamic
will pass -export-dynamic to ld(1).  export-dynamic/-E has
been a valid gnu ld option since 1994 and we use 2.15 everywhere
at the moment so this should be fine.  objdump -T can
be used to easily test this.

This diff does not contain powerpc/rs6000 as it is
already in the spec there.

From http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html

-rdynamic
    Pass the flag -export-dynamic to the ELF linker, on targets that
    support it. This instructs the linker to add all symbols, not only
    used ones, to the dynamic symbol table. This option is needed for
    some uses of dlopen or to allow obtaining backtraces from within a
    program.

Index: egcs/gcc/config/sparc/openbsd.h
===================================================================
RCS file: /cvs/src/gnu/egcs/gcc/config/sparc/openbsd.h,v
retrieving revision 1.5
diff -u -p -r1.5 openbsd.h
--- egcs/gcc/config/sparc/openbsd.h 13 Jan 2006 17:51:18 -0000 1.5
+++ egcs/gcc/config/sparc/openbsd.h 28 Jun 2011 17:17:01 -0000
@@ -32,6 +32,7 @@ Boston, MA 02111-1307, USA.  */
    %{shared:-shared} %{R*} \
    %{static:-Bstatic} \
    %{!static:-Bdynamic} \
+   %{rdynamic:-export-dynamic} \
    %{assert*} \
    %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
 
Index: usr.bin/gcc/gcc/config/alpha/openbsd.h
===================================================================
RCS file: /cvs/src/gnu/usr.bin/gcc/gcc/config/alpha/openbsd.h,v
retrieving revision 1.10
diff -u -p -r1.10 openbsd.h
--- usr.bin/gcc/gcc/config/alpha/openbsd.h 2 Mar 2011 04:12:50 -0000 1.10
+++ usr.bin/gcc/gcc/config/alpha/openbsd.h 28 Jun 2011 17:17:02 -0000
@@ -31,6 +31,7 @@ Boston, MA 02111-1307, USA.  */
    %{shared:-shared} %{R*} \
    %{static:-Bstatic} \
    %{!static:-Bdynamic} \
+   %{rdynamic:-export-dynamic} \
    %{assert*} \
    %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
 
Index: usr.bin/gcc/gcc/config/arm/openbsd.h
===================================================================
RCS file: /cvs/src/gnu/usr.bin/gcc/gcc/config/arm/openbsd.h,v
retrieving revision 1.9
diff -u -p -r1.9 openbsd.h
--- usr.bin/gcc/gcc/config/arm/openbsd.h 11 Nov 2008 23:48:19 -0000 1.9
+++ usr.bin/gcc/gcc/config/arm/openbsd.h 28 Jun 2011 17:17:02 -0000
@@ -87,6 +87,7 @@ Boston, MA 02111-1307, USA.  */
    %{shared:-shared} %{R*} \
    %{static:-Bstatic} \
    %{!static:-Bdynamic} \
+   %{rdynamic:-export-dynamic} \
    %{assert*} \
    %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
 #endif
Index: usr.bin/gcc/gcc/config/sh/openbsd.h
===================================================================
RCS file: /cvs/src/gnu/usr.bin/gcc/gcc/config/sh/openbsd.h,v
retrieving revision 1.11
diff -u -p -r1.11 openbsd.h
--- usr.bin/gcc/gcc/config/sh/openbsd.h 16 Jun 2007 01:09:43 -0000 1.11
+++ usr.bin/gcc/gcc/config/sh/openbsd.h 28 Jun 2011 17:17:02 -0000
@@ -64,7 +64,13 @@ Boston, MA 02111-1307, USA.  */
   "%{g:%{!nostdlib:-L/usr/lib/debug}} %{!nostdlib:%{!r*:%{!e*:-e __start}}} -dc -dp %{assert*}"
 #else
 #define SUBTARGET_LINK_SPEC \
-  "%{g:%{!nostdlib:-L/usr/lib/debug}} %{!shared:%{!nostdlib:%{!r*:%{!e*:-e __start}}}} %{shared:-Bshareable -x} -dc -dp %{R*} %{static:-Bstatic} %{assert*} %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
+  "%{g:%{!nostdlib:-L/usr/lib/debug}} \
+   %{!shared:%{!nostdlib:%{!r*:%{!e*:-e __start}}}} \
+   %{shared:-Bshareable -x} -dc -dp %{R*} \
+   %{static:-Bstatic} \
+   %{rdynamic:-export-dynamic} \
+   %{assert*} \
+   %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
 #endif
 
 
Index: gcc/gcc/config/alpha/openbsd.h
===================================================================
RCS file: /cvs/src/gnu/gcc/gcc/config/alpha/openbsd.h,v
retrieving revision 1.3
diff -u -p -r1.3 openbsd.h
--- gcc/gcc/config/alpha/openbsd.h 12 May 2010 18:19:50 -0000 1.3
+++ gcc/gcc/config/alpha/openbsd.h 28 Jun 2011 17:17:05 -0000
@@ -31,6 +31,7 @@ Boston, MA 02110-1301, USA.  */
    %{shared:-shared} %{R*} \
    %{static:-Bstatic} \
    %{!static:-Bdynamic} \
+   %{rdynamic:-export-dynamic} \
    %{assert*} \
    %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
 
Index: gcc/gcc/config/arm/openbsd.h
===================================================================
RCS file: /cvs/src/gnu/gcc/gcc/config/arm/openbsd.h,v
retrieving revision 1.3
diff -u -p -r1.3 openbsd.h
--- gcc/gcc/config/arm/openbsd.h 25 Jun 2011 20:56:21 -0000 1.3
+++ gcc/gcc/config/arm/openbsd.h 28 Jun 2011 17:17:05 -0000
@@ -72,6 +72,7 @@ Boston, MA 02111-1307, USA.  */
    %{shared:-shared} %{R*} \
    %{static:-Bstatic} \
    %{!static:-Bdynamic} \
+   %{rdynamic:-export-dynamic} \
    %{assert*} \
    %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
 #endif
Index: gcc/gcc/config/i386/openbsd64.h
===================================================================
RCS file: /cvs/src/gnu/gcc/gcc/config/i386/openbsd64.h,v
retrieving revision 1.1
diff -u -p -r1.1 openbsd64.h
--- gcc/gcc/config/i386/openbsd64.h 15 Oct 2009 21:16:33 -0000 1.1
+++ gcc/gcc/config/i386/openbsd64.h 28 Jun 2011 17:17:05 -0000
@@ -112,6 +112,7 @@ Boston, MA 02111-1307, USA.  */
    %{shared:-shared} %{R*} \
    %{static:-Bstatic} \
    %{!static:-Bdynamic} \
+   %{rdynamic:-export-dynamic} \
    %{assert*} \
    %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
 
Index: gcc/gcc/config/i386/openbsdelf.h
===================================================================
RCS file: /cvs/src/gnu/gcc/gcc/config/i386/openbsdelf.h,v
retrieving revision 1.2
diff -u -p -r1.2 openbsdelf.h
--- gcc/gcc/config/i386/openbsdelf.h 15 Oct 2009 21:16:33 -0000 1.2
+++ gcc/gcc/config/i386/openbsdelf.h 28 Jun 2011 17:17:05 -0000
@@ -123,6 +123,7 @@ Boston, MA 02110-1301, USA.  */
    %{shared:-shared} %{R*} \
    %{static:-Bstatic} \
    %{!static:-Bdynamic} \
+   %{rdynamic:-export-dynamic} \
    %{assert*} \
    %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
 
Index: gcc/gcc/config/mips/openbsd.h
===================================================================
RCS file: /cvs/src/gnu/gcc/gcc/config/mips/openbsd.h,v
retrieving revision 1.2
diff -u -p -r1.2 openbsd.h
--- gcc/gcc/config/mips/openbsd.h 10 Sep 2010 16:20:11 -0000 1.2
+++ gcc/gcc/config/mips/openbsd.h 28 Jun 2011 17:17:05 -0000
@@ -132,6 +132,7 @@ Boston, MA 02110-1301, USA.  */
    %{shared:-shared} %{R*} \
    %{static:-Bstatic} \
    %{!static:-Bdynamic} \
+   %{rdynamic:-export-dynamic} \
    %{assert*} \
    %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
 
Index: gcc/gcc/config/pa/openbsd.h
===================================================================
RCS file: /cvs/src/gnu/gcc/gcc/config/pa/openbsd.h,v
retrieving revision 1.2
diff -u -p -r1.2 openbsd.h
--- gcc/gcc/config/pa/openbsd.h 26 Apr 2010 21:29:00 -0000 1.2
+++ gcc/gcc/config/pa/openbsd.h 28 Jun 2011 17:17:05 -0000
@@ -155,7 +155,8 @@ Boston, MA 02111-1307, USA.  */
    %{!shared: %{!non_shared: %{!call_shared: -non_shared}}} \
    %{!dynamic-linker:-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*}"
 
 /* Layout of source language data types. */
 
Index: gcc/gcc/config/sh/openbsd.h
===================================================================
RCS file: /cvs/src/gnu/gcc/gcc/config/sh/openbsd.h,v
retrieving revision 1.1
diff -u -p -r1.1 openbsd.h
--- gcc/gcc/config/sh/openbsd.h 9 Sep 2010 19:16:50 -0000 1.1
+++ gcc/gcc/config/sh/openbsd.h 28 Jun 2011 17:17:05 -0000
@@ -74,7 +74,13 @@ Boston, MA 02110-1301, USA.  */
   "%{g:%{!nostdlib:-L/usr/lib/debug}} %{!nostdlib:%{!r*:%{!e*:-e __start}}} -dc -dp %{assert*}"
 #else
 #define SUBTARGET_LINK_SPEC \
-  "%{g:%{!nostdlib:-L/usr/lib/debug}} %{!shared:%{!nostdlib:%{!r*:%{!e*:-e __start}}}} %{shared:-Bshareable -x} -dc -dp %{R*} %{static:-Bstatic} %{assert*} %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
+  "%{g:%{!nostdlib:-L/usr/lib/debug}} \
+   %{!shared:%{!nostdlib:%{!r*:%{!e*:-e __start}}}} \
+   %{shared:-Bshareable -x} -dc -dp %{R*} \
+   %{static:-Bstatic} \
+   %{rdynamic:-export-dynamic} \
+   %{assert*} \
+   %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
 #endif
 
 
Index: gcc/gcc/config/sparc/openbsd.h
===================================================================
RCS file: /cvs/src/gnu/gcc/gcc/config/sparc/openbsd.h,v
retrieving revision 1.2
diff -u -p -r1.2 openbsd.h
--- gcc/gcc/config/sparc/openbsd.h 12 Dec 2010 18:51:42 -0000 1.2
+++ gcc/gcc/config/sparc/openbsd.h 28 Jun 2011 17:17:05 -0000
@@ -73,6 +73,7 @@ Boston, MA 02110-1301, USA.  */
    %{shared:-shared} %{R*} \
    %{static:-Bstatic} \
    %{!static:-Bdynamic} \
+   %{rdynamic:-export-dynamic} \
    %{assert*} \
    %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
 
Index: gcc/gcc/config/sparc/openbsd64.h
===================================================================
RCS file: /cvs/src/gnu/gcc/gcc/config/sparc/openbsd64.h,v
retrieving revision 1.3
diff -u -p -r1.3 openbsd64.h
--- gcc/gcc/config/sparc/openbsd64.h 10 May 2010 21:02:58 -0000 1.3
+++ gcc/gcc/config/sparc/openbsd64.h 28 Jun 2011 17:17:05 -0000
@@ -83,6 +83,7 @@ Boston, MA 02110-1301, USA.  */
    %{shared:-shared} %{R*} \
    %{static:-Bstatic} \
    %{!static:-Bdynamic} \
+   %{rdynamic:-export-dynamic} \
    %{assert*} \
    %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"

Reply | Threaded
Open this post in threaded view
|

Re: fix gcc -rdynamic

Brad Smith-14
On 28/06/11 1:24 PM, Jonathan Gray wrote:
> The following fixes the gcc link spec so that gcc -rdynamic
> will pass -export-dynamic to ld(1).  export-dynamic/-E has
> been a valid gnu ld option since 1994 and we use 2.15 everywhere
> at the moment so this should be fine.  objdump -T can
> be used to easily test this.

This has been a known issue with our system compilers for awhile.
Thanks for creating a diff to fix this. It would be nice to get this
in and clean up the few workarounds in the ports tree.

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.