[NCLUG] extracting library from statically linked executable
Stephen Warren
swarren at wwwdotorg.org
Wed Dec 20 15:09:36 MST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Daniel Herrington wrote:
> I have a question about reusing the library routines from an old program
> in a new one. Is it possible to extract the library routines from an ELF
> executable into a .so style library, so that I can link a new program
> against it and use the functions defined in it? I looked at the man
> pages for ar, ranlib, ld, nm, objcopy, and objdump, but I couldn't find
> anything about this.
The simple answer is no.
Typically, objects, archives (libraries), or shared libraries contain
both the actual compiled code itself, plus a lot of extra information
that the linker needs when creating the final linked executable. Once
the executable is created, this information is "lost" (i.e. isn't put in
the executable; it's still in the input files!) and hence the executable
can't be input to the linker again.
In theory, if the original objects were compiled "position independant",
you just might be able to (with a lot of manual work, or via writing a
complex program) extract the individual functions from the executable
and make it work. However, that'd be a topic for a very advanced PhD
thesis (for the general case anyway)...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFibSghk3bo0lNTrURAjjdAKD3SYkyVFhJnaKdC8jtth5YLpFBYACfdmEV
r9QJKLBy1DCSL9WHMUdyMwo=
=779w
-----END PGP SIGNATURE-----
More information about the NCLUG
mailing list