aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/objtool/arch/x86/decode.c
diff options
context:
space:
mode:
authorJulien Thierry <jthierry@redhat.com>2020-09-04 16:30:28 +0100
committerJosh Poimboeuf <jpoimboe@redhat.com>2020-09-10 10:43:13 -0500
commitedea9e6bcbeaa41718b022a8b99ffddef2330bbc (patch)
tree750c5adeb0cf00da380faefea8cc4551bcc202ba /tools/objtool/arch/x86/decode.c
parentobjtool: Make unwind hint definitions available to other architectures (diff)
downloadwireguard-linux-edea9e6bcbeaa41718b022a8b99ffddef2330bbc.tar.xz
wireguard-linux-edea9e6bcbeaa41718b022a8b99ffddef2330bbc.zip
objtool: Decode unwind hint register depending on architecture
The set of registers that can be included in an unwind hint and their encoding will depend on the architecture. Have arch specific code to decode that register. Signed-off-by: Julien Thierry <jthierry@redhat.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Diffstat (limited to 'tools/objtool/arch/x86/decode.c')
-rw-r--r--tools/objtool/arch/x86/decode.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index 1967370440b3..cde9c36e40ae 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -15,6 +15,7 @@
#include "../../elf.h"
#include "../../arch.h"
#include "../../warn.h"
+#include <asm/orc_types.h>
static unsigned char op_to_cfi_reg[][2] = {
{CFI_AX, CFI_R8},
@@ -583,3 +584,39 @@ const char *arch_nop_insn(int len)
return nops[len-1];
}
+
+int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg)
+{
+ struct cfi_reg *cfa = &insn->cfi.cfa;
+
+ switch (sp_reg) {
+ case ORC_REG_UNDEFINED:
+ cfa->base = CFI_UNDEFINED;
+ break;
+ case ORC_REG_SP:
+ cfa->base = CFI_SP;
+ break;
+ case ORC_REG_BP:
+ cfa->base = CFI_BP;
+ break;
+ case ORC_REG_SP_INDIRECT:
+ cfa->base = CFI_SP_INDIRECT;
+ break;
+ case ORC_REG_R10:
+ cfa->base = CFI_R10;
+ break;
+ case ORC_REG_R13:
+ cfa->base = CFI_R13;
+ break;
+ case ORC_REG_DI:
+ cfa->base = CFI_DI;
+ break;
+ case ORC_REG_DX:
+ cfa->base = CFI_DX;
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}