diff options
author | David Faust <david.faust@oracle.com> | 2023-12-04 14:08:03 -0800 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2023-12-05 14:02:16 -0800 |
commit | b8cf266f4ca4ff89704b190c827abf9ea7e7b5bf (patch) | |
tree | 10e381ebf03e31824d7008febe3891a9300d2d9f /gcc/ada/gcc-interface/utils.cc | |
parent | 9610ba7b6ff88c1c9b4fba232458e9397cc71a02 (diff) | |
download | gcc-b8cf266f4ca4ff89704b190c827abf9ea7e7b5bf.zip gcc-b8cf266f4ca4ff89704b190c827abf9ea7e7b5bf.tar.gz gcc-b8cf266f4ca4ff89704b190c827abf9ea7e7b5bf.tar.bz2 |
btf: avoid wrong DATASEC entries for extern vars [PR112849]
The process of creating BTF_KIND_DATASEC records involves iterating
through variable declarations, determining which section they will be
placed in, and creating an entry in the appropriate DATASEC record
accordingly.
For variables without e.g. an explicit __attribute__((section)), we use
categorize_decl_for_section () to identify the appropriate named section
and corresponding BTF_KIND_DATASEC record.
This was incorrectly being done for 'extern' variable declarations as
well as non-extern ones, which meant that extern variable declarations
could result in BTF_KIND_DATASEC entries claiming the variable is
allocated in some section such as '.bss' without any knowledge whether
that is actually true. That resulted in errors building the Linux kernel
BPF selftests.
This patch corrects btf_collect_datasec () to avoid assuming a section
for extern variables, and only emit BTF_KIND_DATASEC entries for them if
they have a known section.
gcc/
PR debug/112849
* btfout.cc (btf_collect_datasec): Avoid incorrectly creating an
entry in a BTF_KIND_DATASEC record for extern variable decls without
a known section.
gcc/testsuite/
PR debug/112849
* gcc.dg/debug/btf/btf-datasec-3.c: New test.
Diffstat (limited to 'gcc/ada/gcc-interface/utils.cc')
0 files changed, 0 insertions, 0 deletions