This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patching raw section data with non-partial_inplace relocations


I'm not sure if there's any workaround for the following situation. As you
know, constant addresses (e.g. jump tables) are loaded in powerpc as:
lis     r9, .jumptable@ha      ; load high 16 bits
addis   r9, r9, .jumptable@l   ; load low 16 bits

However, the raw contents of the .text section show something like:
lis     r9, 0
addis   r9, r9, 0

The immediate values are usually patched later while processing the dynamic
relocations (which contain the appropriate addends for .jumptable).

I've tried to replicate this process to patch my section data with
libbfd-2.28 (multiarch) as follows:

> bfd_get_section_contents(bfd_h, bfd_section, data, 0, size);
> // And for each dynamic relocation do...
> bfd_install_relocation(bfd_h, bfd_reloc, data, bfd_section->vma,
bfd_section, &errormsg);

This doesn't work (`data` remains unchanged) despite returning `ok` and
further debugging has made me notice that the relevant relocations
(R_PPC_ADDR16_HA and R_PPC_ADDR16_LO) howto's specify `partial_inplace =
FALSE`. Because of this both `bfd_install_relocation` and
`bfd_perform_relocation` return bfd_reloc_ok without patching the raw data.

Question: Is there any way of forcing the raw data to be patched? Or do I
have to implement that myself?

Thanks a lot for your time,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]