Re: relink a dynamically linke executable to make some of the libraries static?
- From: Grant Edwards <grante@xxxxxxxx>
- Date: Fri, 14 Sep 2007 21:58:10 -0000
On 2007-09-14, John Reiser <jreiser@xxxxxxxxxxxx> wrote:
If I have an ELF executable that dynamically linked against 6
different shared objects, is there a way to link it "again" to
pull one of those in as a static library?
Or do I have to re-do the link that was used to create the
executable?
In order to do any linking, then /bin/ld requires inputs that are ET_REL.
You could try using objcopy, and/or --oformat of /bin/ld, to take apart
the executable and the library, generating pieces that are ET_REL and
with symbols and relocations intact. Consider using a binary editor
to change the two-byte tag Elf32_Ehdr.e_type from ET_EXEC or ET_DYN
into ET_REL. In general you require the "linking view" information
contained in Elf32_Shdr records (and not the "execution view" information
contained in Elf32_Phdr records). Any input that has been "stripped"
will be a disaster.
Study the loading done at the last stages of making Linux kernels.
See the Makefiles and ".*.cmd" files [after successful load] in
linux/arch/$ARCH/boot{,compressed}.
You could do it yourself, particularly if total cleanliness was not required.
Concatenate the PT_LOADs, and concatenate/merge the non-PT_LOAD info. The
output would have as many PT_LOAD as the sum of the input PT_LOAD. Most
of the tables referenced from the Elf32_Ehdr could move to beyond the end
of the original ET_EXEC. The old tables may be left in place, unreferenced.
See also the 'statifier' project http://statifier.sourceforge.net
and the 'jumpstart' tool http://BitWagon.com/jumpstart/jumpstart.html
Both of these create "packages" of executables "bound" to shared libraries.
Thanks for the pointers. It's mostly just an academic
question, since I can just hack up the makefile and re-build
from sources. Actually, it's currently a moot point since the
library I want to 'statify' into the app is libtcl8.4: I
haven't yet figured out how to get a static library out of TCL
8.4's build process.
--
Grant Edwards grante Yow! Half a mind is a
at terrible thing to waste!
visi.com
.
- Follow-Ups:
- Re: relink a dynamically linke executable to make some of the libraries static?
- From: Grant Edwards
- Re: relink a dynamically linke executable to make some of the libraries static?
- References:
- relink a dynamically linke executable to make some of the libraries static?
- From: Grant Edwards
- Re: relink a dynamically linke executable to make some of the libraries static?
- From: John Reiser
- relink a dynamically linke executable to make some of the libraries static?
- Prev by Date: Re: relink a dynamically linke executable to make some of the libraries static?
- Next by Date: Re: relink a dynamically linke executable to make some of the libraries static?
- Previous by thread: Re: relink a dynamically linke executable to make some of the libraries static?
- Next by thread: Re: relink a dynamically linke executable to make some of the libraries static?
- Index(es):
Relevant Pages
|