Merge pull request #9053 from kit-ty-kate/freebsd-arm64

Add support for FreeBSD/arm64
This commit is contained in:
LC 2020-08-28 18:42:01 -04:00 committed by GitHub
commit 75b4f70e5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -9,7 +9,9 @@
#include <thread>
#ifndef _WIN32
#ifndef __FreeBSD__
#include <asm/hwcap.h>
#endif
#include <sys/auxv.h>
#include <unistd.h>
#endif
@ -87,7 +89,12 @@ void CPUInfo::Detect()
num_cores = sysconf(_SC_NPROCESSORS_CONF);
strncpy(cpu_string, GetCPUString().c_str(), sizeof(cpu_string));
#ifdef __FreeBSD__
u_long hwcaps = 0;
elf_aux_info(AT_HWCAP, &hwcaps, sizeof(u_long));
#else
unsigned long hwcaps = getauxval(AT_HWCAP);
#endif
bFP = hwcaps & HWCAP_FP;
bASIMD = hwcaps & HWCAP_ASIMD;
bAES = hwcaps & HWCAP_AES;

View File

@ -35,6 +35,7 @@ typedef CONTEXT SContext;
#define CTX_RIP Rip
#elif _M_ARM64
#define CTX_REG(x) X[x]
#define CTX_LR X[30]
#define CTX_SP Sp
#define CTX_PC Pc
#else
@ -115,6 +116,7 @@ typedef mcontext_t SContext;
#define CTX_RIP gregs[REG_RIP]
#elif _M_ARM_64
#define CTX_REG(x) regs[x]
#define CTX_LR regs[30]
#define CTX_SP sp
#define CTX_PC pc
#else
@ -189,6 +191,11 @@ typedef mcontext_t SContext;
#define CTX_R14 mc_r14
#define CTX_R15 mc_r15
#define CTX_RIP mc_rip
#elif _M_ARM_64
#define CTX_REG(x) mc_gpregs.gp_x[x]
#define CTX_LR mc_gpregs.gp_lr
#define CTX_SP mc_gpregs.gp_sp
#define CTX_PC mc_gpregs.gp_elr
#else
#error No context definition for architecture
#endif

View File

@ -27,7 +27,7 @@ void JitArm64::DoBacktrace(uintptr_t access_address, SContext* ctx)
ERROR_LOG(DYNA_REC, "R%d: 0x%016llx\tR%d: 0x%016llx", i, ctx->CTX_REG(i), i + 1,
ctx->CTX_REG(i + 1));
ERROR_LOG(DYNA_REC, "R30: 0x%016llx\tSP: 0x%016llx", ctx->CTX_REG(30), ctx->CTX_SP);
ERROR_LOG(DYNA_REC, "R30: 0x%016llx\tSP: 0x%016llx", ctx->CTX_LR, ctx->CTX_SP);
ERROR_LOG(DYNA_REC, "Access Address: 0x%016lx", access_address);
ERROR_LOG(DYNA_REC, "PC: 0x%016llx", ctx->CTX_PC);