about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-03-05 21:01:40 +0100
committerptitSeb <sebastien.chev@gmail.com>2023-03-05 21:01:40 +0100
commit31fd0451d0d65d8706078373c884bccbb4c9934b (patch)
tree31cf3ab86630645aed31cac16b3f762c53af200c
parentb56be08f959557a0a1fd18190ff89f8de83862a1 (diff)
downloadbox64-31fd0451d0d65d8706078373c884bccbb4c9934b.tar.gz
box64-31fd0451d0d65d8706078373c884bccbb4c9934b.zip
Made the Signal workaround more generic, so it can be used by Termux user
-rwxr-xr-xCMakeLists.txt8
-rwxr-xr-xdocs/COMPILE.md2
-rwxr-xr-xsrc/libtools/signals.c2
3 files changed, 11 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3b287e28..9de51a5f 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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()
diff --git a/docs/COMPILE.md b/docs/COMPILE.md
index 377a465f..f0dd0881 100755
--- a/docs/COMPILE.md
+++ b/docs/COMPILE.md
@@ -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:

diff --git a/src/libtools/signals.c b/src/libtools/signals.c
index f8aa6cb8..0bb9767f 100755
--- a/src/libtools/signals.c
+++ b/src/libtools/signals.c
@@ -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)) {