From ffdb81d41ad4ff487f87f1bc2ece305246505e5b Mon Sep 17 00:00:00 2001 From: abcSup Date: Mon, 10 Feb 2020 23:21:01 -0800 Subject: [PATCH] Refactor and Add Swift calling conventions to sdb --- libr/anal/d/cc-arm-32.sdb.txt | 10 ++++++++++ libr/anal/d/cc-arm-64.sdb.txt | 14 ++++++++++++++ libr/anal/d/cc-x86-64.sdb.txt | 16 ++++++++++++++++ libr/anal/var.c | 2 +- 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/libr/anal/d/cc-arm-32.sdb.txt b/libr/anal/d/cc-arm-32.sdb.txt index 7e76b3bd85..0f61af4fb8 100644 --- a/libr/anal/d/cc-arm-32.sdb.txt +++ b/libr/anal/d/cc-arm-32.sdb.txt @@ -12,3 +12,13 @@ cc.arm16.arg2=r2 cc.arm16.arg3=r3 cc.arm16.argn=stack cc.arm16.ret=r0 + +swift=cc +cc.swift.arg0=r0 +cc.swift.arg1=r1 +cc.swift.arg2=r2 +cc.swift.arg3=r3 +cc.swift.argn=stack +cc.swift.self=r10 +cc.swift.self=r8 +cc.swift.ret=r0 diff --git a/libr/anal/d/cc-arm-64.sdb.txt b/libr/anal/d/cc-arm-64.sdb.txt index 37adc5fd5b..3cc74135e2 100644 --- a/libr/anal/d/cc-arm-64.sdb.txt +++ b/libr/anal/d/cc-arm-64.sdb.txt @@ -11,3 +11,17 @@ cc.arm64.arg6=x6 cc.arm64.arg7=x7 cc.arm64.argn=stack cc.arm64.ret=x0 + +swift=cc +cc.swift.arg0=x0 +cc.swift.arg1=x1 +cc.swift.arg2=x2 +cc.swift.arg3=x3 +cc.swift.arg4=x4 +cc.swift.arg5=x5 +cc.swift.arg6=x6 +cc.swift.arg7=x7 +cc.swift.argn=stack +cc.swift.self=x20 +cc.swift.error=x21 +cc.swift.ret=x0 diff --git a/libr/anal/d/cc-x86-64.sdb.txt b/libr/anal/d/cc-x86-64.sdb.txt index 791b6cb54b..02539b8c57 100644 --- a/libr/anal/d/cc-x86-64.sdb.txt +++ b/libr/anal/d/cc-x86-64.sdb.txt @@ -21,3 +21,19 @@ cc.amd64.arg8=xmm2 cc.amd64.arg9=xmm3 cc.amd64.arg10=xmm4 cc.amd64.ret=rax + +swift=cc +cc.swift.arg0=rdi +cc.swift.arg1=rsi +cc.swift.arg2=rdx +cc.swift.arg3=rcx +cc.swift.arg4=r8 +cc.swift.arg5=r9 +cc.swift.arg6=xmm0 +cc.swift.arg7=xmm1 +cc.swift.arg8=xmm2 +cc.swift.arg9=xmm3 +cc.swift.arg10=xmm4 +cc.swift.self=r13 +cc.swift.error=r12 +cc.swift.ret=rax diff --git a/libr/anal/var.c b/libr/anal/var.c index 5c36158282..c6bb9d73d6 100644 --- a/libr/anal/var.c +++ b/libr/anal/var.c @@ -137,7 +137,7 @@ R_API bool r_anal_var_add(RAnal *a, ut64 addr, int scope, int delta, char kind, eprintf ("Invalid var kind '%c'\n", kind); return false; } - if (kind == 'r') { + if (kind == R_ANAL_VAR_KIND_REG) { reg = r_reg_index_get (a->reg, R_ABS (delta)); if (!reg) { eprintf ("Register wasn't found at the given delta\n");