This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Extract static object from dynamic one
Brian Dessent <brian@dessent.net> writes:
> Thomas KÃppe wrote:
>
> > Is there an obstruction in principle (that some vital information is
> > lost in the shared library), or is it simply that no such tool has been
> > written?
>
> It's not just a matter of extracting something. You'd have to rewrite
> all accesses through the GOT and PLT (for ELF) or indirections through
> .idata (for PE) to be regular symbol references. You'd have to undo
> relocs and make them into regular labels. With things like relaxation
> this becomes extremely nontrivial. In a sense this is going backwards,
> like a disassembler, because a static library is just a collection of
> unlinked .o files, whereas a shared library is fully linked.
In particular, PC relative relocations between object files will be
lost in the .so, and there is no way to recreate them as would be
required in a .o. So this conversion is not possible even in
principle.
Ian