BFD (mips-elf): Reading relocation entries in user program

Ian Lance Taylor iant@google.com
Mon Jul 13 05:44:00 GMT 2009


"Marshall B. Rogers" <mbr@64.vg> writes:

> I've been sifting through documentation on the BFD library in hopes of
> finding an interface for reading the relocations of a section/file
> (since I noticed various relocation types are defined in "bfd.h").
> This doesn't seem to be possible, though - I'm guessing due to BFD's
> goal of abstraction.
>
> Still, I love BFD's programming interface, and I prefer it over
> libelf, which is quite clunky. Is there a simple - albeit possibly
> hacky - way to get at the relocation entries in an ELF file through
> BFD? Hopefully I won't have to end up using some strange combination
> of BFD and libelf...

bfd_get_reloc_upper_bound and bfd_canonicalize_reloc.  See
binutils/objdump.c for an example of usage.

BFD's documentation is truly horrible.  But, then, libelf's is not all
that great either.

Ian



More information about the Binutils mailing list