Re: [PATCH v2] PowerPC: fix external calls from modules built by the compile command

Ulrich Weigand <[email protected]>
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
Abhay Kandpal <[email protected]> wrote:

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

This is OK.

Thanks,
Ulrich
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.