Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c9ca34b
Update LIEF to 0.12.1
ekilmer Jun 8, 2022
d38cab4
Update LIEF API usage
ekilmer Jun 8, 2022
f6b4304
Add version requirement to CMake when finding LIEF
ekilmer Jun 8, 2022
3af4dbe
vcpkg integration
ekilmer Jun 27, 2022
3a6cf4b
Update to Mbed-TLS v3.2.1
ekilmer Jul 20, 2022
425ebe3
Update sleigh portfile to latest cmake-refactor commit
ekilmer Aug 2, 2022
62c039e
Add vcpkg-tool-sleigh-speccompiler
ekilmer Aug 18, 2022
c8a20af
Update to latest LIEF
ekilmer Nov 16, 2022
4d00b54
Merge branch 'master' into ekilmer/vcpkg-integration
ekilmer Nov 16, 2022
c7a616e
CI: Update clang compiler from 11 to 14
ekilmer Dec 9, 2022
f7fb224
CI: Fix Python 3 macOS dependencies
ekilmer Dec 9, 2022
d9dd5b4
Update sleigh to 10.2.2
ekilmer Nov 16, 2022
441531c
Merge latest x86 slaspec files from Ghidra 10.2.2
ekilmer Dec 22, 2022
155aef7
Change value for tests (unsure if correct)
ekilmer Dec 29, 2022
5c03f5c
Add back previously failing tests
ekilmer Dec 29, 2022
58f1ff7
Don't include LLVM version in HACKING doc
ekilmer Dec 29, 2022
ce71cc3
Fix compilation when using sleigh submodule
ekilmer Jan 16, 2023
00a90f3
Fix some ubsan errors
ekilmer Jan 16, 2023
467450c
Use 'std::' prefix when needed
ekilmer Jan 16, 2023
62a5390
Update vcpkg ports
ekilmer Mar 29, 2023
68ab2f8
Merge branch 'master' into ekilmer/vcpkg-integration
ekilmer Mar 29, 2023
fafd35c
Merge branch 'ekilmer/update-sleigh' into ekilmer/vcpkg-integration
ekilmer Mar 29, 2023
90a2b64
Download vcpkg in CI
ekilmer Mar 29, 2023
82ec219
Update to Ghidra 10.2.3
ekilmer Mar 30, 2023
a556438
Don't treat on CMake warnings as errors + don't fail fast
ekilmer Mar 30, 2023
b1a85e0
Fix more CI
ekilmer Mar 30, 2023
c91b388
More CI updates
ekilmer Mar 30, 2023
ffdb362
Don't fail fast matrix
ekilmer Mar 30, 2023
e8f42e1
Fix CI for testing installed directory
ekilmer Mar 30, 2023
8e7afae
Merge branch 'ekilmer/update-sleigh' into ekilmer/vcpkg-integration
ekilmer Mar 30, 2023
893f0ee
Try to fix vcpkg install directory
ekilmer Mar 30, 2023
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
48 changes: 36 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ on:

pull_request:
branches:
- '**'
- "**"

env:
LIEF_VERSION: 0.12.3
SLEIGH_VERSION: 10.2.3

jobs:
coverage:
Expand All @@ -26,9 +27,18 @@ jobs:

- name: Install Dependencies
run: |
sudo apt-get install libgmp-dev python3-dev libz3-dev
wget -O - -c https://github.com/lief-project/LIEF/releases/download/$LIEF_VERSION/LIEF-$LIEF_VERSION-Linux-x86_64.tar.gz | sudo tar xz -C /usr/local --strip-components=1
wget -O - -c https://github.com/lifting-bits/sleigh/releases/download/v10.1.2-2/Linux-sleigh-10.1.2-2.x86_64.tar.gz | sudo tar xz -C /usr/local --strip-components=1
sudo apt-get install libgmp-dev python3-dev
# LIEF
wget -O- https://github.com/lief-project/LIEF/releases/download/$LIEF_VERSION/LIEF-$LIEF_VERSION-Linux-x86_64.tar.gz | sudo tar xz -C /usr/local --strip-components=1
# Sleigh
wget -O- https://github.com/lifting-bits/sleigh/releases/download/v$SLEIGH_VERSION/Linux-sleigh-$SLEIGH_VERSION-1.x86_64.tar.gz | sudo tar xz -C /usr/local --strip-components=1
# Z3 Ubuntu 20.04 package doesn't play nice with sanitizers
# (also remove top-level directory from zip)
wget -O z3.zip https://github.com/Z3Prover/z3/releases/download/z3-4.8.14/z3-4.8.14-x64-glibc-2.31.zip
dest=/opt/z3; zip=./z3.zip; \
sudo mkdir -p "${dest}" && \
sudo unzip -d "${dest}" "${zip}" && \
f=("${dest}"/*) && sudo mv "${dest}"/*/* "$dest" && sudo rmdir "${f[@]}"

- name: Install LCov
run: sudo apt-get update -q
Expand Down Expand Up @@ -69,7 +79,7 @@ jobs:
# LIEF
wget -O- https://github.com/lief-project/LIEF/releases/download/$LIEF_VERSION/LIEF-$LIEF_VERSION-Linux-x86_64.tar.gz | sudo tar xz -C /usr/local --strip-components=1
# Sleigh
wget -O- https://github.com/lifting-bits/sleigh/releases/download/v10.1.2-2/Linux-sleigh-10.1.2-2.x86_64.tar.gz | sudo tar xz -C /usr/local --strip-components=1
wget -O- https://github.com/lifting-bits/sleigh/releases/download/v$SLEIGH_VERSION/Linux-sleigh-$SLEIGH_VERSION-1.x86_64.tar.gz | sudo tar xz -C /usr/local --strip-components=1
# Z3 Ubuntu 20.04 package doesn't play nice with sanitizers
# (also remove top-level directory from zip)
wget -O z3.zip https://github.com/Z3Prover/z3/releases/download/z3-4.8.14/z3-4.8.14-x64-glibc-2.31.zip
Expand Down Expand Up @@ -99,6 +109,7 @@ jobs:

test:
strategy:
fail-fast: false
matrix:
os: [
# TODO: windows,
Expand All @@ -111,6 +122,8 @@ jobs:
include:
- { type: shared, shared: YES }
- { type: static, shared: NO }
- { os: macos, triplet: x64-osx-release }
- { os: ubuntu, triplet: x64-linux-release }

runs-on: ${{ matrix.os }}-latest

Expand All @@ -125,25 +138,30 @@ jobs:
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

- name: Common Dependencies
run: |
git clone https://github.com/microsoft/vcpkg
git -C vcpkg checkout 23f0707b1a46bbf7fff9fb95cde2aa0c7213c31d
echo "VCPKG_ROOT=$(pwd)/vcpkg" >> "$GITHUB_ENV"

- name: Install Dependencies
if: matrix.os == 'ubuntu'
run: |
sudo apt-get install libgmp-dev python3-dev libz3-dev
sudo apt-get install python3-dev
python3 -m pip install pytest
wget -O - -c https://github.com/lief-project/LIEF/releases/download/$LIEF_VERSION/LIEF-$LIEF_VERSION-Linux-x86_64.tar.gz | sudo tar xz -C /usr/local --strip-components=1
wget -O - -c https://github.com/lifting-bits/sleigh/releases/download/v10.1.2-2/Linux-sleigh-10.1.2-2.x86_64.tar.gz | sudo tar xz -C /usr/local --strip-components=1

- name: Install Dependencies
if: matrix.os == 'macos'
run: |
brew install gmp z3
brew install autoconf automake libtool
python3 -m pip install --user pytest
wget -O - -c https://github.com/lief-project/LIEF/releases/download/$LIEF_VERSION/LIEF-$LIEF_VERSION-Darwin-x86_64.tar.gz | sudo tar xz -C /usr/local --strip-components=1
wget -O - -c https://github.com/lifting-bits/sleigh/releases/download/v10.1.2-2/macOS-sleigh-10.1.2-2.x86_64.tar.gz | sudo tar xz -C /usr/local --strip-components=1

- name: Configure
run: cmake --preset=ci-${{ matrix.os }}
-D BUILD_SHARED_LIBS=${{ matrix.shared }}
-D VCPKG_HOST_TRIPLET=${{ matrix.triplet }}
-D VCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
-D "VCPKG_INSTALLED_DIR=${{ github.workspace }}/vcpkg_installed"

- name: Build
run: cmake --build build --config Release -j 2
Expand All @@ -154,7 +172,13 @@ jobs:
- name: Test install directory
working-directory: tests/find-package
run: |
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -Dmaat_DIR=${{ github.workspace }}/prefix/share/maat
cmake -B build -S . \
-DCMAKE_BUILD_TYPE=Release \
-Dmaat_DIR=${{ github.workspace }}/prefix/share/maat \
"-DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_HOST_TRIPLET=${{ matrix.triplet }} \
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \
"-DVCPKG_INSTALLED_DIR=${{ github.workspace }}/vcpkg_installed"
cmake --build build
./build/maat_find_package_test

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:

env:
LIEF_VERSION: 0.12.3
SLEIGH_VERSION: 10.2.3

jobs:

Expand Down Expand Up @@ -125,7 +126,7 @@ jobs:
cmake --build z3/build "-j$(sysctl -n hw.logicalcpu)" && cmake --install z3/build --prefix "${{ github.workspace }}/arm64-cross"

# Native sleigh for running the sleigh compiler
wget -O - -c https://github.com/lifting-bits/sleigh/releases/download/v10.1.2-2/macOS-sleigh-10.1.2-2.x86_64.tar.gz | sudo tar xz -C /usr/local --strip-components=1
wget -O - -c https://github.com/lifting-bits/sleigh/releases/download/v$SLEIGH_VERSION/macOS-sleigh-$SLEIGH_VERSION-1.x86_64.tar.gz | sudo tar xz -C /usr/local --strip-components=1


- name: Build wheels
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ cmake-build-*/
prefix/
CMakeLists.txt.user
CMakeUserPresets.json
.z3-trace
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ if(maat_USE_EXTERNAL_SLEIGH)
find_package(sleigh REQUIRED)
else()
set(sleigh_ENABLE_TESTS OFF CACHE BOOL "")
set(sleigh_BUILD_TOOLS ON CACHE BOOL "")
add_subdirectory(src/third-party/sleigh/sleigh-cmake sleigh EXCLUDE_FROM_ALL)
include("${sleigh_SOURCE_DIR}/cmake/modules/sleighCompile.cmake")
endif()

target_link_libraries(
Expand Down Expand Up @@ -155,15 +157,13 @@ add_custom_command(

# Allow user to override sleigh compiler to support cross-compilation. Default
# location is the one imported when we found the sleigh package
if(CMAKE_CROSSCOMPILING)
find_program(maat_SLEIGH_COMPILER "sleigh_opt"
DOC "Sleigh compiler executable"
)
if(TARGET sleigh::sleigh AND NOT CMAKE_CROSSCOMPILING)
set(maat_SLEIGH_COMPILER "$<TARGET_FILE:sleigh::sleigh>" CACHE PATH "Sleigh compiler executable")
else()
find_program(maat_SLEIGH_COMPILER "sleigh" DOC "Sleigh compiler executable")
if(NOT maat_SLEIGH_COMPILER)
message(FATAL_ERROR "Maat needs a sleigh compiler. Specify path manually by setting 'maat_SLEIGH_COMPILER'")
endif()
else()
set(maat_SLEIGH_COMPILER "$<TARGET_FILE:sleigh::sleigh_opt>" CACHE PATH "Sleigh compiler executable")
endif()

macro(maat_sleigh_compile ARCH_DIR ARCH)
Expand Down
28 changes: 23 additions & 5 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"systemVars": false
},
"errors": {
"dev": true,
"deprecated": true
}
},
Expand All @@ -29,6 +28,21 @@
"maat_DEVELOPER_MODE": "ON"
}
},
{
"name": "vcpkg",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
},
{
"name": "vcpkg-win64-static",
"inherits": "vcpkg",
"hidden": true,
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows-static-md"
}
},
{
"name": "cppcheck",
"hidden": true,
Expand All @@ -50,7 +64,8 @@
"cacheVariables": {
"CMAKE_CXX_EXTENSIONS": "OFF",
"CMAKE_CXX_STANDARD": "17",
"CMAKE_CXX_STANDARD_REQUIRED": "ON"
"CMAKE_CXX_STANDARD_REQUIRED": "ON",
"CMAKE_POSITION_INDEPENDENT_CODE": "ON"
}
},
{
Expand Down Expand Up @@ -107,6 +122,9 @@
"name": "ci-sanitize",
"binaryDir": "${sourceDir}/build/sanitize",
"inherits": ["ci-unix", "dev-mode"],
"errors": {
"dev": true
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Sanitize",
"CMAKE_CXX_FLAGS_SANITIZE": "-O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common",
Expand All @@ -120,15 +138,15 @@
},
{
"name": "ci-macos",
"inherits": ["ci-build", "ci-unix", "dev-mode"]
"inherits": ["ci-build", "ci-unix", "dev-mode", "vcpkg"]
},
{
"name": "ci-ubuntu",
"inherits": ["ci-build", "ci-unix", "dev-mode"]
"inherits": ["ci-build", "ci-unix", "dev-mode", "vcpkg"]
},
{
"name": "ci-windows",
"inherits": ["ci-build", "ci-win64", "dev-mode"]
"inherits": ["ci-build", "ci-win64", "dev-mode", "vcpkg-win64-static"]
}
]
}
4 changes: 2 additions & 2 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ the project. The following is a real example of a contributor's user preset (ins
"inherits": ["dev-common", "ci-sanitize"],
"binaryDir": "${sourceDir}/build/sanitize",
"cacheVariables": {
"CMAKE_CXX_COMPILER": "/usr/local/opt/llvm@13/bin/clang++",
"CMAKE_C_COMPILER": "/usr/local/opt/llvm@13/bin/clang"
"CMAKE_CXX_COMPILER": "/usr/local/opt/llvm/bin/clang++",
"CMAKE_C_COMPILER": "/usr/local/opt/llvm/bin/clang"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion bindings/packaging/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN yum install -y wget findutils git gmp-devel python3-devel curl

# Build and install LIEF. We need to rebuild it so that it doesn't use the C++11 mangling ABI
# which is incompatible with manylinux wheels
RUN wget -O lief.tar.gz https://github.com/lief-project/LIEF/archive/refs/tags/0.12.3.zip && \
RUN wget -O lief.tar.gz https://github.com/lief-project/LIEF/releases/download/0.12.3/lief-0.12.3.tar.gz && \
mkdir -p lief/build && tar xzvf lief.tar.gz -C lief --strip-components 1 && cd lief/build && \
cmake -DCMAKE_BUILD_TYPE=Release .. && make -j4 && make install && \
cd ../.. && rm -rf lief.tar.gz lief
Expand Down
2 changes: 1 addition & 1 deletion cmake/install-rules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ set(other_maat_targets)
# Needed only if using vendored library and not building as shared library
# because sleigh is always a static library
if(NOT maat_USE_EXTERNAL_SLEIGH AND NOT BUILD_SHARED_LIBS)
list(APPEND other_maat_targets sla sleigh_settings)
list(APPEND other_maat_targets sleigh_sla)
endif()

install(
Expand Down
28 changes: 28 additions & 0 deletions ports/fmt/fix-format-conflict.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h
index 2c51c50..fb3eba0 100644
--- a/include/fmt/format-inl.h
+++ b/include/fmt/format-inl.h
@@ -75,8 +75,8 @@ FMT_FUNC void format_error_code(detail::buffer<char>& out, int error_code,
error_code_size += detail::to_unsigned(detail::count_digits(abs_value));
auto it = buffer_appender<char>(out);
if (message.size() <= inline_buffer_size - error_code_size)
- format_to(it, FMT_STRING("{}{}"), message, SEP);
- format_to(it, FMT_STRING("{}{}"), ERROR_STR, error_code);
+ fmt::format_to(it, FMT_STRING("{}{}"), message, SEP);
+ fmt::format_to(it, FMT_STRING("{}{}"), ERROR_STR, error_code);
FMT_ASSERT(out.size() <= inline_buffer_size, "");
}

diff --git a/src/os.cc b/src/os.cc
index 04b4dc5..fe2c7e4 100644
--- a/src/os.cc
+++ b/src/os.cc
@@ -167,7 +167,7 @@ void detail::format_windows_error(detail::buffer<char>& out, int error_code,
if (msg) {
utf16_to_utf8 utf8_message;
if (utf8_message.convert(msg) == ERROR_SUCCESS) {
- format_to(buffer_appender<char>(out), "{}: {}", message, utf8_message);
+ fmt::format_to(buffer_appender<char>(out), "{}: {}", message, utf8_message);
return;
}
}
11 changes: 11 additions & 0 deletions ports/fmt/fix-invalid-command.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
diff --git a/include/fmt/locale.h b/include/fmt/locale.h
index 7571b52..0a34eb4 100644
--- a/include/fmt/locale.h
+++ b/include/fmt/locale.h
@@ -1,2 +1,6 @@
#include "xchar.h"
+#ifdef _WIN32
+#pragma message ("fmt/locale.h is deprecated, include fmt/format.h or fmt/xchar.h instead")
+#else
#warning fmt/locale.h is deprecated, include fmt/format.h or fmt/xchar.h instead
+#endif
13 changes: 13 additions & 0 deletions ports/fmt/fix-write-batch.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f21cf45..691a632 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -157,7 +157,7 @@ if (MASTER_PROJECT AND CMAKE_GENERATOR MATCHES "Visual Studio")
join(netfxpath
"C:\\Program Files\\Reference Assemblies\\Microsoft\\Framework\\"
".NETFramework\\v4.0")
- file(WRITE run-msbuild.bat "
+ file(WRITE ${CMAKE_BINARY_DIR}/run-msbuild.bat "
${MSBUILD_SETUP}
${CMAKE_MAKE_PROGRAM} -p:FrameworkPathOverride=\"${netfxpath}\" %*")
endif ()
67 changes: 67 additions & 0 deletions ports/fmt/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO fmtlib/fmt
REF 8.1.1
SHA512 794a47d7cb352a2a9f2c050a60a46b002e4157e5ad23e15a5afc668e852b1e1847aeee3cda79e266c789ff79310d792060c94976ceef6352e322d60b94e23189
HEAD_REF master
PATCHES
fix-write-batch.patch
fix-invalid-command.patch
fix-format-conflict.patch
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DFMT_CMAKE_DIR=share/fmt
-DFMT_TEST=OFF
-DFMT_DOC=OFF
)

vcpkg_cmake_install()
file(INSTALL "${SOURCE_PATH}/LICENSE.rst" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
if(VCPKG_TARGET_IS_WINDOWS)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/fmtd.dll")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/bin")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/fmtd.dll" "${CURRENT_PACKAGES_DIR}/debug/bin/fmtd.dll")
endif()
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
if(EXISTS "${CURRENT_PACKAGES_DIR}/lib/fmt.dll")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/bin")
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/fmt.dll" "${CURRENT_PACKAGES_DIR}/bin/fmt.dll")
endif()
endif()
endif()

vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/fmt/core.h
"defined(FMT_SHARED)"
"1"
)
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

vcpkg_cmake_config_fixup()
vcpkg_fixup_pkgconfig()

if(VCPKG_TARGET_IS_WINDOWS)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/share/fmt/fmt-targets-debug.cmake
"lib/fmtd.dll"
"bin/fmtd.dll"
)
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/share/fmt/fmt-targets-release.cmake
"lib/fmt.dll"
"bin/fmt.dll"
)
endif()
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

# Handle post-build CMake instructions
vcpkg_copy_pdbs()
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
8 changes: 8 additions & 0 deletions ports/fmt/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The package fmt provides CMake targets:

find_package(fmt CONFIG REQUIRED)
target_link_libraries(main PRIVATE fmt::fmt)

# Or use the header-only version
find_package(fmt CONFIG REQUIRED)
target_link_libraries(main PRIVATE fmt::fmt-header-only)
Loading