This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tdep/22576] ppc64: gdbarch_skip_trampoline_code uses wrong r2


https://sourceware.org/bugzilla/show_bug.cgi?id=22576

--- Comment #6 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit db9077b7275e86637218a7a7d165cb85a4de116f
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Dec 11 17:31:11 2017 +1030

    PR22576, ppc64_skip_trampoline_code uses wrong r2 for EXEC_REVERSE

    The TOC pointer register, r2, on powerpc64 is generally not mentioned
    in debug info.  It is saved and restored by call linkage code, and
    set to the callee value either by call stub code (ELFv1) or in the
    callee global entry point code (ELFv2).  A call stub uses the caller
    TOC pointer to access the PLT.  So for gdb to read the correct PLT
    entry in order to determine the destination of the trampoline, gdb
    needs to know the caller r2.  When skipping over trampolines in the
    normal forward direction, the caller r2 is simply the current value of
    r2 (at the start of the trampoline).  However, when reversing over
    trampolines the current value of r2 is that for the callee.  Using
    that value results in wild reads of memory rather than the correct PLT
    entry.

    This patch corrects the value of r2 by using the value saved on the
    stack for reverse execution.  Note that in reverse execution mode it
    isn't really necessary for skip_trampoline_code to return the actual
    destination, so we're doing a little more work than needed here.  Any
    non-zero return value would do (and it would be nicer if the interface
    was changed to return the start of the stub).

        PR tdep/22576
        * ppc64-tdep.c (ppc64_plt_entry_point): Rewrite to take TOC-relative
        PLT offset, and retrieve r2 from stack when executing in reverse.
        (ppc64_standard_linkage1_target): Drop pc param.  Calculate offset
        rather than PLT address.
        (ppc64_standard_linkage2_target): Likewise.
        (ppc64_standard_linkage3_target): Likewise.
        (ppc64_standard_linkage4_target): Likewise.
        (ppc64_skip_trampoline_code_1): Adjust to suit.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]