From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21044 invoked by alias); 4 Dec 2007 14:08:17 -0000 Received: (qmail 21029 invoked by uid 22791); 4 Dec 2007 14:08:15 -0000 X-Spam-Check-By: sourceware.org Received: from lmtp2.ucs.ed.ac.uk (HELO lmtp2.ucs.ed.ac.uk) (129.215.149.71) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 04 Dec 2007 14:08:02 +0000 Received: from [0.0.0.0] (gauss.maths.ed.ac.uk [129.215.104.179]) by lmtp2.ucs.ed.ac.uk (8.13.8/8.13.7) with ESMTP id lB4E7nwU022871; Tue, 4 Dec 2007 14:07:54 GMT Message-ID: <47555F19.1060501@ed.ac.uk> Date: Tue, 04 Dec 2007 14:08:00 -0000 From: =?ISO-8859-1?Q?Thomas_K=F6ppe?= User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: gcc-help@gcc.gnu.org CC: Tom Browder Subject: Re: Extract static object from dynamic one References: <47548F85.8040002@ed.ac.uk> <8bc817ee0712040358o4e3d8d85vf9afafa25fe5eea@mail.gmail.com> <4755509F.847B5017@dessent.net> In-Reply-To: <4755509F.847B5017@dessent.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Edinburgh-Scanned: at lmtp2.ucs.ed.ac.uk with MIMEDefang 2.52, Sophie, Sophos Anti-Virus Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2007-12/txt/msg00079.txt.bz2 Brian Dessent wrote: > > Tom Browder wrote: > >> On Dec 3, 2007 5:21 PM, Thomas Köppe 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