using BFD to load and reloc a simple file
Daniel Jacobowitz
drow@false.org
Thu Mar 2 21:18:00 GMT 2006
On Thu, Mar 02, 2006 at 01:15:18PM -0800, thockin@hockin.org wrote:
> I am trying to load and relocate a simple ELF executable. It's entirely
> self contained, but needs to be loadable at an arbitrary 32 bit address.
>
> I'm trying to use libbfd for this, but I am having trouble. The load goes
> fine, and it copies the ELF data into memory where I tell it to. Very
> nice and very easy. When I call perform_relocation(), though, it goes
> haywire.
That's because this is a routine for the linker, not a routine for
in-place relocation.
> bfd_perform_relocation() eventually does:
> reloc_target_output_section = symbol->section->output_section;
>
> The problem is that output_section is always NULL. I don't want to output
> a BFD, I want to relocate it in memory.
You might be able to set the section to point at itself. However, I'm
not sure if bfd_perform_relocation even does the operation you want it
to.
--
Daniel Jacobowitz
CodeSourcery
More information about the Binutils
mailing list