bpf: ensure correct string offsets in BTF.ext
authorDavid Faust <david.faust@oracle.com>
Tue, 14 Dec 2021 21:48:21 +0000 (13:48 -0800)
committerDavid Faust <david.faust@oracle.com>
Tue, 18 Jan 2022 21:20:49 +0000 (13:20 -0800)
commit7db42268ce4bc77bc13f13ba0899221747255bb5
tree57a9b3828f6e1636b145a6aae83c681a36159dca
parent43ec2652134239f83cd4c06bc4d8158acc0721cf
bpf: ensure correct string offsets in BTF.ext

BPF CO-RE relocations contain offsets to strings buffered in the BTF
string table. These BTF-specific strings are stored in memory in the
CTF auxilliary strtab, which at output time is concatenated onto the end
of the standard strtab.

Previously, these string offsets were computed at the time the
relocations were created. But strings could be added to the standard
strtab after this point, causing the offsets to no longer be correct.

Compute the offsets just before output instead, when they are sure to no
longer change.

gcc/ChangeLog:

* config/bpf/coreout.cc (bpf_core_reloc_add): Do not account
for base strtab offset yet as it may change.
(output_asm_btfext_core_reloc): Do so here instead.
(output_btfext_core_sections): Likewise.
gcc/config/bpf/coreout.cc