This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Patching raw section data with non-partial_inplace relocations
- From: Nick Clifton <nickc at redhat dot com>
- To: Alexandro Sanchez Bach <alexaltea123 at gmail dot com>, binutils at sourceware dot org
- Date: Fri, 30 Jun 2017 16:45:42 +0100
- Subject: Re: Patching raw section data with non-partial_inplace relocations
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=nickc at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A906B63E23
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A906B63E23
- References: <004b01d2eb57$9c5e8d10$d51ba730$@gmail.com> <09528cd2-36d1-0419-6c47-3dc00ccdcc93@redhat.com> <003201d2f0c9$7f82d8a0$7e8889e0$@gmail.com>
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