[Lldb-commits] [PATCH] D15273: [LLDB][MIPS] Handle PIC calling convention for MIPS32
Bhushan Attarde via lldb-commits
lldb-commits at lists.llvm.org
Mon Dec 7 01:23:42 PST 2015
bhushan created this revision.
bhushan added a reviewer: clayborg.
bhushan added subscribers: lldb-commits, nitesh.jain, sagar, mohit.bhakkad, jaydeep.
bhushan set the repository for this revision to rL LLVM.
This patch includes:
1. PrepareTrivialCall() to setup register r25 with the address of function to be called.
This is needed because the PIC calling convention for MIPS requires that on entry to
a function, the r25 (t9) register holds the address of the function’s entry point.
2. RegisterIsCalleeSaved() to use name of a register instead of its byte_offset.
Repository:
rL LLVM
http://reviews.llvm.org/D15273
Files:
source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
Index: source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
===================================================================
--- source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
+++ source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
@@ -241,6 +241,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);
@@ -262,7 +263,14 @@
// Set pc to the address of the called function.
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;
}
@@ -546,13 +554,36 @@
{
// Preserved registers are :
// r16-r23, r28, r29, r30, r31
+ const char *name = reg_info->name;
- int reg = ((reg_info->byte_offset) / 4);
-
- bool save = (reg >= 16) && (reg <= 23);
- save |= (reg >= 28) && (reg <= 31);
+ if (name[0] == 'r')
+ {
+ switch (name[1])
+ {
+ case '1':
+ if (name[2] == '6' || name[2] == '7' || name[2] == '8' || name[2] == '9') // r16-r19
+ return name[3] == '\0';
+ break;
+ case '2':
+ if (name[2] == '0' || name[2] == '1' || name[2] == '2' || name[2] == '3' // r20-r23
+ || name[2] == '8' || name[2] == '9') // r28 and r29
+ return name[3] == '\0';
+ break;
+ case '3':
+ if (name[2] == '0' || name[2] == '1') // r30 and r31
+ return name[3] == '\0';
+ break;
+ }
- return save;
+ if (name[0] == 'g' && name[1] == 'p' && name[2] == '\0') // gp (r28)
+ return true;
+ if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp (r29)
+ return true;
+ if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp (r30)
+ return true;
+ if (name[0] == 'r' && name[1] == 'a' && name[2] == '\0') // ra (r31)
+ return true;
+ }
}
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15273.42031.patch
Type: text/x-patch
Size: 2856 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151207/98ffc815/attachment-0001.bin>
More information about the lldb-commits
mailing list