[Bug compile/34551] Summary: compile command: external calls from compiled modules crash on powerpc64le

"cvs-commit at gcc dot gnu.org via Gdb-prs" <[email protected]>
Newsgroups gmane.comp.gdb.bugs.discuss
Message-ID <[email protected]/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=34551

--- Comment #2 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Abhay Kandpal <[email protected]>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a6d0eb39462588ed757cb1fe97749863604588ff

commit a6d0eb39462588ed757cb1fe97749863604588ff
Author: Abhay Kandpal <[email protected]>
Date:   Thu Aug 20 07:03:57 2026 -0500

    PowerPC: fix external calls from modules built by the compile command

    A module built for the compile command is loaded into inferior memory
    without a linker, so it has no PLT.  On ELFv2 the default code model
    still emits a direct bl for a call to another module, leaving r12 unset
    and the caller's TOC pointer unrestored, and the callee then derives a
    wrong r2 from a stale r12.

    gdb.compile/compile-setjmp.exp shows this: the injected code calls
    setjmp, whose global entry point computes r2 from a stale r12, and the
    first TOC-relative load segfaults.

    -mlongcall makes the call indirect, but on its own it reaches the target
    through a PLT entry, giving R_PPC64_PLT16_HA/LO_DS relocations that BFD's
    generic linker rejects.  Adding -mno-pltseq resolves the call against the
    module's own TOC instead, via R_PPC64_TOC16_HA/LO_DS, which GDB already
    handles.  GCC then emits the r2 save and restore around the call itself.

    Tested on powerpc64le-linux; the two compile-setjmp.exp failures now pass
    with no unexpected failures in the full testsuite.

    gdb/
            * ppc-linux-tdep.c (ppc64_gcc_target_options): New function.
            (ppc_linux_init_abi): Set gcc_target_options for ELFv2.

    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34551
    Suggested-by: Ulrich Weigand <[email protected]>

-- 
You are receiving this mail because:
You are on the CC list for the bug.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.