[Bug target/107909] [powerpc64le, debug] Incorrect call site location due to nop after call insn

bernard.ladenthin at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Sep 6 23:00:57 GMT 2026


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

Bernard Ladenthin <bernard.ladenthin at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bernard.ladenthin at gmail dot com

--- Comment #4 from Bernard Ladenthin <bernard.ladenthin at gmail dot com> ---
Still present on trunk (17.0.0, 2026-09-06), and measured on three ABIs with
two cc1 binaries built from one tree, nothing else differing:

  powerpc64le-linux, ELFv2     16 call sites corrected, 0 broken
  powerpc-ibm-aix7.3.1.0       12 corrected, 0 broken (32-bit, XCOFF)
  powerpc64-linux, ELFv1       12 corrected, 0 broken

Direct and indirect calls are wrong by 4; calls to a symbol in the same file,
sibcalls and pc-relative calls are already correct, and the 32-bit V4 ABI is
not affected at all.

Confirmed on the machine rather than only from the DWARF.  Stopping in the
callee on AIX:

  main+16   0x100004b0   bl      0x10000500 <callee>
  main+20   0x100004b4   nop

  (gdb) p/x $lr
  $1 = 0x100004b4

The link register holds the address of the nop.  GCC's label sits at
0x100004b8.

Why this has looked dormant since 2022: gdb gained a PowerPC workaround in
14.1 -- ppc64_update_call_site_pc in gdb/rs6000-tdep.c retries the lookup at
pc + 4 after an exact-match miss -- so on 64-bit the symptom disappears with
any current gdb.  That workaround is registered only for wordsize == 8, so
32-bit gets none.  On AIX 7.3 with gdb 17.2:

  without the fix:
    Breakpoint 1, callee (i=126) at cee.c:6
    DW_OP_entry_value resolving cannot find DW_TAG_call_site 0x100004b4 in main

  with the fix:
    Breakpoint 1, callee (i=126, i@entry=42) at cee.c:6
    $1 = 42

Because the workaround is a retry after a miss, correcting the compiler cannot
regress gdb either: the first exact lookup starts succeeding and the retry
never fires.  gdb 13 and earlier, which have no workaround, are fixed too.

A patch is posted to gcc-patches:

  [PATCH v4] rs6000: correct the call-site return PC past the TOC restore slot
  Message-ID: <20260906225455.15157-1-bernard.ladenthin@gmail.com>

It implements TARGET_CALL_OFFSET_RETURN_LABEL, the hook Alexandre Oliva added
in 3472b5749df5 (2024-06-07) for exactly this purpose and which no target has
implemented since.  It is v4 of his series; he is CC'd and credited.

Worth noting for anyone searching later: none of the earlier postings of that
series (2023-03, 2023-03 v2, 2024-05 v3) ever carried this PR number, which is
why the bug shows no patch link despite three submissions.


More information about the Gcc-bugs mailing list