bfd_get_relocated_section_contents on hppa and ia64
Nick Clifton
nickc@redhat.com
Thu Apr 22 15:00:00 GMT 2010
Hi Camm,
> Greetings! Am looking into your suggestion re: readelf relocation
> code. I've found this comment:
>
> /* Apply relocations to a section.
> Note: So far support has been added only for those relocations
> which can be found in debug sections.
> FIXME: Add support for more relocations ? */
>
> Not sure what this means.
What it means is that the code in readelf only implements a subset of
the possible relocations that any given target can produce. In
particular it only implements those relocations which can be found
inside DWARF debug sections. So for example it implements relocations
to insert 32-bit values, but not relocations to fix up function calls.
> I need the relocated code to be executable.
> Does the above indicate that this implementation won't suffice for
> this purpose?
Yes. Or rather "yes unless you put further work into it". Adding
support for other relocations is not that hard. Providing that you have
the documentation describing what they do, that is.
If you have a look at the function apply_relocations() in readelf.c you
will see a for() loop that walks over the relocations for a given
section applying them one by one. If it comes across a relocation that
it does not know how to implement it issues a warning message. But just
before that warning there is a call to target_specific_reloc_handling().
This is where you would add the code to handle any HPPA and IA64
relocations that are not currently supported by readelf.
The main reason I suggested looking at the readelf code is that it has
most of the framework for handling relocations in place, just not the
specific code to handle every possible relocation on every possible
target. The BFD library also has code to handle relocations, and it
does cover every possible relocations - but it is a lot harder to
understand.
Cheers
Nick
More information about the Binutils
mailing list