Exporting symbols from static binary?

Sam Lantinga slouken@devolution.com
Wed Mar 31 00:17:00 GMT 1999


Linux, x86:

We are trying to build a statically linked binary which still exports
symbols to shared objects it loads dynamically via dlopen().

Apparently if -static is used, then the dynamic sections of the executable
are not written, and the symbol information is gone.  Also, if the command
line explicitly has all the required objects for linking, and none of them
are dynamic objects, then the binary is statically linked.
If you add a bogus shared object, then that object gets linked in as well
as the shared version of libc, and /lib/ld-linux.so...

As a side note, if for some reason two versions of libc are linked, either
explicitly via -lc,/usr/lib/libc.a, or implicitly by the dependencies of
the shared libraries the binary is linked with, then the resulting binary
will crash with a segmentation fault.

If there's a better place to take this question, please let me know.

Thanks! :)

	-Sam Lantinga				(slouken@devolution.com)

Lead Programmer, Loki Entertainment Software
--
Author of Simple DirectMedia Layer -
	http://www.devolution.com/~slouken/SDL/
--


More information about the Gcc mailing list