]> git.ipfire.org Git - thirdparty/gcc.git/commit
bpf: make sure CO-RE relocs are typed with struct BTF_KIND_STRUCT
authorCupertino Miranda <cupertino.miranda@oracle.com>
Wed, 15 Jan 2025 14:25:44 +0000 (14:25 +0000)
committerCupertino Miranda <cupertino.miranda@oracle.com>
Wed, 15 Jan 2025 16:15:36 +0000 (16:15 +0000)
commitd30def000abbc8d254a128751ac87a079cd10202
treee0327eccc030eb33b2945b9433b2beff49bb7c3b
parent8d9d583484006a75bc3ed3b3badb585f3a0bb546
bpf: make sure CO-RE relocs are typed with struct BTF_KIND_STRUCT

Based on observation within bpf-next selftests and comparisson of GCC
and clang compiled code, the BPF loader expects all CO-RE relocations to
point to BTF non const and non volatile type nodes.

gcc/ChangeLog:

* btfout.cc (get_btf_kind): Remove static from function definition.
* config/bpf/btfext-out.cc (bpf_code_reloc_add): Check if CO-RE type
is not a const or volatile.
* ctfc.h (btf_dtd_kind): Add prototype for function.

gcc/testsuite/ChangeLog:

* gcc.target/bpf/core-attr-const.c: New test.
gcc/btfout.cc
gcc/config/bpf/btfext-out.cc
gcc/ctfc.h
gcc/testsuite/gcc.target/bpf/core-attr-const.c [new file with mode: 0644]