Patching raw section data with non-partial_inplace relocations

Nick Clifton nickc@redhat.com
Fri Jun 30 15:45:00 GMT 2017


Hi Alexandro,

>> But ... have you tried using the assembler to generate the raw data with reloc directives attached ?
> 
> Not sure if I understand this correctly, is this part of BFD? The binaries I'm processing are given as-is and I cannot assume that C/C++/ASM sources are available to compile them with other flags if that's what you mean.

Sorry - I was not very clear.  What I was suggesting was that you write a script that
converts the raw binaries into a series of assembler directives that would reproduce
the data.  So for example suppose that your input binary contains the bytes 0x12 0x34
0x56 0x78 in that order then the script would produce:

  .data
  .byte 0x12, 0x34, 0x56, 0x78

or more likely, since I assume that you are working on 32-bit words:

  .data
  .word 0x12345678

(or similar, depending upon endianness, and the architecture you are targeting).

Once you have done this, you can then annotate the assembler source, adding in 
the necessary relocation hints, and then assemble the result.  Eg:

  .data
  .word 0x12345678@ha

Cheers
  Nick




More information about the Binutils mailing list