diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac6c61bd..b078a30f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,7 @@ on: env: LIEF_VERSION: 0.12.3 + SLEIGH_VERSION: 10.2.2 jobs: coverage: @@ -28,7 +29,7 @@ jobs: 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 + wget -O - -c 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 - name: Install LCov run: sudo apt-get update -q @@ -69,7 +70,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 @@ -131,7 +132,7 @@ jobs: sudo apt-get install libgmp-dev python3-dev libz3-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 + wget -O - -c 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 - name: Install Dependencies if: matrix.os == 'macos' @@ -139,7 +140,7 @@ jobs: brew install gmp python3 z3 python3 -m pip install 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 + 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: Configure run: cmake --preset=ci-${{ matrix.os }} diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 18d35733..19fa29f0 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -10,6 +10,7 @@ on: env: LIEF_VERSION: 0.12.3 + SLEIGH_VERSION: 10.2.2 jobs: @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index c7be0169..e55260e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,15 +155,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 "$" 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 "$" CACHE PATH "Sleigh compiler executable") endif() macro(maat_sleigh_compile ARCH_DIR ARCH) diff --git a/src/third-party/sleigh/native/sleigh_interface.cpp b/src/third-party/sleigh/native/sleigh_interface.cpp index e31b5702..cf8a884b 100644 --- a/src/third-party/sleigh/native/sleigh_interface.cpp +++ b/src/third-party/sleigh/native/sleigh_interface.cpp @@ -296,6 +296,9 @@ class TranslationContext TranslationContext(maat::Arch::Type a, const std::string& slafile, const std::string& pspecfile): arch(a) { + AttributeId::initialize(); + ElementId::initialize(); + if (not loadSlaFile(slafile.c_str())) { throw runtime_exception(Fmt() << "Sleigh: failed to load slafile: " << slafile >> Fmt::to_str); diff --git a/src/third-party/sleigh/sleigh-cmake b/src/third-party/sleigh/sleigh-cmake index 759fe7ff..ded4e6ac 160000 --- a/src/third-party/sleigh/sleigh-cmake +++ b/src/third-party/sleigh/sleigh-cmake @@ -1 +1 @@ -Subproject commit 759fe7ff76fcd3fbafa0a7ce38a824c19ae80aca +Subproject commit ded4e6ac03e43ca97442537c6ea236d29e171eda