Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Questions about "gcc: unrecognized option `-rdynamic'"

Tags:

c

gcc

solaris

I use gcc on Solaris 10 to build make program, and get the following information:

gcc: unrecognized option `-rdynamic'

After checking the rdynamic in gcc document, I get the following explantions:

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

My questions are:

(1) Although gcc prints "gcc: unrecognized option -rdynamic", the build is still success. Is this the default behavior of gcc?

(2) I replace "-rdynamic" with "-export-dynamic" in Makefile, and the build is success. Is there any side-effect of this substitution?

P.S. My gcc information:

bash-3.00# gcc -v
Reading specs from /usr/local/lib/gcc/i386-pc-solaris2.10/3.4.6/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --enable-shared --enable-languages=c,c++,f77
Thread model: posix
gcc version 3.4.6 
like image 395
Nan Xiao Avatar asked Oct 27 '25 08:10

Nan Xiao


1 Answers

You are using an obsolete version of gcc, but you refer to an up-to-date documentation. There is no such linker option for gcc-3.4.6, see https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Link-Options.html.

Try using -Wl,--export-dynamic option when linking instead.


I replace -rdynamic with -export-dynamic in Makefile, and the build is success. Is there any side-effect of this substitution.

This option is not documented, it may well do nothing, you need to check strace output what command line options it passes to the linker.

like image 97
Maxim Egorushkin Avatar answered Oct 29 '25 23:10

Maxim Egorushkin