public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "david.faust at oracle dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/112849] New: btf: wrong BTF_KIND_DATSEC entries for extern variables without known section Date: Mon, 04 Dec 2023 21:12:12 +0000 [thread overview] Message-ID: <bug-112849-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112849 Bug ID: 112849 Summary: btf: wrong BTF_KIND_DATSEC entries for extern variables without known section Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: btf-debug, wrong-debug Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: david.faust at oracle dot com CC: cupertino.miranda at oracle dot com, ibhagat at gcc dot gnu.org, jemarch at gcc dot gnu.org Target Milestone: --- When building bpf-next selftests with gcc trunk, we get the following error from libbpf: libbpf: linker: adding object file 'linked_vars1.bpf.o'... libbpf: linker: adding object file 'linked_vars2.bpf.o'... libbpf: global 'input_data1': section mismatch 4 vs 5 Error: failed to link 'linked_vars2.bpf.o': Invalid argument (22) Here libbpf is doing some form of linking of the two objects. 'input_data1' is declared and initialized in linked_vars1, and placed in .data. In linked_vars2 it is declared extern, however an entry for it is added in the .bss BTF_KIND_DATASEC record in linked_vars2.bpf.o. clang does not emit entries in BTF_KIND_DATASEC for extern variable decls without an explicit section e.g. via __attribute__((section(...))). gcc [7237] DATASEC '.bss' size=0 vlen=8 type_id=7059 offset=0 size=4 (VAR 'input_data1') <----- type_id=7167 offset=0 size=4 (VAR 'input_bss1') <----- type_id=7100 offset=0 size=4 (VAR 'output_sink2') type_id=7111 offset=0 size=4 (VAR 'output_rodata2') type_id=7065 offset=0 size=4 (VAR 'output_data2') type_id=7090 offset=0 size=4 (VAR 'output_bss2') type_id=7079 offset=0 size=4 (VAR 'input_bss_weak') type_id=7192 offset=0 size=4 (VAR 'input_bss2') clang [34] DATASEC '.bss' size=0 vlen=6 type_id=18 offset=0 size=4 (VAR 'input_bss2') type_id=19 offset=0 size=4 (VAR 'input_bss_weak') type_id=20 offset=0 size=4 (VAR 'output_bss2') type_id=21 offset=0 size=4 (VAR 'output_data2') type_id=22 offset=0 size=4 (VAR 'output_rodata2') type_id=23 offset=0 size=4 (VAR 'output_sink2') The problem is that when creating the BTF_KIND_DATASEC entires, gcc is incorrectly falling back to a default section name (like .bss) for variables, even if they are 'extern' decls. gcc should be changed to not emit entries in any BTF_KIND_DATASEC for extern variable decls without a known section.
next reply other threads:[~2023-12-04 21:12 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-12-04 21:12 david.faust at oracle dot com [this message] 2023-12-04 21:14 ` [Bug debug/112849] " david.faust at oracle dot com 2023-12-05 22:07 ` ibhagat at gcc dot gnu.org 2023-12-05 22:08 ` cvs-commit at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-112849-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).