This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Relinker util?
- From: John Reiser <jreiser at BitWagon dot com>
- To: binutils at sources dot redhat dot com
- Date: Thu, 28 Feb 2002 15:32:40 -0800
- Subject: Relinker util?
- Organization: -
Mike Perry <mikepery@fscked.org> asked:
> Is there a way to add new object files into a pre-exisiting
> statically linked binary?
In most Elf ET_EXEC, you can add bytes from the end of the first
PT_LOAD up to a page boundary, and from the begnning of the second
PT_LOAD down to a page boundary, by adding one page in the middle
of the file, and adjusting .p_offset etc. In rare cases (1/4096)
this fails because the PT_LOADs abut exactly in the address space.
Another way to get space is to steal it from DT_HASH by reducing
the number of bucket headers: you get 8 bytes per bucket. See
http://www.BitWagon.com/elfvector.html for some code that does this.
But I have not figured out how to get ld [bfd] to _input_ an ET_EXEC
file (elf32-i386 format) and obey the obvious placement restrictions
on the ensuing elf32-i386 output.
--
John Reiser, jreiser@BitWagon.com