public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Controlling dynsym/symtab output
@ 2016-05-09 21:05 Evan Klitzke
  2016-05-10 14:08 ` Michael Matz
  0 siblings, 1 reply; 2+ messages in thread
From: Evan Klitzke @ 2016-05-09 21:05 UTC (permalink / raw)
  To: binutils

Hi all,

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.

Is there a way to get ld to put my symbols into the .dynsym section?
I've read some of the linker script documentation but it's not clear
to me if this is the right path to go down or how I would use a linker
script to control which symbol table things end up in.

-- 
evan klitzke
w: https://eklitzke.org/
e: evan@eklitzke.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Controlling dynsym/symtab output
  2016-05-09 21:05 Controlling dynsym/symtab output Evan Klitzke
@ 2016-05-10 14:08 ` Michael Matz
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Matz @ 2016-05-10 14:08 UTC (permalink / raw)
  To: Evan Klitzke; +Cc: binutils

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-10 14:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-09 21:05 Controlling dynsym/symtab output Evan Klitzke
2016-05-10 14:08 ` Michael Matz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).