From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
To: binutils@sourceware.org
Subject: [COMMITTED][BPF] bfd: fix handling of R_BPF_INSN_{32, 64} relocations.
Date: Thu, 28 May 2020 21:57:10 +0200 [thread overview]
Message-ID: <87a71r4yuh.fsf@oracle.com> (raw)
Just pushed the patch below on behalf of David Faust.
Salud!
Author: David Faust <david.faust@oracle.com>
Date: Thu May 28 20:53:29 2020 +0200
bfd: fix handling of R_BPF_INSN_{32,64} relocations.
2020-05-28 David Faust <david.faust@oracle.com>
* elf64-bpf.c (bpf_elf_relocate_section): Fix handling of
R_BPF_INSN_{32,64} relocations.
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 482bf81e68..05452c5d46 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2020-05-28 David Faust <david.faust@oracle.com>
+
+ * elf64-bpf.c (bpf_elf_relocate_section): Fix handling of
+ R_BPF_INSN_{32,64} relocations.
+
2020-05-28 Stephen Casner <casner@acm.org>
* pdp11.c: Implement BRD_RELOC_32 to relocate the low 16 bits of
diff --git a/bfd/elf64-bpf.c b/bfd/elf64-bpf.c
index bf488af81f..641caa1f05 100644
--- a/bfd/elf64-bpf.c
+++ b/bfd/elf64-bpf.c
@@ -64,7 +64,7 @@ static reloc_howto_type bpf_elf_howto_table [] =
MINUS_ONE, /* dst_mask */
TRUE), /* pcrel_offset */
- /* 32-immediate in LDDW instruction. */
+ /* 32-immediate in many instructions. Note: handled manually. */
HOWTO (R_BPF_INSN_32, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
@@ -460,6 +460,31 @@ bpf_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
r = bfd_reloc_ok;
break;
}
+ case R_BPF_INSN_32:
+ {
+ /* Write relocated value */
+ bfd_put (howto->bitsize, input_bfd, relocation,
+ contents + rel->r_offset + 4);
+
+ r = bfd_reloc_ok;
+ break;
+ }
+ case R_BPF_INSN_64:
+ {
+ /*
+ LDDW instructions are 128 bits long, with a 64-bit immediate.
+ The lower 32 bits of the immediate are in the same position
+ as the imm32 field of other instructions.
+ The upper 32 bits of the immediate are stored at the end of
+ the instruction.
+ */
+ bfd_put (32, input_bfd, (relocation & 0xFFFFFFFF),
+ contents + rel->r_offset + 4);
+ bfd_put (32, input_bfd, (relocation >> 32),
+ contents + rel->r_offset + 12);
+ r = bfd_reloc_ok;
+ break;
+ }
default:
r = _bfd_final_link_relocate (howto, input_bfd, input_section,
contents, rel->r_offset, relocation,
reply other threads:[~2020-05-28 19:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a71r4yuh.fsf@oracle.com \
--to=jose.marchesi@oracle.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).