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

Remove gflags #588

Merged
merged 23 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
65b6451
bc: Remove deprecated `Find[Host, Target]SemanticsBitcodeFile` functi…
lkorenc Apr 10, 2022
140aba1
bc: Refactor list of default search paths of bitcode files.
lkorenc Apr 10, 2022
3162b9b
bc: Add function that checks if there is a semantics bc file in given…
lkorenc Apr 10, 2022
71d3f31
bc: Use std::filesystem when searching for bitcode semantics file.
lkorenc Apr 10, 2022
bed40bc
bc: Change `FindSemanticsBitcodeFile` to no longer use global state.
lkorenc Apr 10, 2022
6af72c6
bc:util: Wrap return type of `FindSemanticsBitcodeFile` in optional.
lkorenc Apr 10, 2022
65c8305
bc:util: Remove extra overload of `LoadArchSemantics`.
lkorenc Apr 10, 2022
9337634
bc:util: Add fallback option to use compile time paths when loading s…
lkorenc Apr 10, 2022
2994ecc
bc:util: Add search path argument to `LoadArchSemantics`.
lkorenc Apr 10, 2022
b8ce780
bc:util: Add missing documentation.
lkorenc Apr 10, 2022
21c11ab
bc:util: Change message that semantics are being loaded from LOG to D…
lkorenc Apr 10, 2022
0af8362
bc:util: Remove semantics_search_path command line flag.
lkorenc Apr 10, 2022
6cf9cfa
bc:util: No longer use arch cmd flag in Util.cpp.
lkorenc Apr 10, 2022
0923f6e
bc:util: Add missing implementation of `LoadArchSemantics` overload.
lkorenc Apr 10, 2022
5e46858
treewide: Remove arch, os command line flags.
lkorenc Apr 10, 2022
3c06d00
bin:lift: Reflect changes in remill API.
lkorenc Apr 10, 2022
c8e058c
test: Reflect changes in remill api.
lkorenc Apr 12, 2022
e24f934
bc:util: Use std::filesystem::path in place of std::string in some apis.
lkorenc Apr 12, 2022
2dd2746
bc:util: Deprecate api of LoadModuleFromFile, add one with filesystem…
lkorenc Apr 12, 2022
5c8cf43
bc:util: Add VerifyModuleMsg function.
lkorenc Apr 12, 2022
df7e433
bin:lift: Reflect change in IntrinsicTable ctors.
lkorenc Apr 14, 2022
1501f02
CI: Install g++-8 on ubuntu to get access to std::filesystem.
lkorenc Apr 14, 2022
e91f18e
Remove Ubuntu 18.04
ekilmer Apr 14, 2022
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
22 changes: 4 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
fail-fast: false
matrix:
image:
- { name: 'ubuntu', tag: '18.04' }
- { name: 'ubuntu', tag: '20.04' }
llvm: ['12', '13']

Expand All @@ -40,7 +39,9 @@ jobs:

- name: Build with build script
shell: bash
run: ./scripts/build.sh --llvm-version ${{ matrix.llvm }}
run: |
sudo apt-get update && sudo apt-get install g++-8
./scripts/build.sh --llvm-version ${{ matrix.llvm }}
- name: Build with build-presets script
shell: bash
run: |
Expand Down Expand Up @@ -179,27 +180,12 @@ jobs:

- name: Group the packages by platform
run: |
zip -r9 remill_ubuntu-18.04_packages.zip \
ubuntu-18.04*

zip -r9 remill_ubuntu-20.04_packages.zip \
ubuntu-20.04*

zip -r9 remill_macos-11_packages.zip \
macos-11*

- name: Upload the Ubuntu 18.04 packages
uses: actions/upload-release-asset@v1

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: remill_ubuntu-18.04_packages.zip
asset_name: remill_ubuntu-18.04_packages.zip
asset_content_type: application/gzip

- name: Upload the Ubuntu 20.04 packages
uses: actions/upload-release-asset@v1

Expand Down Expand Up @@ -230,7 +216,7 @@ jobs:
strategy:
matrix:
llvm: ["12", "13"]
ubuntu: ["18.04"]
ubuntu: ["20.04"]
steps:
- uses: actions/checkout@v2
- name: Build LLVM ${{ matrix.llvm }} on ${{ matrix.ubuntu }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Choose your LLVM version
ARG LLVM_VERSION=13
ARG ARCH=amd64
ARG UBUNTU_VERSION=18.04
ARG UBUNTU_VERSION=20.04
ARG DISTRO_BASE=ubuntu${UBUNTU_VERSION}
ARG BUILD_BASE=ubuntu:${UBUNTU_VERSION}
ARG LIBRARIES=/opt/trailofbits
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If you are experiencing undocumented problems with Remill then ask for help in t

## Supported Platforms

Remill is supported on Linux platforms and has been tested on Ubuntu 14.04, 16.04, and 18.04. Remill also works on macOS, and has experimental support for Windows.
Remill is supported on Linux platforms and has been tested on Ubuntu 20.04. Remill also works on macOS, and has experimental support for Windows.

Remill's Linux version can also be built via Docker for quicker testing.

Expand Down Expand Up @@ -55,7 +55,7 @@ Remill now comes with a Dockerfile for easier testing. This Dockerfile reference

The Dockerfile allows for quick builds of multiple supported LLVM, architecture, and Linux configurations.

Quickstart (builds Remill against LLVM 12 on Ubuntu 18.04 for AMD64):
Quickstart (builds Remill against LLVM 12 on Ubuntu 20.04 for AMD64):

Clone Remill:
```shell
Expand All @@ -69,7 +69,7 @@ Build Remill Docker container:
# do the build
docker build . -t remill \
-f Dockerfile \
--build-arg UBUNTU_VERSION=18.04 \
--build-arg UBUNTU_VERSION=20.04 \
--build-arg ARCH=amd64 \
--build-arg LLVM_VERSION=12
```
Expand Down
13 changes: 9 additions & 4 deletions bin/lift/Lift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@
#include <string>
#include <system_error>

DECLARE_string(arch);
DECLARE_string(os);
DEFINE_string(os, REMILL_OS,
"Operating system name of the code being "
"translated. Valid OSes: linux, macos, windows, solaris.");
DEFINE_string(arch, REMILL_ARCH,
"Architecture of the code being translated. "
"Valid architectures: x86, amd64 (with or without "
"`_avx` or `_avx512` appended), aarch64, aarch32");

DEFINE_uint64(address, 0,
"Address at which we should assume the bytes are"
Expand Down Expand Up @@ -252,14 +257,14 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}

std::unique_ptr<llvm::Module> module(remill::LoadArchSemantics(arch));
std::unique_ptr<llvm::Module> module(remill::LoadArchSemantics(arch.get()));

const auto state_ptr_type = arch->StatePointerType();
const auto mem_ptr_type = arch->MemoryPointerType();

Memory memory = UnhexlifyInputBytes(addr_mask);
SimpleTraceManager manager(memory);
remill::IntrinsicTable intrinsics(module);
remill::IntrinsicTable intrinsics(module.get());
remill::InstructionLifter inst_lifter(arch, intrinsics);
remill::TraceLifter trace_lifter(inst_lifter, manager);

Expand Down
3 changes: 0 additions & 3 deletions include/remill/BC/IntrinsicTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ namespace remill {

class IntrinsicTable {
public:
inline explicit IntrinsicTable(const std::unique_ptr<llvm::Module> &module)
: IntrinsicTable(module.get()) {}

explicit IntrinsicTable(llvm::Module *module);

llvm::Function *const error;
Expand Down
38 changes: 23 additions & 15 deletions include/remill/BC/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
// clang-format on

#include <array>
#include <filesystem>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
Expand Down Expand Up @@ -148,20 +150,25 @@ llvm::GlobalVariable *FindGlobaVariable(llvm::Module *M, std::string_view name);

// Try to verify a module.
bool VerifyModule(llvm::Module *module);
// Returns diagnostic message if verify failed.
std::optional<std::string> VerifyModuleMsg(llvm::Module *module);

// Parses and loads a bitcode file into memory.
std::unique_ptr<llvm::Module>
LoadModuleFromFile(llvm::LLVMContext *context,
std::string_view file_name,
bool allow_failure = false) __attribute__((__deprecated__));

std::unique_ptr<llvm::Module> LoadModuleFromFile(llvm::LLVMContext *context,
std::string_view file_name,
bool allow_failure = false);
std::filesystem::path file_name);

// Loads the semantics for the `arch`-specific machine, i.e. the machine of the
// code that we want to lift.
std::unique_ptr<llvm::Module> LoadArchSemantics(const Arch *arch);

inline std::unique_ptr<llvm::Module>
LoadArchSemantics(const std::unique_ptr<const Arch> &arch) {
return LoadArchSemantics(arch.get());
}
// `sem_dirs` is forwarded to `FindSemanticsBitcodeFile`.
std::unique_ptr<llvm::Module>
LoadArchSemantics(const Arch *arch,
const std::vector<std::filesystem::path> &sem_dirs);

// Store an LLVM module into a file.
bool StoreModuleToFile(llvm::Module *module, std::string_view file_name,
Expand All @@ -171,15 +178,16 @@ bool StoreModuleToFile(llvm::Module *module, std::string_view file_name,
bool StoreModuleIRToFile(llvm::Module *module, std::string_view file_name,
bool allow_failure = false);

// Find the path to the semantics bitcode file associated with `FLAGS_arch`.
std::string FindTargetSemanticsBitcodeFile(void) __attribute__((deprecated));

// Find the path to the semantics bitcode file associated with `REMILL_ARCH`,
// the architecture on which remill is compiled.
std::string FindHostSemanticsBitcodeFile(void) __attribute__((deprecated));

// Find a semantics bitcode file for the architecture `arch`.
std::string FindSemanticsBitcodeFile(std::string_view arch);
// Default compile-time created list of directories is searched.
std::optional<std::filesystem::path> FindSemanticsBitcodeFile(std::string_view arch);
// List of directories to search is provided as second argument - default compile time
// created list is used as fallback only if `fallback_to_defaults` is set.
// A "shallow" search happens, searching for file `arch` + ".bc".
std::optional<std::filesystem::path>
FindSemanticsBitcodeFile(std::string_view arch,
const std::vector<std::filesystem::path> &dirs,
bool fallback_to_defaults=true);

// Return a pointer to the Nth argument (N=0 is the first argument).
llvm::Argument *NthArgument(llvm::Function *func, size_t index);
Expand Down
5 changes: 0 additions & 5 deletions lib/Arch/Arch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@
#include "remill/BC/Version.h"
#include "remill/OS/OS.h"

DEFINE_string(arch, REMILL_ARCH,
"Architecture of the code being translated. "
"Valid architectures: x86, amd64 (with or without "
"`_avx` or `_avx512` appended), aarch64, aarch32");

namespace remill {
namespace {

Expand Down
Loading