Made the Signal workaround more generic, so it can be used by Termux user

This commit is contained in:
ptitSeb 2023-03-05 21:01:40 +01:00
parent b56be08f95
commit 31fd0451d0
3 changed files with 11 additions and 1 deletions

View File

@ -23,6 +23,7 @@ option(USE_CCACHE "Set to ON to use ccache if present in the system" ${USE_CCACH
option(HAVE_TRACE "Set to ON to have Trace ability (needs ZydisInfo library)" ${HAVE_TRACE})
option(NOLOADADDR "Set to ON to avoid fixing the load address of Box64" OFF)
option(NOGIT "Set to ON if not building from a git clone repo (like when building from a zip download from github)" ${NOGIT})
option(BAD_SIGNAL "Set to ON to activate the workaround for incoherent si_info on SIGSEGV" ${BAD_SIGNAL})
option(SW64 "Set ON if targeting an SW64 based device" ${SW64})
if(LARCH64)
@ -50,6 +51,9 @@ endif()
if(RK3399 OR RK3588 OR ODROIDN2 OR RPI3ARM64 OR RPI4ARM64 OR RK3326 OR TEGRAX1 OR PHYTIUM OR SD845 OR LX2160A)
set(PAGE16K OFF CACHE BOOL "")
endif()
if(RK3588)
set(BAD_SIGNAL ON CACHE BOOL "")
endif()
if(M1 OR LARCH64)
set(PAGE16K ON CACHE BOOL "")
endif()
@ -156,6 +160,10 @@ elseif(ARM_DYNAREC)
set(CMAKE_ASM_FLAGS "-pipe -march=armv8-a+crc+simd+crypto")
endif()
if(BAD_SIGNAL)
add_definitions(-DBAD_SIGNAL)
endif()
if(PAGE8K)
add_definitions(-DPAGE8K)
endif()

View File

@ -169,6 +169,8 @@ sudo systemctl restart systemd-binfmt
`mkdir build; cd build; cmake .. -DARM_DYNAREC=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo; make -j$(nproc)`
You can also add `-DBAD_SIGNAL=ON` to the cmake command if you are on Linux Kernel mixed with Android, like on RK3588 or maybe Termux
#### for LoongArch
Using a 64bit OS:

View File

@ -847,7 +847,7 @@ void my_box64signalhandler(int32_t sig, siginfo_t* info, void * ucntx)
#endif
int Locks = unlockMutex();
uint32_t prot = getProtection((uintptr_t)addr);
#ifdef RK3588
#ifdef BAD_SIGNAL
// try to see if the si_code makes sense
// the RK3588 tend to need a special Kernel that seems to have a weird behaviour sometimes
if((sig==SIGSEGV) && (addr) && (info->si_code == 1) && prot&(PROT_READ|PROT_WRITE|PROT_EXEC)) {