[PATCH] bpf: fix relocation addend incorrect symbol value

Nick Clifton nickc@redhat.com
Fri Jan 12 12:36:16 GMT 2024


Hi David,

> 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.

Approved - please apply.

Cheers
   Nick




More information about the Binutils mailing list