export symbols

Ian Lance Taylor iant@google.com
Tue Aug 11 16:16:00 GMT 2009

Alberich de megres <alberich2k5@gmail.com> writes:

> I know it's been a long since i first send my question.. but i'm still stucked.
> Versioning symbols does not add them to dynsym table.
> Maybe i explained myself in the wrong way:
> - I got host program P, with its functions and i want only one to be
> seen by modules (function F).
> - In the other side i got a program M (module), that is loaded by P
> and then it uses the F function from P.
> If i compile with -rdynamic option in gcc, it works fine but it
> exports all the functions on .dynsym.
> Using versioning, and adding this on my code:
> __asm__(".symver F,  F@");
> Only adds F@ to .symtab, but not to .dynsym. So when executing the
> program i get the following message:
> ./main: symbol lookup error: ../mod/log: undefined symbol: F
> And i tried to  --dynamic-list option.. but with no results.
> Any idea or tip??

I recommend that you look at linker version scripts, which permit you to
set specific symbols to be "local" and "global".  See the linker
documentation.  This approach requires an external list of symbols.  It
does not require any specification in the source code.

Another option is to use the visibility attribute, or the -fvisibility
option.  See the compiler documentation for that.


More information about the Gcc-help mailing list