mirror of
https://github.com/ptitSeb/box64.git
synced 2025-05-09 00:21:32 +08:00
[WOW64] More tweaks towards PE build (#2519)
This commit is contained in:
parent
f9f082ee53
commit
0bb41a73c2
@ -230,7 +230,7 @@ elseif(ARM64)
|
||||
#add_definitions(-pipe -march=native)
|
||||
endif()
|
||||
if(ARM_DYNAREC)
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "9.0")
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "9.0")
|
||||
set(ASMFLAGS -pipe -march=armv8.2-a+crc+simd+crypto)
|
||||
else()
|
||||
#putting a random cpu that have 8.2 architecture so assembly can be build. the use of the feature are conditionnal anyway
|
||||
@ -350,6 +350,7 @@ set(OS_LINUX_SRC
|
||||
"${BOX64_ROOT}/src/os/backtrace.c"
|
||||
"${BOX64_ROOT}/src/os/emit_signals_linux.c"
|
||||
"${BOX64_ROOT}/src/os/os_linux.c"
|
||||
"${BOX64_ROOT}/src/os/symbolfuncs_linux.c"
|
||||
)
|
||||
|
||||
set(ELFLOADER_SRC
|
||||
@ -868,7 +869,7 @@ if(BOX32)
|
||||
set(WRAPPEDS32_HEAD ${WRAPPEDS32_HEAD} ${B})
|
||||
set_source_files_properties(${A} PROPERTIES OBJECT_DEPENDS ${B})
|
||||
endforeach()
|
||||
|
||||
|
||||
set(WRAPPER32 "${BOX64_ROOT}/src/wrapped32/generated/wrapper32.c" "${BOX64_ROOT}/src/wrapped32/generated/wrapper32.h")
|
||||
|
||||
if(NOT CI)
|
||||
@ -1814,13 +1815,13 @@ if(BOX32)
|
||||
-P ${CMAKE_SOURCE_DIR}/runTest.cmake)
|
||||
endforeach()
|
||||
|
||||
#add_test(NAME sse_optimized_32bits COMMAND ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX64}
|
||||
# -D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests32/test17_o2 -D TEST_OUTPUT=tmpfile32_17_o2.txt
|
||||
#add_test(NAME sse_optimized_32bits COMMAND ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX64}
|
||||
# -D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests32/test17_o2 -D TEST_OUTPUT=tmpfile32_17_o2.txt
|
||||
# -D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests32/ref17_o2.txt
|
||||
# -P ${CMAKE_SOURCE_DIR}/runTest.cmake )
|
||||
|
||||
#set_tests_properties(sse_optimized_32bits PROPERTIES ENVIRONMENT "BOX64_DYNAREC_FASTNAN=0;BOX64_DYNAREC_FASTROUND=0")
|
||||
|
||||
#set_tests_properties(sse_optimized_32bits PROPERTIES ENVIRONMENT "BOX64_DYNAREC_FASTNAN=0;BOX64_DYNAREC_FASTROUND=0")
|
||||
|
||||
add_test(bswap_32bits ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX64}
|
||||
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests32/test23 -D TEST_OUTPUT=tmpfile32_23.txt
|
||||
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests32/ref23.txt
|
||||
|
@ -86,39 +86,6 @@ void free_tlsdatasize(void* p)
|
||||
void x64Syscall(x64emu_t *emu);
|
||||
void x86Syscall(x64emu_t *emu);
|
||||
|
||||
int unlockMutex()
|
||||
{
|
||||
int ret = unlockCustommemMutex();
|
||||
int i;
|
||||
#ifdef USE_CUSTOM_MUTEX
|
||||
uint32_t tid = (uint32_t)GetTID();
|
||||
#define GO(A, B) \
|
||||
i = (native_lock_storeifref2_d(&A, 0, tid)==tid); \
|
||||
if(i) { \
|
||||
ret|=(1<<B); \
|
||||
}
|
||||
#else
|
||||
#define GO(A, B) \
|
||||
i = checkUnlockMutex(&A); \
|
||||
if(i) { \
|
||||
ret|=(1<<B); \
|
||||
}
|
||||
#endif
|
||||
|
||||
GO(my_context->mutex_trace, 7)
|
||||
#ifdef DYNAREC
|
||||
GO(my_context->mutex_dyndump, 8)
|
||||
#else
|
||||
GO(my_context->mutex_lock, 8)
|
||||
#endif
|
||||
GO(my_context->mutex_tls, 9)
|
||||
GO(my_context->mutex_thread, 10)
|
||||
GO(my_context->mutex_bridge, 11)
|
||||
#undef GO
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void relockMutex(int locks)
|
||||
{
|
||||
relockCustommemMutex(locks);
|
||||
|
@ -45,15 +45,15 @@ static uintptr_t box64_jmptbldefault0[1<<JMPTABL_SHIFT0];
|
||||
KHASH_SET_INIT_INT64(lockaddress)
|
||||
static kh_lockaddress_t *lockaddress = NULL;
|
||||
#ifdef USE_CUSTOM_MUTEX
|
||||
static uint32_t mutex_prot;
|
||||
static uint32_t mutex_blocks;
|
||||
uint32_t mutex_prot;
|
||||
uint32_t mutex_blocks;
|
||||
#else
|
||||
static pthread_mutex_t mutex_prot;
|
||||
static pthread_mutex_t mutex_blocks;
|
||||
pthread_mutex_t mutex_prot;
|
||||
pthread_mutex_t mutex_blocks;
|
||||
#endif
|
||||
#else
|
||||
static pthread_mutex_t mutex_prot;
|
||||
static pthread_mutex_t mutex_blocks;
|
||||
pthread_mutex_t mutex_prot;
|
||||
pthread_mutex_t mutex_blocks;
|
||||
#endif
|
||||
//#define TRACE_MEMSTAT
|
||||
rbtree_t* memprot = NULL;
|
||||
@ -1859,6 +1859,7 @@ uintptr_t old_brk = 0;
|
||||
uintptr_t* cur_brk = NULL;
|
||||
void loadProtectionFromMap()
|
||||
{
|
||||
#ifndef _WIN32 // TODO: Should this be implemented on Win32?
|
||||
if(box64_mapclean)
|
||||
return;
|
||||
char buf[500];
|
||||
@ -1893,6 +1894,7 @@ void loadProtectionFromMap()
|
||||
}
|
||||
fclose(f);
|
||||
box64_mapclean = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void freeProtection(uintptr_t addr, size_t size)
|
||||
@ -2058,30 +2060,6 @@ int isBlockFree(void* hint, size_t size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int unlockCustommemMutex()
|
||||
{
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
#ifdef USE_CUSTOM_MUTEX
|
||||
uint32_t tid = (uint32_t)GetTID();
|
||||
#define GO(A, B) \
|
||||
i = (native_lock_storeifref2_d(&A, 0, tid)==tid); \
|
||||
if(i) { \
|
||||
ret|=(1<<B); \
|
||||
}
|
||||
#else
|
||||
#define GO(A, B) \
|
||||
i = checkUnlockMutex(&A); \
|
||||
if(i) { \
|
||||
ret|=(1<<B); \
|
||||
}
|
||||
#endif
|
||||
GO(mutex_blocks, 0)
|
||||
GO(mutex_prot, 1) // See also signals.c
|
||||
#undef GO
|
||||
return ret;
|
||||
}
|
||||
|
||||
void relockCustommemMutex(int locks)
|
||||
{
|
||||
#define GO(A, B) \
|
||||
|
@ -50,7 +50,7 @@
|
||||
PKip(0), PKip(1), PKip(2), PKip(3), PKip(4), PKip(5), PKip(6), PKip(7), PKip(8), PKip(9), \
|
||||
PKip(10), PKip(11), PKip(12), PKip(13), PKip(14)); \
|
||||
} \
|
||||
printFunctionAddr(ip, " => "); \
|
||||
PrintFunctionAddr(ip, " => "); \
|
||||
dynarec_log_prefix(0, LOG_NONE, "\n"); \
|
||||
}
|
||||
|
||||
|
@ -46,11 +46,11 @@ void printf_x64_instruction(dynarec_native_t* dyn, zydis_dec_t* dec, instruction
|
||||
// print Call function name if possible
|
||||
if(ip[0]==0xE8 || ip[0]==0xE9) { // Call / Jmp
|
||||
uintptr_t nextaddr = (uintptr_t)ip + 5 + *((int32_t*)(ip+1));
|
||||
printFunctionAddr(nextaddr, "=> ");
|
||||
PrintFunctionAddr(nextaddr, "=> ");
|
||||
} else if(ip[0]==0xFF) {
|
||||
if(ip[1]==0x25) {
|
||||
uintptr_t nextaddr = (uintptr_t)ip + 6 + *((int32_t*)(ip+2));
|
||||
printFunctionAddr(nextaddr, "=> ");
|
||||
PrintFunctionAddr(nextaddr, "=> ");
|
||||
}
|
||||
}
|
||||
// end of line and colors
|
||||
@ -235,7 +235,7 @@ int next_instruction(dynarec_native_t *dyn, uintptr_t addr)
|
||||
case 0xF3:
|
||||
nextop = PK(1);
|
||||
switch(nextop) {
|
||||
case 0x90:
|
||||
case 0x90:
|
||||
return 2;
|
||||
default: break;
|
||||
}
|
||||
@ -279,7 +279,7 @@ void addInst(instsize_t* insts, size_t* size, int x64_size, int native_size)
|
||||
toadd = 1 + native_size/15;
|
||||
while(toadd) {
|
||||
if(x64_size>15)
|
||||
insts[*size].x64 = 15;
|
||||
insts[*size].x64 = 15;
|
||||
else
|
||||
insts[*size].x64 = x64_size;
|
||||
x64_size -= insts[*size].x64;
|
||||
@ -764,7 +764,7 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr, int alternate, int is32bit
|
||||
CancelBlock64(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// pass 2, instruction size
|
||||
helper.callrets = static_callrets;
|
||||
native_pass2(&helper, addr, alternate, is32bits, inst_max);
|
||||
@ -824,7 +824,7 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr, int alternate, int is32bit
|
||||
// pass 3, emit (log emit native opcode)
|
||||
if(BOX64DRENV(dynarec_dump)) {
|
||||
dynarec_log(LOG_NONE, "%s%04d|Emitting %zu bytes for %u %s bytes (native=%zu, table64=%zu, instsize=%zu, arch=%zu, callrets=%zu)", (BOX64DRENV(dynarec_dump)>1)?"\e[01;36m":"", GetTID(), helper.native_size, helper.isize, is32bits?"x86":"x64", native_size, helper.table64size*sizeof(uint64_t), insts_rsize, arch_size, callret_size);
|
||||
printFunctionAddr(helper.start, " => ");
|
||||
PrintFunctionAddr(helper.start, " => ");
|
||||
dynarec_log(LOG_NONE, "%s\n", (BOX64DRENV(dynarec_dump)>1)?"\e[m":"");
|
||||
}
|
||||
if (BOX64ENV(dynarec_gdbjit) && (!BOX64ENV(dynarec_gdbjit_end) || (addr >= BOX64ENV(dynarec_gdbjit_start) && addr < BOX64ENV(dynarec_gdbjit_end)))) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "emu/x64run_private.h"
|
||||
#include "emu/x87emu_private.h"
|
||||
#include "x64trace.h"
|
||||
#include "signals.h"
|
||||
#include "mysignal.h"
|
||||
#include "emit_signals.h"
|
||||
#include "dynarec_native.h"
|
||||
#include "custommem.h"
|
||||
@ -629,7 +629,7 @@ int is_avx_zero_unset(dynarec_native_t* dyn, int ninst, int reg)
|
||||
{
|
||||
if((dyn->ymm_zero>>reg)&1) {
|
||||
dyn->ymm_zero &= ~(1<<reg);
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -651,7 +651,7 @@ void propagate_nodf(dynarec_native_t* dyn, int ninst)
|
||||
if(dyn->insts[ninst].x64.gen_flags || dyn->insts[ninst].x64.use_flags)
|
||||
return; // flags are use, so maybe it's needed
|
||||
dyn->insts[ninst].df_notneeded = 1;
|
||||
--ninst;
|
||||
--ninst;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,6 @@
|
||||
PKip(0), PKip(1), PKip(2), PKip(3), PKip(4), PKip(5), PKip(6), PKip(7), PKip(8), PKip(9), \
|
||||
PKip(10), PKip(11), PKip(12), PKip(13), PKip(14)); \
|
||||
} \
|
||||
printFunctionAddr(ip, " => "); \
|
||||
PrintFunctionAddr(ip, " => "); \
|
||||
dynarec_log_prefix(0, LOG_NONE, "\n"); \
|
||||
}
|
||||
|
@ -85,7 +85,7 @@
|
||||
PKip(0), PKip(1), PKip(2), PKip(3), PKip(4), PKip(5), PKip(6), PKip(7), PKip(8), PKip(9), \
|
||||
PKip(10), PKip(11), PKip(12), PKip(13), PKip(14)); \
|
||||
} \
|
||||
printFunctionAddr(ip, " => "); \
|
||||
PrintFunctionAddr(ip, " => "); \
|
||||
dynarec_log_prefix(0, LOG_NONE, "\n"); \
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@
|
||||
PKip(0), PKip(1), PKip(2), PKip(3), PKip(4), PKip(5), PKip(6), PKip(7), PKip(8), PKip(9), \
|
||||
PKip(10), PKip(11), PKip(12), PKip(13), PKip(14)); \
|
||||
} \
|
||||
printFunctionAddr(ip, " => "); \
|
||||
PrintFunctionAddr(ip, " => "); \
|
||||
dynarec_log_prefix(0, LOG_NONE, "\n"); \
|
||||
} \
|
||||
return 0
|
||||
|
@ -414,7 +414,7 @@ void UpdateFlags(x64emu_t *emu)
|
||||
CLEAR_FLAG(F_OF);
|
||||
} else {
|
||||
SET_FLAG(F_CF);
|
||||
SET_FLAG(F_OF);
|
||||
SET_FLAG(F_OF);
|
||||
}
|
||||
if (!BOX64ENV(cputype)) {
|
||||
CONDITIONAL_SET_FLAG((emu->res.u32>>31)&1, F_SF);
|
||||
@ -1208,22 +1208,6 @@ const char* getAddrFunctionName(uintptr_t addr)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int printFunctionAddr(uintptr_t nextaddr, const char* text)
|
||||
{
|
||||
uint64_t sz = 0;
|
||||
uintptr_t start = 0;
|
||||
const char* symbname = FindNearestSymbolName(FindElfAddress(my_context, nextaddr), (void*)nextaddr, &start, &sz);
|
||||
if(!sz) sz=0x100; // arbitrary value...
|
||||
if(symbname && nextaddr>=start && (nextaddr<(start+sz) || !sz)) {
|
||||
if(nextaddr==start)
|
||||
printf_log_prefix(0, LOG_NONE, " (%s%s:%s)", text, ElfName(FindElfAddress(my_context, nextaddr)), symbname);
|
||||
else
|
||||
printf_log_prefix(0, LOG_NONE, " (%s%s:%s + 0x%lx)", text, ElfName(FindElfAddress(my_context, nextaddr)), symbname, nextaddr - start);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_TRACE
|
||||
#define PK(a) (*(uint8_t*)(ip+a))
|
||||
#define PKS(a) (*(int8_t*)(ip+a))
|
||||
@ -1235,14 +1219,14 @@ void PrintTrace(x64emu_t* emu, uintptr_t ip, int dynarec)
|
||||
int is32bits = (emu->segs[_CS]==0x23);
|
||||
if(BOX64ENV(start_cnt)) SET_BOX64ENV(start_cnt, BOX64ENV(start_cnt)-1);
|
||||
if(!BOX64ENV(start_cnt) && my_context->dec && (
|
||||
(trace_end == 0)
|
||||
(trace_end == 0)
|
||||
|| ((ip >= trace_start) && (ip < trace_end))) ) {
|
||||
int tid = syscall(SYS_gettid);
|
||||
mutex_lock(&my_context->mutex_trace);
|
||||
#ifdef DYNAREC
|
||||
if((my_context->trace_tid != tid) || (my_context->trace_dynarec!=dynarec)) {
|
||||
printf_log(LOG_NONE, "Thread %04d| (%s) ", tid, dynarec?"dyn":"int");
|
||||
printFunctionAddr(ip, "here: ");
|
||||
PrintFunctionAddr(ip, "here: ");
|
||||
printf_log_prefix(0, LOG_NONE, "\n");
|
||||
my_context->trace_tid = tid;
|
||||
my_context->trace_dynarec = dynarec;
|
||||
@ -1279,81 +1263,81 @@ void PrintTrace(x64emu_t* emu, uintptr_t ip, int dynarec)
|
||||
if(peek==0xC3 || peek==0xC2 || (peek==0xF3 && PK(1)==0xC3)) {
|
||||
if(is32bits) {
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", (void*)(uintptr_t)*(uint32_t*)(R_RSP));
|
||||
printFunctionAddr(*(uint32_t*)(R_RSP), "=> ");
|
||||
PrintFunctionAddr(*(uint32_t*)(R_RSP), "=> ");
|
||||
} else {
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", *(void**)(R_RSP));
|
||||
printFunctionAddr(*(uintptr_t*)(R_RSP), "=> ");
|
||||
PrintFunctionAddr(*(uintptr_t*)(R_RSP), "=> ");
|
||||
}
|
||||
} else if(peek==0x57 && rex.b) {
|
||||
printf_log_prefix(0, LOG_NONE, " => STACK_TOP: %p", *(void**)(R_RSP));
|
||||
printFunctionAddr(ip, "here: ");
|
||||
PrintFunctionAddr(ip, "here: ");
|
||||
} else if((peek==0x55 /*|| peek==0x53*/) && !is32bits) {
|
||||
if(!printFunctionAddr(*(uintptr_t*)(R_RSP), " STACK_TOP: "))
|
||||
if(!PrintFunctionAddr(*(uintptr_t*)(R_RSP), " STACK_TOP: "))
|
||||
printf_log_prefix(0, LOG_NONE, " STACK_TOP: %p ", (void*)*(uintptr_t*)(R_RSP));
|
||||
} else if((peek==0x55 || peek==0x56 || peek==0x53 || peek==0x57) && is32bits) {
|
||||
if(!printFunctionAddr(*(uint32_t*)(R_RSP), " STACK_TOP: "))
|
||||
if(!PrintFunctionAddr(*(uint32_t*)(R_RSP), " STACK_TOP: "))
|
||||
printf_log_prefix(0, LOG_NONE, " STACK_TOP: %p ", (void*)(uintptr_t)*(uint32_t*)(R_RSP));
|
||||
} else if(peek==0xF3 && PK(1)==0x0F && PK(2)==0x1E && PK(3)==0xFA && !is32bits) {
|
||||
uintptr_t nextaddr = *(uintptr_t*)(R_RSP);
|
||||
if(!printFunctionAddr(nextaddr, "=> "))
|
||||
if(!PrintFunctionAddr(nextaddr, "=> "))
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", (void*)nextaddr);
|
||||
} else if((peek==0x81 || peek==0x83) && PK(1)==0xEC && is32bits) {
|
||||
uintptr_t nextaddr = *(ptr_t*)from_ptrv(R_ESP);
|
||||
if(!printFunctionAddr(nextaddr, "STACK_TOP: "))
|
||||
if(!PrintFunctionAddr(nextaddr, "STACK_TOP: "))
|
||||
printf_log_prefix(0, LOG_NONE, " STACK_TOP: %p", (void*)nextaddr);
|
||||
} else if(peek==0xE8 || peek==0xE9) { // Call & Jmp
|
||||
uintptr_t nextaddr = ip + 5 + PK32(1);
|
||||
printFunctionAddr(nextaddr, "=> ");
|
||||
PrintFunctionAddr(nextaddr, "=> ");
|
||||
} else if(peek==0xFF) {
|
||||
if(PK(1)==0x25) {
|
||||
uintptr_t nextaddr = is32bits?(*(uint32_t*)(uintptr_t)PK32(2)):(*(uintptr_t*)(ip + 6 + PK32(2)));
|
||||
if(!printFunctionAddr(nextaddr, "=> "))
|
||||
if(!PrintFunctionAddr(nextaddr, "=> "))
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", (void*)nextaddr);
|
||||
} else if(PK(1)==0x15) {
|
||||
uintptr_t nextaddr = is32bits?(*(uint32_t*)(uintptr_t)PK32(2)):(*(uintptr_t*)(ip + 6 + PK32(2)));
|
||||
if(!printFunctionAddr(nextaddr, "=> "))
|
||||
if(!PrintFunctionAddr(nextaddr, "=> "))
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", (void*)nextaddr);
|
||||
} else if(PK(1)==0x60) {
|
||||
uintptr_t nextaddr = *(uintptr_t*)(R_RAX+PK(2));
|
||||
if(!printFunctionAddr(nextaddr, "=> "))
|
||||
if(!PrintFunctionAddr(nextaddr, "=> "))
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", (void*)nextaddr);
|
||||
} else if(PK(1)==0xE0) {
|
||||
uintptr_t nextaddr = R_RAX;
|
||||
if(is32bits) nextaddr &= 0xffffffff;
|
||||
if(!printFunctionAddr(nextaddr, "=> "))
|
||||
if(!PrintFunctionAddr(nextaddr, "=> "))
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", (void*)nextaddr);
|
||||
} else if((PK(1)==0x14) && (PK(2)==0x25)) {
|
||||
uintptr_t nextaddr = is32bits?(*(uint32_t*)(uintptr_t)PK32(3)):(*(uintptr_t*)(uintptr_t)PK32(3));
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", (void*)nextaddr);
|
||||
printFunctionAddr(nextaddr, "=> ");
|
||||
PrintFunctionAddr(nextaddr, "=> ");
|
||||
} else if((PK(1)==0x14) && (PK(2)==0xC2) && rex.rex==0x41) {
|
||||
uintptr_t nextaddr = *(uintptr_t*)(R_R10 + R_RAX*8);
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", (void*)nextaddr);
|
||||
printFunctionAddr(nextaddr, "=> ");
|
||||
PrintFunctionAddr(nextaddr, "=> ");
|
||||
} else if(PK(1)==0xE1 && rex.rex==0x41) {
|
||||
uintptr_t nextaddr = R_R9;
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", (void*)nextaddr);
|
||||
printFunctionAddr(nextaddr, "=> ");
|
||||
PrintFunctionAddr(nextaddr, "=> ");
|
||||
} else if(is32bits && PK(1)==0xA3) {
|
||||
uintptr_t nextaddr = *(ptr_t*)from_ptrv(R_EBX + PK32(2));
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", (void*)nextaddr);
|
||||
printFunctionAddr(nextaddr, "=> ");
|
||||
PrintFunctionAddr(nextaddr, "=> ");
|
||||
} else if(PK(1)==0x92) {
|
||||
uintptr_t nextaddr = is32bits?(*(ptr_t*)from_ptrv(R_EDX + PK32(2))):(*(uintptr_t*)(R_RDX + PK32(2)));
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", (void*)nextaddr);
|
||||
printFunctionAddr(nextaddr, "=> ");
|
||||
PrintFunctionAddr(nextaddr, "=> ");
|
||||
} else if(PK(1)==0x50) {
|
||||
uintptr_t nextaddr = is32bits?(*(ptr_t*)from_ptrv(R_EAX + PK(2))):(*(uintptr_t*)(R_RAX + PK(2)));
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", (void*)nextaddr);
|
||||
printFunctionAddr(nextaddr, "=> ");
|
||||
PrintFunctionAddr(nextaddr, "=> ");
|
||||
} else if(PK(1)==0x52) {
|
||||
uintptr_t nextaddr = is32bits?(*(ptr_t*)from_ptrv(R_EDX + PK(2))):(*(uintptr_t*)(R_RDX + PK(2)));
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", (void*)nextaddr);
|
||||
printFunctionAddr(nextaddr, "=> ");
|
||||
PrintFunctionAddr(nextaddr, "=> ");
|
||||
} else if(is32bits && PK(1)==0x10) {
|
||||
uintptr_t nextaddr = *(ptr_t*)from_ptrv(R_EAX);
|
||||
printf_log_prefix(0, LOG_NONE, " => %p", (void*)nextaddr);
|
||||
printFunctionAddr(nextaddr, "=> ");
|
||||
PrintFunctionAddr(nextaddr, "=> ");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "regs.h"
|
||||
#include "x64emu_private.h"
|
||||
#include "box64context.h"
|
||||
#include "symbolfuncs.h"
|
||||
|
||||
typedef struct rex_s {
|
||||
union {
|
||||
|
@ -278,8 +278,6 @@ void thread_set_emu(x64emu_t* emu);
|
||||
void thread_forget_emu();
|
||||
x64emu_t* thread_get_emu(void);
|
||||
|
||||
// unlock mutex that are locked by current thread (for signal handling). Return a mask of unlock mutex
|
||||
int unlockMutex(void);
|
||||
// relock the muxtex that were unlocked
|
||||
void relockMutex(int locks);
|
||||
|
||||
|
@ -118,8 +118,6 @@ void* find47bitBlockElf(size_t size, int mainbin, uintptr_t mask);
|
||||
void* find31bitBlockElf(size_t size, int mainbin, uintptr_t mask);
|
||||
int isBlockFree(void* hint, size_t size);
|
||||
|
||||
// unlock mutex that are locked by current thread (for signal handling). Return a mask of unlock mutex
|
||||
int unlockCustommemMutex(void);
|
||||
// relock the muxtex that were unlocked
|
||||
void relockCustommemMutex(int locks);
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <stdint.h>
|
||||
#include <env.h>
|
||||
|
||||
#include "os.h"
|
||||
|
||||
typedef struct box64context_s box64context_t;
|
||||
extern box64env_t box64env;
|
||||
extern box64env_t* cur_box64env;
|
||||
|
@ -11,6 +11,8 @@ typedef struct {
|
||||
typedef sigset_t __sigset_t;
|
||||
|
||||
#define sigfillset(x)
|
||||
|
||||
#define SIGTRAP 5
|
||||
#endif
|
||||
|
||||
#endif // __MYSIGNAL_H_
|
8
src/include/symbolfuncs.h
Normal file
8
src/include/symbolfuncs.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef __SYMBOLFUNCS_H__
|
||||
#define __SYMBOLFUNCS_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int PrintFunctionAddr(uintptr_t nextaddr, const char* text); // 0 if nothing was found
|
||||
|
||||
#endif // __SYMBOLFUNCS_H__
|
@ -34,7 +34,6 @@ long double LD2localLD(void* ld); // long double (80bits pointer) -> long
|
||||
void LD2D(void* ld, void* d); // long double (80bits) -> double (64bits)
|
||||
void D2LD(void* d, void* ld); // double (64bits) -> long double (64bits)
|
||||
|
||||
int printFunctionAddr(uintptr_t nextaddr, const char* text); // 0 if nothing was found
|
||||
const char* getAddrFunctionName(uintptr_t addr);
|
||||
|
||||
#endif //__X86EMU_H_
|
||||
|
@ -465,6 +465,9 @@ void convert_siginfo_to_32(void* d, void* s, int sig)
|
||||
dst->_sifields._sigchld.__si_utime = src->si_utime;
|
||||
}
|
||||
}
|
||||
|
||||
void relockMutex(int locks);
|
||||
|
||||
int write_opcode(uintptr_t rip, uintptr_t native_ip, int is32bits);
|
||||
#define is_memprot_locked (1<<1)
|
||||
#define is_dyndump_locked (1<<8)
|
||||
|
@ -1069,6 +1069,51 @@ int sigbus_specialcases(siginfo_t* info, void * ucntx, void* pc, void* _fpsimd,
|
||||
#undef CHECK
|
||||
}
|
||||
|
||||
#ifdef USE_CUSTOM_MUTEX
|
||||
extern uint32_t mutex_prot;
|
||||
extern uint32_t mutex_blocks;
|
||||
#else
|
||||
extern pthread_mutex_t mutex_prot;
|
||||
extern pthread_mutex_t mutex_blocks;
|
||||
#endif
|
||||
|
||||
// unlock mutex that are locked by current thread (for signal handling). Return a mask of unlock mutex
|
||||
int unlockMutex()
|
||||
{
|
||||
int ret = 0;
|
||||
int i;
|
||||
#ifdef USE_CUSTOM_MUTEX
|
||||
uint32_t tid = (uint32_t)GetTID();
|
||||
#define GO(A, B) \
|
||||
i = (native_lock_storeifref2_d(&A, 0, tid) == tid); \
|
||||
if (i) { \
|
||||
ret |= (1 << B); \
|
||||
}
|
||||
#else
|
||||
#define GO(A, B) \
|
||||
i = checkUnlockMutex(&A); \
|
||||
if (i) { \
|
||||
ret |= (1 << B); \
|
||||
}
|
||||
#endif
|
||||
|
||||
GO(mutex_blocks, 0)
|
||||
GO(mutex_prot, 1)
|
||||
|
||||
GO(my_context->mutex_trace, 7)
|
||||
#ifdef DYNAREC
|
||||
GO(my_context->mutex_dyndump, 8)
|
||||
#else
|
||||
GO(my_context->mutex_lock, 8)
|
||||
#endif
|
||||
GO(my_context->mutex_tls, 9)
|
||||
GO(my_context->mutex_thread, 10)
|
||||
GO(my_context->mutex_bridge, 11)
|
||||
#undef GO
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef BOX32
|
||||
void my_sigactionhandler_oldcode_32(x64emu_t* emu, int32_t sig, int simple, siginfo_t* info, void * ucntx, int* old_code, void* cur_db);
|
||||
#endif
|
||||
|
@ -12,6 +12,11 @@ int SchedYield(void)
|
||||
return SwitchToThread();
|
||||
}
|
||||
|
||||
int IsBridgeSignature(char s, char c)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void PersonalityAddrLimit32Bit(void) { }
|
||||
|
||||
ULONG_PTR default_zero_bits32 = 0x7fffffff;
|
||||
|
20
src/os/symbolfuncs_linux.c
Normal file
20
src/os/symbolfuncs_linux.c
Normal file
@ -0,0 +1,20 @@
|
||||
#include "symbolfuncs.h"
|
||||
#include "elfloader.h"
|
||||
#include "debug.h"
|
||||
#include "box64context.h"
|
||||
|
||||
int PrintFunctionAddr(uintptr_t nextaddr, const char* text)
|
||||
{
|
||||
uint64_t sz = 0;
|
||||
uintptr_t start = 0;
|
||||
const char* symbname = FindNearestSymbolName(FindElfAddress(my_context, nextaddr), (void*)nextaddr, &start, &sz);
|
||||
if(!sz) sz=0x100; // arbitrary value...
|
||||
if(symbname && nextaddr>=start && (nextaddr<(start+sz) || !sz)) {
|
||||
if(nextaddr==start)
|
||||
printf_log_prefix(0, LOG_NONE, " (%s%s:%s)", text, ElfName(FindElfAddress(my_context, nextaddr)), symbname);
|
||||
else
|
||||
printf_log_prefix(0, LOG_NONE, " (%s%s:%s + 0x%lx)", text, ElfName(FindElfAddress(my_context, nextaddr)), symbname, nextaddr - start);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
6
src/os/symbolfuncs_wine.c
Normal file
6
src/os/symbolfuncs_wine.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include "symbolfuncs.h"
|
||||
|
||||
int PrintFunctionAddr(uintptr_t nextaddr, const char* text)
|
||||
{
|
||||
return 0;
|
||||
}
|
@ -25,13 +25,16 @@ set_source_files_properties(${DYNAREC_ASM_SRC} PROPERTIES COMPILE_OPTIONS "-mcpu
|
||||
|
||||
set(BOX64CPU_SRC
|
||||
"${BOX64_ROOT}/src/custommem.c"
|
||||
"${BOX64_ROOT}/src/dynarec/arm64/dynarec_arm64_jmpnext.c"
|
||||
"${BOX64_ROOT}/src/emu/x87emu_private.c"
|
||||
"${BOX64_ROOT}/src/dynarec/dynablock.c"
|
||||
"${BOX64_ROOT}/src/dynarec/dynarec_native_functions.c"
|
||||
"${BOX64_ROOT}/src/dynarec/dynarec_native.c"
|
||||
"${BOX64_ROOT}/src/os/backtrace.c"
|
||||
"${BOX64_ROOT}/src/os/os_wine.c"
|
||||
"${BOX64_ROOT}/src/os/symbolfuncs_wine.c"
|
||||
"${BOX64_ROOT}/src/tools/alternate.c"
|
||||
"${BOX64_ROOT}/src/tools/rbtree.c"
|
||||
"${BOX64_ROOT}/src/libtools/threads.c"
|
||||
)
|
||||
|
||||
add_library(wowbox64 SHARED ${MAIN_SRC} ${BOX64CPU_SRC} ${DYNAREC_ASM_SRC})
|
||||
|
@ -5,6 +5,36 @@
|
||||
|
||||
#include "os.h"
|
||||
#include "custommem.h"
|
||||
#include "env.h"
|
||||
#include "box64context.h"
|
||||
|
||||
uintptr_t box64_pagesize = 4096;
|
||||
|
||||
int box64_is32bits = 0;
|
||||
int box64_wine = 0; // this is for the emulated x86 Wine.
|
||||
|
||||
box64env_t box64env = { 0 }; // FIXME: add real env support.
|
||||
|
||||
box64env_t* GetCurEnvByAddr(uintptr_t addr) {
|
||||
return &box64env;
|
||||
}
|
||||
|
||||
int arm64_asimd = 0;
|
||||
int arm64_aes = 0;
|
||||
int arm64_pmull = 0;
|
||||
int arm64_crc32 = 0;
|
||||
int arm64_atomics = 0;
|
||||
int arm64_sha1 = 0;
|
||||
int arm64_sha2 = 0;
|
||||
int arm64_uscat = 0;
|
||||
int arm64_flagm = 0;
|
||||
int arm64_flagm2 = 0;
|
||||
int arm64_frintts = 0;
|
||||
int arm64_afp = 0;
|
||||
int arm64_rndr = 0;
|
||||
|
||||
static box64context_t box64_context;
|
||||
box64context_t *my_context = &box64_context;
|
||||
|
||||
void WINAPI BTCpuFlushInstructionCache2(LPCVOID addr, SIZE_T size)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user