This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: using BFD to load and reloc a simple file
- From: Daniel Jacobowitz <drow at false dot org>
- To: thockin at hockin dot org
- Cc: binutils at sourceware dot org
- Date: Thu, 2 Mar 2006 16:18:00 -0500
- Subject: Re: using BFD to load and reloc a simple file
- References: <20060302211518.GA29595@hockin.org>
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