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] btf: wrong BTF_KIND_DATSEC entries for extern variables without known section
Date: Mon, 04 Dec 2023 21:14:50 +0000	[thread overview]
Message-ID: <bug-112849-4-Y74EWWSvG7@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-112849-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112849

--- Comment #1 from David Faust <david.faust at oracle dot com> ---
Simple reproducer. Note how clang does not emit an entry
in BTF_KIND_DATASEC for 'extern int a'.

$ cat a.c
extern int a;
int b;

int foo (void)
{
  return a + b;
}

$ ~/toolchains/bpf/bin/bpf-unknown-none-gcc -gbtf -c a.c -o a.o
$ /usr/sbin/bpftool btf dump file a.o
[1] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED
[2] FUNC_PROTO '(anon)' ret_type_id=1 vlen=0
[3] VAR 'a' type_id=1, linkage=extern
[4] VAR 'b' type_id=1, linkage=global
[5] FUNC 'foo' type_id=2 linkage=global
[6] DATASEC '.bss' size=0 vlen=2
        type_id=3 offset=0 size=4 (VAR 'a')
        type_id=4 offset=0 size=4 (VAR 'b')

$ ~/toolchains/llvm/bin/clang -target bpf -c -g a.c -o a.o
$ /usr/sbin/bpftool btf dump file a.o
[1] FUNC_PROTO '(anon)' ret_type_id=2 vlen=0
[2] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED
[3] FUNC 'foo' type_id=1 linkage=global
[4] VAR 'a' type_id=2, linkage=extern
[5] VAR 'b' type_id=2, linkage=global
[6] DATASEC '.bss' size=0 vlen=1
        type_id=5 offset=0 size=4 (VAR 'b')

  reply	other threads:[~2023-12-04 21:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04 21:12 [Bug debug/112849] New: " david.faust at oracle dot com
2023-12-04 21:14 ` david.faust at oracle dot com [this message]
2023-12-05 22:07 ` [Bug debug/112849] " 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-Y74EWWSvG7@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: link
Be 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).