From 679a5a46af4f4b3a350570d28b7240d703de4234 Mon Sep 17 00:00:00 2001 From: secnotes <1321993383@qq.com> Date: Thu, 9 Oct 2025 07:45:37 -0400 Subject: [PATCH] Add support for the cross-compilation tool aarch64-linux-gnu in Linux --- CMakeLists.txt | 4 ++-- Linux/arm64.toochain.cmake | 12 ++++++++++++ Linux/debugger.h | 1 + README.md | 8 ++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 Linux/arm64.toochain.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c7c33b..648684a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,10 +28,10 @@ elseif(NOT DEFINED ${ARCHITECTURE}) endif() endif() -add_subdirectory(third_party) - project("tinyinst") +add_subdirectory(third_party) + include_directories(${CMAKE_CURRENT_BINARY_DIR}/third_party/obj/wkit/include) if(${ARCHITECTURE} MATCHES arm64) diff --git a/Linux/arm64.toochain.cmake b/Linux/arm64.toochain.cmake new file mode 100644 index 0000000..d81cd98 --- /dev/null +++ b/Linux/arm64.toochain.cmake @@ -0,0 +1,12 @@ +set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) + +set(ARCHITECTURE arm64) +add_definitions(-DARM64) + +# search for programs in the build host directories. +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# Only look for libraries, headers and packages in the sysroot, don't look on the build machine. +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) \ No newline at end of file diff --git a/Linux/debugger.h b/Linux/debugger.h index 6216c81..0521976 100644 --- a/Linux/debugger.h +++ b/Linux/debugger.h @@ -81,6 +81,7 @@ struct LoadedModule { bool operator< (LoadedModule const& lhs, LoadedModule const& rhs); #ifdef ARM64 +#include typedef user_pt_regs arch_reg_struct; #else typedef user_regs_struct arch_reg_struct; diff --git a/README.md b/README.md index 478df8f..70236bb 100755 --- a/README.md +++ b/README.md @@ -87,6 +87,14 @@ cmake -DCMAKE_TOOLCHAIN_FILE=build/cmake/android.toolchain cmake --build . --config Release ``` +#### Cross-compiling for Linux +``` +mkdir build +cd build +cmake -DCMAKE_TOOLCHAIN_FILE=../Linux/arm64.toochain.cmake .. +cmake --build . --config Release +``` + Note #1: 64-bit build will also run against 32-bit targets on Windows and Linux operating systems Note #2: Encountering problems creating a 32-bit build on 64-bit Windows due to the environment not being properly set up and libraries missing? Open the generated .sln file in Visual Studio and build from there instead of running cmake --build. Also note that 64-bit build is going to work on 32-bit targets, so creating a 32-bit build might not be necessary.