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

abhay at sourceware dot 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

            Bug ID: 34551
           Summary: Summary:  compile command: external calls from
                    compiled modules crash on powerpc64le
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: compile
          Assignee: unassigned at sourceware dot org
          Reporter: abhay at sourceware dot org
  Target Milestone: ---

On powerpc64le-linux, code injected by the "compile" command crashes when
it calls a function in another module.

The module 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 such a
call, which leaves r12 unset and the caller's TOC pointer unrestored, so
the callee derives a wrong r2 from a stale r12 and faults on its first
TOC-relative load.

gdb.compile/compile-setjmp.exp reproduces this:

  FAIL: gdb.compile/compile-setjmp.exp: compile file -r
  FAIL: gdb.compile/compile-setjmp.exp: p done

  Program received signal SIGSEGV, Segmentation fault.
  0x00007ffff7a47d64 in __sigsetjmp@@GLIBC_2.17 () from
    /lib64/glibc-hwcaps/power10/libc.so.6

At the fault, r12 still held the address of the injected _gdb_expr rather
than that of the callee, and r2 pointed past the end of libc.

This affects any external call from a compiled module; compile-setjmp is
simply the only test in gdb.compile that makes one.

Fix posted to gdb-patches: add -mlongcall -mno-pltseq to the PowerPC
compile options so GCC resolves the call against the module's own TOC.
<URL to the thread>

ELFv1 (powerpc64-linux) fails too, but differently — the symbol resolves
to a function descriptor and the branch lands in .opd.  There are also
other unrelated failures in gdb.compile there.  Not covered by this
report.

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