[Lldb-commits] [lldb] r257441 - [LLDB][MIPS] Handle PIC calling convention for MIPS64

Bhushan D. Attarde via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 11 19:48:43 PST 2016


Author: bhushan.attarde
Date: Mon Jan 11 21:48:43 2016
New Revision: 257441

URL: http://llvm.org/viewvc/llvm-project?rev=257441&view=rev
Log:
[LLDB][MIPS] Handle PIC calling convention for MIPS64
    
    SUMMARY:
    This patch sets up register r25 with the address of function to be called in PrepareTrivialCall().
    This is required as per MIPS PIC calling convention.
    
    Reviewers: clayborg
    Subscribers: mohit.bhakkad, sagar, jaydeep, lldb-commits
    Differential Revision: http://reviews.llvm.org/D16046

Modified:
    lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp

Modified: lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp?rev=257441&r1=257440&r2=257441&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp Mon Jan 11 21:48:43 2016
@@ -206,6 +206,7 @@ ABISysV_mips64::PrepareTrivialCall (Thre
     const RegisterInfo *pc_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
     const RegisterInfo *sp_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
     const RegisterInfo *ra_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA);
+    const RegisterInfo *r25_info = reg_ctx->GetRegisterInfoByName("r25", 0);
 
     if (log)
     log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp);
@@ -228,6 +229,13 @@ ABISysV_mips64::PrepareTrivialCall (Thre
     if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_info, func_addr))
         return false;
 
+    if (log)
+        log->Printf("Writing r25: 0x%" PRIx64, (uint64_t)func_addr);
+
+    // All callers of position independent functions must place the address of the called function in t9 (r25)
+    if (!reg_ctx->WriteRegisterFromUnsigned (r25_info, func_addr))
+        return false;
+
     return true;
 }
 




More information about the lldb-commits mailing list