This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: Using bfd to change the .text section of an executable


On Mon, Mar 28, 2011 at 04:42:06PM -0600, Eric Schulte wrote:
> Even with every part of the elf file updated appropriately, executables
> will not run successfully without changes to the contents of the
> compiled assembly code in progbits sections.

Right.

> As far as I can tell, there is no way to automatically identify
> addresses in compiled code, although I suppose it may be possible, as
> opcodes does print symbol names on the relevant call lines.

You will also need to update pointers in initialized data, dynamic
relocations, .got, .plt etc.  Basically you need to do everything that
the linker does..

> Any suggestions for ways around the need to change addresses embedded in
> compiled code?

There is no way to avoid it, except preallocating space at link time
for your code patches.  Tools like IBM's FDPRPro use ld -q, so you
have relocations to work with.  However, ld -q isn't well supported on
many targets.  For example, x86 does not update the emitted relocs to
suit edited TLS code sequences.

-- 
Alan Modra
Australia Development Lab, IBM


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