This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Extract static object from dynamic one


Brian Dessent wrote:
>
> Tom Browder wrote:
>
>> On Dec 3, 2007 5:21 PM, Thomas Köppe <t.koeppe@ed.ac.uk> wrote:
>>
>>> [...]
>>>
>>> Suppose I have a dynamic C library libfoo.so (or foo.dll) along with
>>> headers in foo.h. Is it possible to build from the binary a static
>>> library libfoo.a?
>>
>> I believe GNU libtool can be used to do that.
>> [...]
>
> Libtool is useful for creating both shared and static at the same
> (build) time, but it won't let you create a static library from an
> already linked shared library.  There is no way to do that, as far as I
> know.  You need to recompile from source.
>
> Brian

I agree that libtool does not deal with binary files in that way; that's why I was thinking about something from binutils.

But is there a reason that it should be impossible in principle to reconstruct a statically linkable object from a shared library? After all, the code is there, I know the function signatures, and relocatable addresses can be resolved to fixed addresses at link time.

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?

Many thanks,

Thomas


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]