This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: relinking a program with shared library
- From: Ian Lance Taylor <iant at google dot com>
- To: Marcin Kasprzak <mkasprzak at autograf dot pl>
- Cc: tprince at computer dot org, gcc-help at gcc dot gnu dot org
- Date: Mon, 29 Dec 2008 18:34:28 -0800
- Subject: Re: relinking a program with shared library
- References: <Q188642135-14bdfcf62a69f4febe406df1e23b9035@pmq3.test.onet.pl>
Marcin Kasprzak <mkasprzak@autograf.pl> writes:
> My platform is x86 machine, running linux with ELF executable.
> I'm thinking about the way of doing a sort of conversion from
> .so (PIC) to .a (static) lib and then (this part is more tricky) to
> relink it against binary.
> As I wrote previously I don't have access to source code or .o (object)
> files (this is a sort of 3rd party software).
>
> I believe that two separate actions are needed:
> 1. Conversion from .so to .a
> 2. decomposition of binary file back to .o files and
> one again linkage(ld) process this time against static libs
>
> Is it possible to do that?
No. It is not possible to run a .so file into a .a file. The .so
file no longer has any record of the various places which call into
the PLT and GOT. It might be possible to do an approximation by
somehow introducing an initialization routine which set up the PLT and
GOT as required. I don't know of any tool which does that.
It is not possible to turn a linked executable back into .o files.
The relocation information has been irretrievably lost.
Ian