reading/writing relocation sections with bfd(binutils 2-11)

Nick Clifton nickc@cambridge.redhat.com
Sat May 11 02:22:00 GMT 2002


Hi André,

> My problem is the following: The first step of a project I deal with  
> is to copy an elf file using bfd (later on, the file will be modified, 
> that's why I can't use objcopy).
> Reading and writing the 'regular' sections is no problem, but since 
> there seem to be no relocation sections in the bfd structure, I have 
> to manage it another way. 
> I found two ways to get the relocation information: 
> bfd_canonicalize_reloc()		and
> section->relocation
> 
> I think about reading the relocation information and add it 'manually' 
> sectionwise to the output file... but I hope there is a more comfortable 
> way to manage this...

You are probably going to have to do this manually.  Take a look at
the code in bfd/elflink.h:elf_bfd_final_link() which counts emits
relocs.  You will have to do something similar in your code.

Cheers
        Nick



More information about the Binutils mailing list