public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/114608] New: [14 Regression] Undefined reference in output asm with -fipa-reference -fipa-reference-addressable -fsection-anchors -gbtf
@ 2024-04-05 17:42 patrick at rivosinc dot com
  2024-04-05 17:43 ` [Bug debug/114608] " patrick at rivosinc dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: patrick at rivosinc dot com @ 2024-04-05 17:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114608
           Summary: [14 Regression] Undefined reference in output asm with
                    -fipa-reference -fipa-reference-addressable
                    -fsection-anchors -gbtf
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: patrick at rivosinc dot com
  Target Milestone: ---

Program:
static short a[7];
void b() { a[6] = 0; }

Compiler flags:
-fipa-reference -fipa-reference-addressable -fsection-anchors -gbtf

Godbolt diff between 13.2 and 14.0:
RISC-V: https://godbolt.org/z/7d1nodoMz
X86: https://godbolt.org/z/YGdej7Y7c

Godbolt showing failure:
RISCV: https://godbolt.org/z/fd3cKP6jM
X86: https://godbolt.org/z/h3WhzK4nG

Found via fuzzer.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug debug/114608] [14 Regression] Undefined reference in output asm with -fipa-reference -fipa-reference-addressable -fsection-anchors -gbtf
  2024-04-05 17:42 [Bug debug/114608] New: [14 Regression] Undefined reference in output asm with -fipa-reference -fipa-reference-addressable -fsection-anchors -gbtf patrick at rivosinc dot com
@ 2024-04-05 17:43 ` patrick at rivosinc dot com
  2024-04-05 17:44 ` patrick at rivosinc dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: patrick at rivosinc dot com @ 2024-04-05 17:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Patrick O'Neill <patrick at rivosinc dot com> ---
Command:
> /scratch/tc-testing/tc-apr-4/build-rv64gcv/bin/riscv64-unknown-linux-gnu-gcc -fipa-reference -fipa-reference-addressable -fsection-anchors -gbtf red.c -o rv64gcv.out
/scratch/tc-testing/tc-apr-4/build-rv64gcv/lib/gcc/riscv64-unknown-linux-gnu/14.0.1/../../../../riscv64-unknown-linux-gnu/bin/ld:
/scratch/tc-testing/tc-apr-4/build-rv64gcv/sysroot/usr/lib64/lp64d/crt1.o: in
function `_start':
(.text+0x22): undefined reference to `main'
/scratch/tc-testing/tc-apr-4/build-rv64gcv/lib/gcc/riscv64-unknown-linux-gnu/14.0.1/../../../../riscv64-unknown-linux-gnu/bin/ld:
/scratch/tmp/ccI7WX4y.o:(.BTF+0x88): undefined reference to `a'
collect2: error: ld returned 1 exit status

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug debug/114608] [14 Regression] Undefined reference in output asm with -fipa-reference -fipa-reference-addressable -fsection-anchors -gbtf
  2024-04-05 17:42 [Bug debug/114608] New: [14 Regression] Undefined reference in output asm with -fipa-reference -fipa-reference-addressable -fsection-anchors -gbtf patrick at rivosinc dot com
  2024-04-05 17:43 ` [Bug debug/114608] " patrick at rivosinc dot com
@ 2024-04-05 17:44 ` patrick at rivosinc dot com
  2024-04-05 17:45 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: patrick at rivosinc dot com @ 2024-04-05 17:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Patrick O'Neill <patrick at rivosinc dot com> ---
(.BTF+0x88): undefined reference to `a'
^ This is the interesting failure line

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug debug/114608] [14 Regression] Undefined reference in output asm with -fipa-reference -fipa-reference-addressable -fsection-anchors -gbtf
  2024-04-05 17:42 [Bug debug/114608] New: [14 Regression] Undefined reference in output asm with -fipa-reference -fipa-reference-addressable -fsection-anchors -gbtf patrick at rivosinc dot com
  2024-04-05 17:43 ` [Bug debug/114608] " patrick at rivosinc dot com
  2024-04-05 17:44 ` patrick at rivosinc dot com
@ 2024-04-05 17:45 ` pinskia at gcc dot gnu.org
  2024-04-09 15:47 ` cvs-commit at gcc dot gnu.org
  2024-04-12 13:35 ` law at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-05 17:45 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0
             Target|riscv*-*-* x86_64-*-*       |
           Keywords|                            |btf-debug

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug debug/114608] [14 Regression] Undefined reference in output asm with -fipa-reference -fipa-reference-addressable -fsection-anchors -gbtf
  2024-04-05 17:42 [Bug debug/114608] New: [14 Regression] Undefined reference in output asm with -fipa-reference -fipa-reference-addressable -fsection-anchors -gbtf patrick at rivosinc dot com
                   ` (2 preceding siblings ...)
  2024-04-05 17:45 ` pinskia at gcc dot gnu.org
@ 2024-04-09 15:47 ` cvs-commit at gcc dot gnu.org
  2024-04-12 13:35 ` law at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-09 15:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Faust <dfaust@gcc.gnu.org>:

https://gcc.gnu.org/g:8075477f81ae8d0abf64b80dfbd179151f91b417

commit r14-9876-g8075477f81ae8d0abf64b80dfbd179151f91b417
Author: David Faust <david.faust@oracle.com>
Date:   Mon Apr 8 11:10:41 2024 -0700

    btf: emit symbol refs in DATASEC entries only for BPF [PR114608]

    The behavior introduced in
      fa60ac54964 btf: Emit labels in DATASEC bts_offset entries.

    is only fully correct when compiling for the BPF target with BPF CO-RE
    enabled.  In other cases, depending on optimizations, it can result in
    an incorrect symbol reference in the entry bts_offset field for a symbol
    which may not be emitted at all, causing link-time undefined symbol
    reference errors like in PR114608.

    The offending bts_offset field of BTF_KIND_DATASEC entries is in reality
    only currently useful to consumers of BTF information for BPF programs
    anyway.  Correct the regression by only emitting symbol references in
    these entries when compiling for the BPF target.  For other targets, the
    behavior returns to that prior to fa60ac54964.

    The underlying cause is related to PR 113566 "btf: incorrect
    BTF_KIND_DATASEC entries for variables which are optimized out." A
    complete fix for 113566 is more involved and unsuitable for stage 4,
    but will be addressed in the near future.

    gcc/
            PR debug/114608
            * btfout.cc (btf_asm_datasec_entry): Only emit a symbol reference
when
            generating BTF for BPF CO-RE target.

    gcc/testsuite/
            PR debug/114608
            * gcc.dg/debug/btf/btf-datasec-1.c: Check bts_offset symbol
references
            only for BPF target.
            * gcc.dg/debug/btf/btf-datasec-2.c: Likewise.
            * gcc.dg/debug/btf/btf-pr106773.c: Likewise.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug debug/114608] [14 Regression] Undefined reference in output asm with -fipa-reference -fipa-reference-addressable -fsection-anchors -gbtf
  2024-04-05 17:42 [Bug debug/114608] New: [14 Regression] Undefined reference in output asm with -fipa-reference -fipa-reference-addressable -fsection-anchors -gbtf patrick at rivosinc dot com
                   ` (3 preceding siblings ...)
  2024-04-09 15:47 ` cvs-commit at gcc dot gnu.org
@ 2024-04-12 13:35 ` law at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: law at gcc dot gnu.org @ 2024-04-12 13:35 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Should be fixed on the trunk.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-12 13:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-05 17:42 [Bug debug/114608] New: [14 Regression] Undefined reference in output asm with -fipa-reference -fipa-reference-addressable -fsection-anchors -gbtf patrick at rivosinc dot com
2024-04-05 17:43 ` [Bug debug/114608] " patrick at rivosinc dot com
2024-04-05 17:44 ` patrick at rivosinc dot com
2024-04-05 17:45 ` pinskia at gcc dot gnu.org
2024-04-09 15:47 ` cvs-commit at gcc dot gnu.org
2024-04-12 13:35 ` law at gcc dot gnu.org

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).