Controlling dynsym/symtab output

Michael Matz matz@suse.de
Tue May 10 14:08:00 GMT 2016


Hi,

On Mon, 9 May 2016, Evan Klitzke wrote:

> I'm interested in creating an executable that can be loaded by dlopen as 
> a DSO. My understanding is that it is possible to do this if the 
> executable is compiled as a PIE, and indeed I can dlopen executables 
> compiled with gcc -fPIC -pie. However, when I do this all of my symbols 
> end up in the .symtab section even if they are marked with default 
> visibility and are not static, and it appears that dlopen will only load 
> symbols from the .dynsym section.

ld doesn't export any symbols for executables by default (except those 
required for correctness, like e.g. destination of copy relocs).  Use -E 
aka --export-dynamic to change this (if you do that you should be able to 
use the various ld options to manipulate the dynamic symbol list)P.


Ciao,
Michael.



More information about the Binutils mailing list