diff options
author | David Faust <david.faust@oracle.com> | 2020-05-28 20:53:29 +0200 |
---|---|---|
committer | Jose E. Marchesi <jose.marchesi@oracle.com> | 2020-05-28 21:54:46 +0200 |
commit | 12adf8053ba0b241d3973b46109842a1cbfa60de (patch) | |
tree | 4d32cb434c7326a1bec0db1286b9634895321167 /bfd/elf64-bpf.c | |
parent | 78c1c35437a013c63acbff6926ff8d254e283d69 (diff) | |
download | gdb-12adf8053ba0b241d3973b46109842a1cbfa60de.zip gdb-12adf8053ba0b241d3973b46109842a1cbfa60de.tar.gz gdb-12adf8053ba0b241d3973b46109842a1cbfa60de.tar.bz2 |
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.
Diffstat (limited to 'bfd/elf64-bpf.c')
-rw-r--r-- | bfd/elf64-bpf.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/bfd/elf64-bpf.c b/bfd/elf64-bpf.c index bf488af..641caa1 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, |