[Lldb-commits] [PATCH] D16046: [LLDB][MIPS] Handle PIC calling convention for MIPS64

Bhushan Attarde via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 11 01:00:39 PST 2016


bhushan created this revision.
bhushan added a reviewer: clayborg.
bhushan added subscribers: lldb-commits, nitesh.jain, mohit.bhakkad, sagar, jaydeep.
bhushan set the repository for this revision to rL LLVM.

The PIC calling convention for MIPS requires that on entry to a function, register r25 (t9) holds the address of the function’s entry point.
This patch sets up register r25 with the address of function to be called in PrepareTrivialCall().

Repository:
  rL LLVM

http://reviews.llvm.org/D16046

Files:
  source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp

Index: source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
===================================================================
--- source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
+++ source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
@@ -206,6 +206,7 @@
     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 @@
     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;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16046.44435.patch
Type: text/x-patch
Size: 1172 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160111/d1f96f29/attachment.bin>


More information about the lldb-commits mailing list