From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 61CFA3858C50; Mon, 28 Mar 2022 18:41:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61CFA3858C50 From: "ibhagat at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/105089] New: CTF for a defined extern variable is ambiguous Date: Mon, 28 Mar 2022 18:41:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ibhagat 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2022 18:41:57 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105089 Bug ID: 105089 Summary: CTF for a defined extern variable is ambiguous Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: ibhagat at gcc dot gnu.org Target Milestone: --- $ cat extern.c extern const char a[]; const char a[] =3D "testme"; $ gcc -gctf -dA -S extern.c excerpt from extern.s: .long 0x5 # objtinfo_var_type .long 0x8 # objtinfo_var_type .long 0xb # objtinfo_name .long 0x1f # objtinfo_name .long 0xb # ctv_name .long 0x5 # ctv_typeidx .long 0x1f # ctv_name .long 0x8 # ctv_typeidx There are TWO CTF variable records (two ctv_name, each with a ctv_typeidx).= =20 Further, two CTF objects records as well. $ gcc -gctf -c extern.c $ objdump --ctf=3D.ctf extern.o shows: Variables: a -> 8: const const char [7] (size 0x7) -> 7: const char [7] (size 0x7) a -> 5: const const char [0] (size 0x0) -> 4: const char [0] (size 0x0) Types: 1: char (size 0x1) [0x0] (ID 0x1) (kind 1) char (aligned at 0x1, format 0x3, offset:b= its 0x0:0x8) 2: const char (size 0x1) -> 1: char (size 0x1) [0x0] (ID 0x2) (kind 12) const char (aligned at 0x1) 3: void (size 0x0) [0x0] (ID 0x3) (kind 1) void (aligned at 0x0, format 0x1, offset:b= its 0x0:0x0) 4: const char [0] (size 0x0) [0x0] (ID 0x4) (kind 4) const char [0] (aligned at 0x1) 5: const const char [0] (size 0x0) -> 4: const char [0] (size 0x0) [0x0] (ID 0x5) (kind 12) const const char [0] (aligned at 0x1) 6: long unsigned int (size 0x8) [0x0] (ID 0x6) (kind 1) long unsigned int (aligned at 0x8, format = 0x0, offset:bits 0x0:0x40) 7: const char [7] (size 0x7) [0x0] (ID 0x7) (kind 4) const char [7] (aligned at 0x1) 8: const const char [7] (size 0x7) -> 7: const char [7] (size 0x7) [0x0] (ID 0x8) (kind 12) const const char [7] (aligned at 0x1) Strings: 0:=20 1: char 6: void b: a d: long unsigned int 1f: a ... Note, two entries in the "Variables:" sub-section, and two strings "a" for = the variable name in the "Strings:" sub-section. In the above case, the compiler must emit only one entry for the variable a with type specified as const char [7]. Note that, CTF format cannot differentiate between a non-defining extern variable declaration vs. a defining variable declaration (unlike DWARF). So, emitting two CTF variable records, one for the non-defining decl and another for the defining decl will create ambiguity for the linker/CTF reader.=