From e5413f9abd7dab28592ff06ffc9fd21544a76b0f Mon Sep 17 00:00:00 2001 From: iris Date: Mon, 11 May 2026 14:17:07 +0200 Subject: [PATCH] introduce capstone --- CMakeLists.txt | 16 ++++++++++++++-- external/capstone/CMakeLists.txt | 2 +- main.cpp | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90ca5a6..1bb82d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,18 @@ project(weee CXX) set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) -include_directories(external/ELFIO) +option(BUILD_SHARED_LIBS OFF) -add_executable(weee main.cpp) \ No newline at end of file +include_directories(external/ELFIO) +include_directories(external/capstone/include) + +if(WIN32) + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) +endif() + +set(CAPSTONE_ARCHITECTURE_DEFAULT OFF) +set(CAPSTONE_PPC_SUPPORT ON) +add_subdirectory(external/capstone) + +add_executable(weee main.cpp) +target_link_libraries(weee PUBLIC capstone) \ No newline at end of file diff --git a/external/capstone/CMakeLists.txt b/external/capstone/CMakeLists.txt index 6e5d87b..a15cc8f 100644 --- a/external/capstone/CMakeLists.txt +++ b/external/capstone/CMakeLists.txt @@ -36,7 +36,7 @@ project(capstone VERSION ${PROJECT_VERSION_BASE}) # Print the values of PROJECT_VERSION and PROJECT_VERSION_BASE message(STATUS "PROJECT_VERSION: ${CPACK_PACKAGE_VERSION} CAPSTONE_VERSION: ${PROJECT_VERSION_BASE}") -set(UNIX_COMPILER_OPTIONS -Werror -Wall -Warray-bounds -Wshift-negative-value -Wreturn-type -Wformat -Wmissing-braces -Wunused-function -Warray-bounds -Wunused-variable -Wparentheses -Wint-in-bool-context -Wmisleading-indentation) +set(UNIX_COMPILER_OPTIONS -Wall -Warray-bounds -Wshift-negative-value -Wreturn-type -Wformat -Wmissing-braces -Wunused-function -Warray-bounds -Wunused-variable -Wparentheses -Wint-in-bool-context -Wmisleading-indentation) # maybe-uninitialized is only supported by newer versions of GCC. # Unfortunately, it is pretty unreliable and reports wrong results. diff --git a/main.cpp b/main.cpp index 1f95a5a..4671284 100644 --- a/main.cpp +++ b/main.cpp @@ -10,4 +10,6 @@ int main() { const auto& section = reader.sections[i]; std::println(R"(Section n.{} "{}": 0x{:08X} -> 0x{:08X})", i, section->get_name(), section->get_address(), section->get_address() + section->get_size() - 1); } + + return 0; } \ No newline at end of file