Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Anvill building with LLVM 15 #330

Merged
merged 13 commits into from
Nov 18, 2022
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
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ jobs:
- { name: "ubuntu", tag: "20.04" }
binja:
- { channel: "headless", version: "3.1.3479" }
llvm: ["14"]
cxxcommon_version: ["v0.2.10"]
llvm: ["14", "15"]
cxxcommon_version: ["v0.2.16"]

runs-on: ubuntu-20.04
container:
Expand Down Expand Up @@ -432,8 +432,8 @@ jobs:
fail-fast: false
matrix:
os: ["macos-11"]
llvm: ["14"]
cxxcommon_version: ["v0.2.10"]
llvm: ["14", "15"]
cxxcommon_version: ["v0.2.16"]

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

Expand Down Expand Up @@ -781,7 +781,7 @@ jobs:

strategy:
matrix:
llvm: ["14"]
llvm: ["14", "15"]
ubuntu: ["20.04"]
binja:
- { channel: "headless", version: "3.1.3479" }
Expand Down
2 changes: 1 addition & 1 deletion .remill_commit_id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
65817f05b86ed7c215ea5871325ff0461a467dea
d5c50357287cae0072938477b3b525bafcce8069
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG LLVM_VERSION=14
ARG LLVM_VERSION=15
ARG ARCH=amd64
ARG UBUNTU_VERSION=20.04
ARG CXX_COMMON_VERSION=0.2.10
ARG CXX_COMMON_VERSION=0.2.16
ARG DISTRO_BASE=ubuntu${UBUNTU_VERSION}
ARG BUILD_BASE=ubuntu:${UBUNTU_VERSION}
ARG LIBRARIES=/opt/trailofbits
Expand All @@ -13,7 +13,7 @@ ARG UBUNTU_VERSION
ARG LIBRARIES
ARG LLVM_VERSION
ARG CXX_COMMON_VERSION
ARG DEBIAN_FRONTEND=noninteractive
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -qqy --no-install-recommends git libdbus-1-3 curl unzip python3 python3-pip python3.8 python3.8-venv python3-setuptools xz-utils cmake && \
rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -62,7 +62,7 @@ RUN cmake -G Ninja -B build -S /dependencies/remill \
-DCMAKE_VERBOSE_MAKEFILE=True \
-DVCPKG_ROOT=/dependencies/vcpkg_ubuntu-${UBUNTU_VERSION}_llvm-${LLVM_VERSION}_amd64 \
&& \
cmake --build build --target install
cmake --build build --target install

# Source code build
FROM deps AS build
Expand Down
2 changes: 2 additions & 0 deletions bin/Decompile/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ int main(int argc, char *argv[]) {
remill::GetReference(maybe_buff);

llvm::LLVMContext context;
#if LLVM_VERSION_NUMBER < LLVM_VERSION(15, 0)
context.enableOpaquePointers();
#endif
llvm::Module module("lifted_code", context);

auto maybe_spec =
Expand Down
43 changes: 0 additions & 43 deletions include/anvill/Passes/ConvertIntegerToPointerOperations.h

This file was deleted.

20 changes: 0 additions & 20 deletions include/anvill/Transforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,26 +190,6 @@ void AddLowerRemillMemoryAccessIntrinsics(llvm::FunctionPassManager &fpm);
// instructions.
void AddLowerTypeHintIntrinsics(llvm::FunctionPassManager &fpm);

//// Anvill-lifted bitcode operates at a very low level, swapping between integer
//// and pointer representations. It is typically for just-lifted bitcode to
//// perform integer arithmetic on addresses, then cast those integers into
//// pointers in order to do a `load` or `store`. This happens because the bitcode
//// we get from Remill uses memory access intrinsics, which abstract over the
//// target program's address space and model memory loads/stores in terms of
//// intrinsic function calls operating on integer addresses. When these intrinsic
//// calls are lowered into `load` and `store` instructions by
//// `LowerRemillMemoryAccessIntrinsics`, we are left with a mixed bag in integer
//// arithmetic and then `inttoptr` casts.
////
//// Ideally, we want to comprehensively brighten all integer operations that
//// produce pointers into pointer operations. For example, integer arithmetic
//// should instead become `getelementptr` instructions, where possible, which
//// model pointer arithmetic at a higher level.
////
//// This function attempts to apply a battery of pattern-based transforms to
//// brighten integer operations into pointer operations.
void AddConvertIntegerToPointerOperations(llvm::FunctionPassManager &fpm);

// Transforms the bitcode to eliminate calls to `__remill_function_return`,
// where appropriate. This will not succeed for all architectures, but is
// likely to always succeed for x86(-64) and aarch64, due to their support
Expand Down
3 changes: 1 addition & 2 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ protobuf_generate_cpp(
# `.cpp` file.
set(anvill_passes
ConvertAddressesToEntityUses
ConvertIntegerToPointerOperations
ConvertMasksToCasts
ConvertSymbolicReturnAddressToConcreteReturnAddress
ConvertXorsToCmps
Expand Down Expand Up @@ -217,7 +216,7 @@ if(ANVILL_ENABLE_INSTALL)
PUBLIC_HEADER DESTINATION
"${CMAKE_INSTALL_INCLUDEDIR}/anvill"
)

install(
FILES
${anvill_passes_HEADERS}
Expand Down
2 changes: 0 additions & 2 deletions lib/Optimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ void OptimizeModule(const EntityLifter &lifter, llvm::Module &module) {
// makes code easier to read and analyze. This is a fairly narrow optimization
// but it comes up often enough for lifted code.

// TODO(alex): Need to rewrite this pass to somehow not rely on typed pointers.
// AddConvertIntegerToPointerOperations(fpm);
AddConvertAddressesToEntityUses(fpm, xr, pc_metadata_id);
AddBranchRecovery(fpm);

Expand Down
Loading