]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
bpf: fix relocation addend incorrect symbol value
authorDavid Faust <david.faust@oracle.com>
Wed, 10 Jan 2024 23:05:36 +0000 (15:05 -0800)
committerDavid Faust <david.faust@oracle.com>
Fri, 12 Jan 2024 16:22:23 +0000 (08:22 -0800)
commitba7c1e37cfb498263a4e309700c27696fa5ff1ad
treecdd71668ca7941a1e1b173a867b09eab02cfd62d
parent98138c62cd7f721af132f9b24f274332fd8bf079
bpf: fix relocation addend incorrect symbol value

Relocations installed by the BPF ELF backend were sometimes incorrectly
adding the symbol value to the relocation entry addend, when the correct
relocation value was already stored in the addend. This could lead to a
relocation effectively adding the symbol value twice.

Fix that by making bpf_elf_generic_reloc () more similar to the flow of
bfd_install_relocation in the case where howto->install_addend is set,
which is how it ought to behave.

bfd/
* bpf-reloc.def (R_BPF_64_ABS32, R_BPF_64_ABS64)
(R_BPF_64_NODYLD32): Set partial_inplace to true.
* elf64-bpf.c (bpf_elf_generic_reloc): Do not include the value
of the symbol when installing relocation. Copy some additional
logic from bfd_elf_generic_reloc.

gas/
* testsuite/gas/bpf/bpf.exp: Run new test.
* testsuite/gas/bpf/elf-relo-1.d: New.
* testsuite/gas/bpf/elf-relo-1.s: New.
bfd/bpf-reloc.def
bfd/elf64-bpf.c
gas/testsuite/gas/bpf/bpf.exp
gas/testsuite/gas/bpf/elf-relo-1.d [new file with mode: 0644]
gas/testsuite/gas/bpf/elf-relo-1.s [new file with mode: 0644]