Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/bldd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential ninja-build
sudo apt-get install -y build-essential ninja-build catch2

- name: Cache CMake build
uses: actions/cache@v4
Expand All @@ -74,7 +74,8 @@ jobs:
- name: Configure CMake
run: |
cmake -B build -S . \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-G Ninja
Expand All @@ -84,7 +85,7 @@ jobs:

- name: Build
run: |
cmake --build build --config Release -j $(nproc)
cmake --build build -j $(nproc)

- name: Run tests
run: |
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Install Build Dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install cmake ninja # Assuming Xcode provides gcc/clang
brew install cmake ninja

- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
Expand All @@ -86,8 +86,6 @@ jobs:
- name: Configure CMake (Cross - Linux aarch64)
if: matrix.use_cross == true && runner.os == 'Linux'
run: |
# Use toolchain file or explicit flags
# Example using explicit flags (adjust if needed)
cmake -B build \
-DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} \
-DBUILD_TESTING=OFF \
Expand All @@ -101,6 +99,10 @@ jobs:
run: |
cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }} -j $(nproc)

- name: Strip
run: |
strip -u -r build/bin/${{ env.APP_NAME }}

- name: Prepare Artifact Directory
run: |
mkdir -p release-artifact
Expand Down Expand Up @@ -137,7 +139,6 @@ jobs:
- name: Generate Release Notes
run: |
echo "Release Notes for ${{ github.ref_name }}" > release_notes.md
git log --oneline $(git describe --tags --abbrev=0 HEAD^)..HEAD >> release_notes.md

- name: Create GitHub Release
id: create_release
Expand Down
169 changes: 116 additions & 53 deletions external/lief/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,64 +1,127 @@
if(APPLE)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
set(LIEF_ARCHIVE "LIEF-0.17.4-Darwin-arm64.tar.gz")
set(LIEF_HASH "SHA256=0805d0c25dbd6a2bea1245adc3f62571f0f945bb22a37058dd0585bdfcdc002c")
else()
set(LIEF_ARCHIVE "LIEF-0.17.4-Darwin-x86_64.tar.gz")
set(LIEF_HASH "SHA256=d275f30057856058932260b5e876682c5b367ad18d9eaff91e093303133405fb")
endif()
elseif(UNIX AND NOT ANDROID)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set(LIEF_ARCHIVE "LIEF-0.17.4-Linux-aarch64.tar.gz")
set(LIEF_HASH "SHA256=cc6f97ee0145f51262d75a32b4ffbffe43cd61c5f4db87b7831fdc18c6630460")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686")
set(LIEF_ARCHIVE "LIEF-0.17.4-Linux-i686.tar.gz")
set(LIEF_HASH "SHA256=a530b6500d8eba146471e1df04926b4bd01ab9fcbb3a27467b3f6a7c6b8d5ca3")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
set(LIEF_ARCHIVE "LIEF-0.17.4-Linux-x86_64.tar.gz")
set(LIEF_HASH "SHA256=bce2d8e5678756e2b3e6f1e99d6f925bbdf63afe39b8030d93c19555ec8b4fe8")
else()
message(FATAL_ERROR "Unsupported Linux architecture: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
elseif(ANDROID)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set(LIEF_ARCHIVE "LIEF-0.17.4-Android-aarch64.tar.gz")
set(LIEF_HASH "SHA256=4fb09d60c7ee9b3fa3da263b75d504920c3dc9bd6013b759f85e6b5018ecf801")
include(FetchContent)

if(CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS "Release mode: Building LIEF from source with ELF and MachO support only")

option(LIEF_TESTS "Enable tests" OFF)
option(LIEF_PYTHON_API "Enable Python Bindings" OFF)
option(LIEF_C_API "C API" OFF)
option(LIEF_EXAMPLES "Build LIEF C++ examples" OFF)
option(LIEF_FORCE32 "Force build LIEF 32 bits version" OFF)
option(LIEF_USE_CCACHE "Use ccache to speed up compilation" ON)
option(LIEF_EXTRA_WARNINGS "Enable extra warning from the compiler" OFF)
option(LIEF_LOGGING "Enable logging" OFF)
option(LIEF_LOGGING_DEBUG "Enable debug logging" OFF)
option(LIEF_ENABLE_JSON "Enable JSON-related APIs" OFF)
option(LIEF_OPT_NLOHMANN_JSON_EXTERNAL "Use nlohmann/json externally" OFF)
option(LIEF_FORCE_API_EXPORTS "Force exports of API symbols" OFF)
option(LIEF_PY_LIEF_EXT "Use a pre-installed version of LIEF for the bindings" OFF)
option(LIEF_RUST_API "Generate the C++ bridge for Rust's cxx" OFF)
option(LIEF_DISABLE_EXCEPTIONS "Disable C++ exceptions on the core library" ON)
option(LIEF_SO_VERSION "Embed versioning for LIEF shared library target" OFF)

option(LIEF_DISABLE_FROZEN "Disable Frozen even if it is supported" OFF)

# Only ELF and MACHO enabled
option(LIEF_MACHO "Build LIEF with MachO module" ON)
option(LIEF_ELF "Build LIEF with ELF module" ON)
option(LIEF_PE "Build LIEF with PE module" OFF)
option(LIEF_COFF "Build LIEF with COFF module" OFF)

option(LIEF_DEX "Build LIEF with DEX module" OFF)
option(LIEF_ART "Build LIEF with ART module" OFF)

# Extended features - all OFF
option(LIEF_DEBUG_INFO "Build LIEF with DWARF/PDB support" OFF)
option(LIEF_OBJC "Build LIEF with ObjC metadata support" OFF)
option(LIEF_DYLD_SHARED_CACHE "Build LIEF with Dyld shared cache support" OFF)
option(LIEF_ASM "Build LIEF with assembler/disassembler support" OFF)

# Sanitizers - all OFF
option(LIEF_ASAN "Enable Address sanitizer" OFF)
option(LIEF_LSAN "Enable Leak sanitizer" OFF)
option(LIEF_TSAN "Enable Thread sanitizer" OFF)
option(LIEF_USAN "Enable undefined sanitizer" OFF)

# Fuzzer - OFF
option(LIEF_FUZZING "Fuzz LIEF" OFF)

# Profiling - OFF
option(LIEF_PROFILING "Enable performance profiling" OFF)


FetchContent_Declare(
LIEF
URL https://github.com/lief-project/LIEF/archive/refs/tags/0.17.4.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)

FetchContent_MakeAvailable(LIEF)

else()
message(STATUS "Debug mode: Using prebuilt LIEF binaries")

if(APPLE)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
set(LIEF_ARCHIVE "LIEF-0.17.4-Darwin-arm64.tar.gz")
set(LIEF_HASH "SHA256=0805d0c25dbd6a2bea1245adc3f62571f0f945bb22a37058dd0585bdfcdc002c")
else()
set(LIEF_ARCHIVE "LIEF-0.17.4-Darwin-x86_64.tar.gz")
set(LIEF_HASH "SHA256=d275f30057856058932260b5e876682c5b367ad18d9eaff91e093303133405fb")
endif()
elseif(UNIX AND NOT ANDROID)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set(LIEF_ARCHIVE "LIEF-0.17.4-Linux-aarch64.tar.gz")
set(LIEF_HASH "SHA256=cc6f97ee0145f51262d75a32b4ffbffe43cd61c5f4db87b7831fdc18c6630460")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686")
set(LIEF_ARCHIVE "LIEF-0.17.4-Linux-i686.tar.gz")
set(LIEF_HASH "SHA256=a530b6500d8eba146471e1df04926b4bd01ab9fcbb3a27467b3f6a7c6b8d5ca3")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
set(LIEF_ARCHIVE "LIEF-0.17.4-Linux-x86_64.tar.gz")
set(LIEF_HASH "SHA256=bce2d8e5678756e2b3e6f1e99d6f925bbdf63afe39b8030d93c19555ec8b4fe8")
else()
message(FATAL_ERROR "Unsupported Linux architecture: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
elseif(ANDROID)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set(LIEF_ARCHIVE "LIEF-0.17.4-Android-aarch64.tar.gz")
set(LIEF_HASH "SHA256=4fb09d60c7ee9b3fa3da263b75d504920c3dc9bd6013b759f85e6b5018ecf801")
else()
set(LIEF_ARCHIVE "LIEF-0.17.4-Android-armv7-a.tar.gz")
set(LIEF_HASH "SHA256=e668ca8f64730c6c3226e9d3ca30c89802faa27ad3d7c365aad4bd8ac07561fb")
endif()
else()
set(LIEF_ARCHIVE "LIEF-0.17.4-Android-armv7-a.tar.gz")
set(LIEF_HASH "SHA256=e668ca8f64730c6c3226e9d3ca30c89802faa27ad3d7c365aad4bd8ac07561fb")
message(FATAL_ERROR "Unsupported platform for LIEF")
endif()
else()
message(FATAL_ERROR "Unsupported platform for LIEF")
endif()

message(STATUS "Using LIEF archive: ${LIEF_ARCHIVE}")
message(STATUS "Using LIEF archive: ${LIEF_ARCHIVE}")

FetchContent_Declare(
LIEF
URL "https://github.com/lief-project/LIEF/releases/download/0.17.4/${LIEF_ARCHIVE}"
URL_HASH ${LIEF_HASH}
)
FetchContent_Declare(
LIEF
URL "https://github.com/lief-project/LIEF/releases/download/0.17.4/${LIEF_ARCHIVE}"
URL_HASH ${LIEF_HASH}
)

FetchContent_MakeAvailable(LIEF)
FetchContent_MakeAvailable(LIEF)

set(LIEF_LIB_NAME "libLIEF.a")
set(LIEF_LIB_NAME "libLIEF.a")
set(LIEF_INCLUDE_DIR "${lief_SOURCE_DIR}/include")
set(LIEF_LIB_FILE "${lief_SOURCE_DIR}/lib/${LIEF_LIB_NAME}")

set(LIEF_INCLUDE_DIR "${lief_SOURCE_DIR}/include")
set(LIEF_LIB_FILE "${lief_SOURCE_DIR}/lib/${LIEF_LIB_NAME}")
message(STATUS "LIEF include dir : ${LIEF_INCLUDE_DIR}")
message(STATUS "LIEF library : ${LIEF_LIB_FILE}")

message(STATUS "LIEF include dir : ${LIEF_INCLUDE_DIR}")
message(STATUS "LIEF library : ${LIEF_LIB_FILE}")
if(NOT EXISTS "${LIEF_INCLUDE_DIR}")
message(FATAL_ERROR "LIEF include dir not found: ${LIEF_INCLUDE_DIR}")
endif()

if(NOT EXISTS "${LIEF_INCLUDE_DIR}")
message(FATAL_ERROR "LIEF include dir not found: ${LIEF_INCLUDE_DIR}")
endif()
if(NOT EXISTS "${LIEF_LIB_FILE}")
message(FATAL_ERROR "LIEF library not found: ${LIEF_LIB_FILE}")
endif()

if(NOT EXISTS "${LIEF_LIB_FILE}")
message(FATAL_ERROR "LIEF library not found: ${LIEF_LIB_FILE}")
add_library(elf_support STATIC IMPORTED GLOBAL)
set_target_properties(elf_support PROPERTIES
IMPORTED_LOCATION "${LIEF_LIB_FILE}"
INTERFACE_INCLUDE_DIRECTORIES "${LIEF_INCLUDE_DIR}"
)
endif()

add_library(elf_support STATIC IMPORTED GLOBAL)
set_target_properties(elf_support PROPERTIES
IMPORTED_LOCATION "${LIEF_LIB_FILE}"
INTERFACE_INCLUDE_DIRECTORIES "${LIEF_INCLUDE_DIR}"
)
3 changes: 1 addition & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ add_library(bldd_lib STATIC
${bldd_lib_sources}
)


target_link_libraries(bldd_lib
PRIVATE
elf_support
$<IF:$<CONFIG:DEBUG>, elf_support, LIEF::LIEF>
project_options
project_warnings
Threads::Threads
Expand Down