From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8EE28385840F; Tue, 5 Dec 2023 22:08:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8EE28385840F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701814137; bh=pNanpXGyDAaGq7QkI0Ge3eeiqKF+dmZhMzucNvgheMk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TlOenLXJ1DgxpyMwYV+/XhOvwfVvYxcaaTYYn6gnY+mlCEiQpSgAE4T6Pcr/AdYGG MkwKDNFlQroEY/n46XBZYxyoDp4js5aTckwvHs1teSa7KVqnDgTnhKt35JJtIdozrL /NdmeTfDfLEfAMe+xoTWQ6+3fsbvsTkpMblOE/4k= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/112849] btf: wrong BTF_KIND_DATSEC entries for extern variables without known section Date: Tue, 05 Dec 2023 22:08:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: btf-debug, wrong-debug X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112849 --- Comment #3 from GCC Commits --- The master branch has been updated by David Faust : https://gcc.gnu.org/g:b8cf266f4ca4ff89704b190c827abf9ea7e7b5bf commit r14-6195-gb8cf266f4ca4ff89704b190c827abf9ea7e7b5bf Author: David Faust Date: Mon Dec 4 14:08:03 2023 -0800 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.=