68 Commits

Author SHA1 Message Date
wizardengineer bfd4b05a8e [DOCS] Included doxygen for better code documentation 2025-12-02 08:59:05 -05:00
Duncan Ogilvie bed042f2d9 Fix signature of memory_f80 intrinsics 2025-11-24 12:04:51 -05:00
Duncan Ogilvie 6892375a97 Add missing gflags dependency in remillConfig.cmake (#726) 2025-11-21 10:20:28 -05:00
Duncan Ogilvie 4689097a21 Add standalone GitHub Actions 2025-11-05 20:46:01 -05:00
Duncan Ogilvie ac78aa9dca Switch to standalone sysroot for semantics compilation 2025-11-05 20:46:01 -05:00
Duncan Ogilvie 658a1806a7 No optimization flags to remill_settings and default CMAKE_BUILD_TYPE=Debug 2025-11-05 20:46:01 -05:00
Duncan Ogilvie 4bc1b54d6d Switch back to C++17 2025-11-05 20:46:01 -05:00
Duncan Ogilvie 37ad2b1efe Remove unused Z3 dependency 2025-11-05 20:46:01 -05:00
cctv130 b6fc70f0f4 CMake: update to C++20, clean up properties, optimize fetch content (#721)
- Enable C++20 on both Windows and Linux
- Remove unnecessary set_property calls to silence LOCATION warnings
- Replace duplicate -fPIC flags with INTERFACE_POSITION_INDEPENDENT_CODE
- Set FETCHCONTENT_BASE_DIR to speed up sleigh and ghidra-fork downloads/builds
- fixed: Does not match the generator used previously: Unix Makefiles,use ninja instead
2025-09-05 17:55:23 -04:00
cctv130 e272b48e84 fix: windows clang build (#719)
* Update settings.cmake

Fix the issue where debugging on Windows in VSCode doesn’t work

* fix: windows clang build

The following flags are not supported in non-MSVC environments
/EHsc /wd4141 /wd4146 /wd4180 /wd4244 /wd4258 /wd4267 /wd4291
/wd4345 /wd4351 /wd4355 /wd4456 /wd4457 /wd4458 /wd4459 /wd4503
/wd4624 /wd4722 /wd4800 /wd4100 /wd4127 /wd4512 /wd4505 /wd4610
/wd4510 /wd4702 /wd4245 /wd4706 /wd4310 /wd4701 /wd4703 /wd4389
/wd4611 /wd4805 /wd4204 /wd4577 /wd4091 /wd4592 /wd4324

Update cmake_minimum_required(VERSION 3.21) to remove CMake warning.
2025-08-18 17:42:31 -04:00
cctv130 6185727cda Update settings.cmake (#717)
Fix the issue where debugging on Windows in VSCode doesn’t work
2025-07-23 09:47:11 -04:00
2over12 0183248218 llvm 17 fixes (#688)
* llvm 17 fix

* more instances

* more fixes

* add inline

* bump ci

* bump cxx common

* add 17 case

* bump xcode version

* macos 13

* xcode 15

* bump docker to llvm 17

* change actual matrix value

* opaque pointers are the default now

* actually remove the option

* debug size

* install tree

* fix install

* fix install?

* get tree after

* build dir?

* tree above

* accumulate

* bug?

* try to remove intermediate packaging

* fix opt

* only inline

* give up on function inlining

* llvm 17

* remove debug tasks

* Update scripts/build.sh

Co-authored-by: William Tan <1284324+Ninja3047@users.noreply.github.com>

* Revert "Update scripts/build.sh"

This reverts commit 6c727a539d.

* debug

* try clear out old build

* retest

* try to save more space

* up

* Clear space and don't use cxx-common docker image (#689)

* Clear space and don't use cxx-common docker image

* Run on all PRs

* Fix perms

* Remove some unnecessary apt commands

* Install LLVM version as root

* Allow writing to external target

* Build before running tests

* Install with sudo

* Simplify with container volume mounts

---------

Co-authored-by: William Tan <1284324+Ninja3047@users.noreply.github.com>
Co-authored-by: Eric Kilmer <eric.d.kilmer@gmail.com>
2023-10-12 16:37:45 -04:00
Eric Kilmer 396e228e93 Fix Linux AArch64 compilation for SPARC32 runtime (#674)
* Fix Linux AArch64 compilation for SPARC32 runtime

Issue with conflicting compilation target(s).

Tests fail though.
2023-05-10 18:38:18 -04:00
William Tan a1a93bbab2 C standard already set by cmake so we shouldn't set it again here 2023-04-04 09:47:14 -04:00
Alex Cameron fb018c96e9 PowerPC Support (#645)
* Add skeleton for PPC

* Copyright notices

* Fill in some details for the PPC arch

* Start building a (wrong) PPC runtime

* Begin populating state structure

* First pass for EIS state structure

* Map registers to Sleigh register names

* More fixes

* add optional param

* Create handle unsupported and invalid instruction isels

* Correct typo

* Get a basic `remill-lift` invocation running without failure

* Fix capitalisation

* Set vle context reg

* Fix SleighDecoder signatures

* Set VLE context register in the Sleigh engine in addition to our
internal context reg mapping

* Capitalize reg names

* Add the flag registers for XER and CR

* Rename bitflag structures in PPC state

* PPC Sleigh patches (#643)

* Modified sleigh patch script to generate patches for multiple .sinc files

* update README with new examples of sleigh patch script invocation

* add ppc register definition

* add ppc sleigh patches

* fix issue with remill_insn_size definition

* regenerate sleigh patches for PPC

* update CMakeLists.txt to include PPC patches

* Add TEA signal as a register in the PPC state

* Uppercase the stack pointer register name

* Fix PPC instruction sizes

* initial PPC tests

* remove duplicate tests

* fix tests for e_stmvgprw/e_ldmvgprw

* add tests for loading/storing from special registers

* add tests with internal conditionals in pcode

* fix for pc reg and addr width not being the same... I suspect this issue is going to come up elsewhere

* add heuristic for flow from normal intrainstruction flow

* rework tests to allow testing for different sized registers

* add tests for overflow and record add

* fix bug with log printout

* add intrafunction control flow lifting

* handle edge case where there is no pcode op at the zero index

* Fix another inconsistency with mismatching address and PC reg size

* Allocate unique ptrs in the entry block

* Fix `INT_LEFT` and `INT_RIGHT` impl where shift exceeds bit width

* fix supiece lift?

* Add PPC emulate instruction to hyper call

* fix for pc reg and addr width not being the same... I suspect this issue is going to come up elsewhere

* add heuristic for flow from normal intrainstruction flow

* add intrafunction control flow lifting

* handle edge case where there is no pcode op at the zero index

* Fix another inconsistency with mismatching address and PC reg size

* fix supiece lift?

* Allocate unique ptrs in the entry block

* Fix `INT_LEFT` and `INT_RIGHT` impl where shift exceeds bit width

* fix int2float semantics

should use appropriate sized float based on the output size

* add tests for lifting int2float

* fix INT_{LEFT,RIGHT} semantics

should be `ICmpSGE` instead of `ICmpSGT`

* add cr0-7 registers

* fix formatting

* fix conditional branch test

* add test for compare

* re-enable rotate left word immediate and mask test

* genericize TestSpecOutput

* explicit instruction data size

* add test for syscall/callother (disabled)

* add tests for store/load word

* add test to convert from float to int

* specify intrinsic arg type, fixes null deref

* Add PPC emulate instruction to hyper call

* add headers + formatting

* remove old comment

* Map CRALL register

* Add basic LLVM data layout that specifies 32-bit addresses

* Remove unused variables

* convert auto* to auto when possible

* RegisterPrecondition -> RegisterCondition

* fix variable name

* convert any to variant

* use std::move

* bump to c++20, use concepts

* set arch in constructor since class isn't generic anyways

* formatting

* make type aliases

* bump cxx-common

* add comment

* clang format

* throw exception if register not found

* use const ref

* use shorthand for lambda capture values

* Add more detail to data layout to include proper stack alignment

* Compare to the correct size for SUBPIECE impl

* Add Sleigh message to error

* throw exception in else case

* throw runtime error if register value has incorrect type

* use reference instead of value

* get rid of unnecessary type alias

* formatting

* Propagate VLE context reg value into Sleigh

* Remove unnecessary whitespace

* Remove stale TODO and NOTE comments

* add additional parameter to test runner to specify decoding context

* drop llvm 14, bump macos version

* bump cxx-common, fix ci.yml mac build

* add test for unconditional relative negative branch

* add missing space to pcode debug log

* fix bug due to unordered_map, iteration order matters

* add error log in case we aren't able to adjust PC value

* use helper for getting register reference

* Revert "add optional param"

This reverts commit 51ed49f8cf.

* Remove remaining LLVM 14 compatibility code and configuration

* Add padding between CR and XER flags

* Use `enum class`

* Remove void cast

* Remove unnecessary variable

* Use initialiser lists where appropriate

* Remove redundant `else`

* Prefer `CHECK` over `assert`

* Polish PowerPC function initialisation with lambda

* zero out xer_so to fix tests

* log error when we see claim_eq with no usages

* Collapse namespace blocks

* Remove unnecessary `this->`

* Use `auto` where appropriate

* Remove unnecessary `else`

* Use `emplace` over `insert` for `std::map`

Co-authored-by: lkorenc <lukas.korencik@trailofbits.com>

* Use `constexpr` for VLE reg name

* Use module verification util

* Add `VerifyFunction` util and use where applicable

* Extract lambda to improve readability of flow categorisation

* Use type alias for context values

* Introduce type alias for block exit

* Create type alias for optional branch taken

* Refactor `PcodeCFGBuilder`

* Use lambda to avoid conditional mutation

* Extract duplicated bit-shift code generation into helper

* Simplify flow with ternary

* Add `GetBlock` helper

* Rename variables

* Move statement for clarity

* Create helpers for working with Sleigh context register values

* Convert loop to `std::copy`

* Add a comment explaining the use of set to de-duplicate and sort

* Refactor `IntraProcTransferCollector`

* Expose static method to easily use `IntraProcTransferCollector`

* Rename PPC related variables to include address width

* add docs to intrainstructionindex

* remove llvm 14 ifdefs

* don't log error if no claim_eqs were used

* update comments

* Cleanup exit visitors

---------

Co-authored-by: 2over12 <ian.smith@trailofbits.com>
Co-authored-by: William Tan <1284324+Ninja3047@users.noreply.github.com>
Co-authored-by: lkorenc <lukas.korencik@trailofbits.com>
2023-02-02 10:05:28 -05:00
Alex Cameron a8ead7b584 Move to explicitly setting CMake toolchain file (#639)
* Move to CMake toolchain file

* Update docs and scripts

* Fix `build.sh` to manually specify the `VCPKG_TARGET_TRIPLET`

* Use x64 instead of amd64 in the VCPKG target triplet

* Remove references to VCPKG in Remill config

* Update cmake/remillConfig.cmake.in

Co-authored-by: Eric Kilmer <eric.d.kilmer@gmail.com>

* Update cmake/remillConfig.cmake.in

Co-authored-by: Eric Kilmer <eric.d.kilmer@gmail.com>

* Fix suggested edit

* Stop specifying compilers in CMake presets

* Fix typo

* Remove trailing comma from JSON file

Co-authored-by: Eric Kilmer <eric.d.kilmer@gmail.com>
2022-12-02 15:45:48 +11:00
Alex Cameron d5c5035728 Get Remill building with LLVM 15 (#631)
* Get Remill building with LLVM 15

* Add missing header for x86 lift test

* Fix `enableOpaquePointers` calls

* Define a non-extern `__remill_state` in each Instructions module

* Remove `__remill_state` variables in tests

* Update build script to support LLVM 15

* Build with LLVM 15 in CI

* Bump CXX Common version

* Update Docker script

* Add comment explaining the definition of the state variable

* Correct wording
2022-10-30 16:42:23 -04:00
Alex Cameron 561990f2a4 Suppress warnings from llvm-link (#626) 2022-09-02 12:31:34 -04:00
William Tan 3f69b7df1b update FindZ3.cmake, remove testz3.cpp 2022-08-29 13:17:48 -04:00
William Tan 8f62b657ce update git_watcher.cmake to latest, use git-describe for version 2022-08-29 13:16:19 -04:00
William Tan 1cb4bb6001 remove thirdparty interfaces + remove llvm jank 2022-08-29 13:11:12 -04:00
William Tan 56887119a4 check for the string arm64 in addition to aarch64
m1 macs for some reason use arm64 instead of aarch64 on linux
2022-08-24 13:38:03 -04:00
Francesco Bertolaccini 5ded7b40e8 Add Sleigh install targets (#621) 2022-08-23 09:03:47 -04:00
Alex Cameron fe6d4276cd Provide initial definition for __remill_sync_hyper_call (#611)
* Create initial implementation of `__remill_sync_hyper_call`

* Fill in a few more cases

* Use `state.addr_to_load` for LGDT and LIDT operands

* Fix variable names

* Cross-compile the Remill runtimes

* Create temp variable for `lgdt` and `lidt` handling

* Add intrinsics for SPARC emulate instruction calls

* Create intrinsics for remaining hyper calls

* Remove `__remill_sync_hyper_call` implementations in tests

* Create the target triple based on the provided arch

* Provide ARCH parameter for SPARC archs

* CMake formatting

* Switch the conditions around

* Adjust target triple

* Cross-compile the hyper calls and then link them into the runtime

* Cleanup

* Prefix int types with namespace

* Include `<limits>`

* Fix `lgdt` and `lidt` handling

* Mark new intrinsics as "used"

* Add placeholder intrinsic definitions to tests

* Complete list of intrinsic definitions

* Mark hyper call definition with `always_inline`

* Use `_BitInt` if available

* Use `__builtin_unreachable` instead of `abort`

* Leave comment explaining `always_inline` attribute
2022-08-22 13:02:00 -04:00
William Tan 9ea5a65f3e Fix typo when parsing z3 version from headers 2022-08-08 10:39:47 -04:00
2over12 eef338df00 Ian/sleigh support rebased (#607)
* cmake: Bring in SLEIGH as a dependency

* sleigh: Boilerplate for adding a new arch

* sleigh: Begin passing instruction sequences into SLEIGH

* cmake: Rename target to be X86 specific

* sleigh: Copy over more X86 runtime code and get things running

* sleigh: Begin populating operands in the returned instruction

* sleigh: Set instruction category for a few opcodes

* sleigh: Initial attempt at generating LLVM IR for P-Code

* sleigh: Implement enough opcodes to run the `sleigh-lift` example

* sleigh: Get things building with an up-to-date Remill tree

* sleigh: Use the new SLA helpers

* sleigh: Clear operands between invalid lifts

* added thumb2

* stub out thumb

* need to refactor to relift the instruction

* factored lifter out of handler:

* allow lifters to decide wether to use sleigh

* relift bytes

* fixed both lifter contexts

* hey a copy lifted :)

* need to refactor to use parameterptrs to unify interface to memory

* refactored to use parameter abstraction

* lift at correct location

* add control flow to pc and next

* add categories mostly

* fix direct semantics add cbranch

* track cbranch metavar also lift returns

* cmake: Fix SleighArch.h path

* sleigh: Support more binary ops

* sleigh: Implement ZEXT

* sleigh: Support SEXT op

* sleigh: Implement 2COMP and INT_NEGATE

* mutex around parsing sleigh specs

* fixed typos in custom image

* added handling for exceptions, need to fix issue with xml parsing

* sleigh: Support boolean binops

* sleigh: Support float binary ops

* sleigh: Support a few more float pcode ops that require LLVM intrinsics

* sleigh: Add entries for ops that require overflow intrinsics

* sleigh: Implement more float unary ops

* sleigh: Reduce duplication in ops that require float intrinsics

* expose mutex

* fix fallthough and format of control flow resolution

* sleigh: Support CARRY, SCARRY and SBORROW

* Remove duplicate THUMB2 arch in enum

* Remove duplicate THUMB2 entry in archnames array

* Implement STORE op

* Fix incorrect index

* Support PIECE and SUBPIECE ops

* Support remaining set of PCode ops in the base set. Now to do the
pseudo ops.

* Implement additional ops

* Partially implement a few pseudo ops + a few missing from the docs

* Fix the variadic op condition

* Include <mutex> to build on Linux

* stop lying about insn categories/functions

* set function insns with mnemonic

* fix fallthrough for ind calls

* More virtualization, fewer pimples

* switch back to x86 normal

* Fix off-by-eight issue with ADR in AArch32

* Get rid of mutex in sleigh, make a globally-available remill locker for handling sleigh issues

* CHange allow 32 bit shift to true, not sure if valid but oh well

* Use the node size when creating constants

* fix memory

* store memory state back

* fix calling intrinsic table

* fix comp sizes

* load pspec data

* add pspec names

* add differential test

* fix tests start pretty printer

* add runner

* added really slow memory

* add comparison of memory state

* do reset

* fix uninitialized module

* fixed lift crash

* add amd64 runtime

* unfix fs, gs, and pc

* added whitelist file

* fix memory to update state with uninitialized reads

* better pc handling

* add main.py

* x86 compiles

* fixup patch generation

* add replacements for mem locs and constant varnodes, now need to handle special branches

* added replacement for direct branches

* add context clears

* add handler for claim_eq

* comment out clears for now

* added ambiguity check

* handle duplicate names in same constructor

* mantain sleigh invariant of 1 or 0 in flag

* added uint8t memory intrinsics

* extend shift value when needed

* handle cmovs

* update patch generation

* removed deprecated load

* fix for returned type

* builds

* add logging

* add comment on why not compute GEPAccessors in Arch.cpp

* enable opaque pointers

* fix memory state update

* add mem_16 impls

* not preserve 1 bit width

* fix CR changes

* fix L and R for shift operands bigger than target

* revert use after move

* more CR fixes

* remove lookahead... lets try this again

* rework to create internal function that is inlined to allow for early return control flow

* terminate conditionally

* avoid large iteration counts for .REP insns

* fix patch for rep insns

* handle inst_start in patches

* handle inserting insn_size constructor outside of macros

* hint size of insn_size

* refactor bool functions to make more sense

* just use ;

* remove delete of operands when fail to lift

* remove copy and paste

* remove unused deps

* add patch file to sleigh list

* prep git user

* refer to checkout

* maybe shell type?

* fix layout

* fix format again

* fix

* update dockerfile

* fix gitwatcher to point to current project:

* Revert "fix gitwatcher to point to current project:"

This reverts commit 711da11e6f.

* fix ninja builds

* disable sleigh tests

* remove duplicates

* refactor

* fix non reset context in sleigh lifter

* remove debugging prints

* wrote CI runner

* add handwritten test infra

* refactor to allow sharing JIT test running between differential tester and hand written tests

* allow for internal ownership of semantics module

* handwritten test framework

* fix hand written tests

* pc rel testruns

* add pc rel regression

* fix script for pc rel

* fix names for priors to ignore whitespace

* fix action ops

* add xor to repl ops

* add xors to patch

* add arm patch to build

* fix test for semantics

* allow cross platform tests to run

* add running diff tester

* 2 underscores?

* run tests on macos too

* fix command

* fix whitelist path

* remove unused test data

* install python deps for differential tests

* update script to git patches

* update patches to git format

* attempt to fixup patches

* update ref for sleigh

* install test depends docker

* point docker to correct dir

* install pydeps in macos too

* initialize address field

* exports, also tag master on sleigh

* add comments and whitelist undefined value OF in shifts

* add of accessor to whitelist impl

* change variables to non alloca and remove dead code

* remove dead code:

* replace dump with print

* code quality

* make non null into ref

* type alias

* remove allocas from unit tests

* Address copypasta comment.

* Address PR comment.

* Address PR comment.

* fix build

* unify diff modules into single structure

* remove extra newline

* lock sleigh to specific commit

* remove new lines

* remove useless fenv headers

* caps

* copyright notices

* update more copyright

* fix reviews

* early returns out of accessors

* early return

* auto

* return getarchbyname

* insert register rather than modify reference

* just return

* only log in the assembly logger

* prefer functional style

* remove commented code

* move defaults to header

* that's not how arch switches work in pcode

* informative names

* simplify control flow in fill

* early return

* fix early exit condition

* refactor register default into function

* make one liner

* early return

* unary instead of unop

* construct pair with {}

* move cbranch into binops instead of integer binops

* refactor float ops into getter

* factor out float type

* early return

* separate out callother handling

* do pointer extensions cleaner

* braces

* add private headers to lifters

* refactor redirecting control flow out of instruction

* use constant check function

* remove has_value

* structure for preconditions

* return success when applying eq claim

* expose arch base and move shared functionality into x86 base

* dedup x86 code

* dedup aarch32

* remove needless assignment, also remove else after an if that returns

Co-authored-by: Alex Cameron <asc@tetsuo.sh>
Co-authored-by: Artem Dinaburg <artem@trailofbits.com>
Co-authored-by: Peter Goodman <peter.goodman@gmail.com>
2022-07-28 08:46:32 -04:00
2over12 dd14a17cdc Ian/recover flags (#559)
* added cross compile semantics

* sorta fix for m1 macs, shouldnt hardcode macosx version

* added flag intrinsics

* changed ordering for easy compare

* made comparison hints easier to reference

* added neq and eq instrinsics

* added more intrinsics

* added intrinsics to tests
2021-11-19 17:26:26 -05:00
Peter Goodman f5c630a1d3 Fix some cmake issues that I caused, and add some options (#547)
* Fix some cmake issues that I caused, and add some options

* Rename some cmake variables. Use them more.
2021-10-06 01:10:03 -04:00
Peter Goodman 7e723cbb0d Update remillConfig.cmake.in 2021-10-05 22:02:16 -04:00
Peter Goodman b8cb5deba8 Improve usage of remill in submodules 2021-10-05 16:58:56 -04:00
Eric Kilmer e768d25564 Fixup cxx-common links (#519)
Moved the repo from trailofbits to lifting-bits
2021-05-26 12:17:06 -04:00
Eric Kilmer 1b415d616b Use system compiler to build (#516)
* Don't use vcpkg clang to build remill in build script

* Don't manually set compiler within CMakeLists.txt & Fix ccache detection

* Simplify ccache usage

Don't use a macro since we just immediately invoke it

* Turn on CMAKE_ENABLE_EXPORTS to fix tests

Not sure exactly why the updated CMake version affected this, but it
did.

See https://cmake.org/cmake/help/latest/variable/CMAKE_ENABLE_EXPORTS.html#variable:CMAKE_ENABLE_EXPORTS

* Bump number of build jobs in Dockerfile
2021-05-17 15:13:17 -04:00
Eric Kilmer 1caf764da3 Workaround LLVM hardcoded include directory (#513)
These fixes are required for packaging a prebuilt remill that is relocatable/portable with respect to dependencies and their paths---in this case LLVM's include directory path.
2021-05-13 15:51:03 -04:00
Eric Kilmer 142ab2f0aa Fix CMake version info bad quoting (#501)
* Fix quote escaping in commit message

* This is a "Test
message"

* Update to latest cmake-git-version-tracking git_watcher cmake file

Listed permalink to make it easier to diff any future changes
2021-04-03 10:53:09 -04:00
Eric Kilmer 2eaf52ca72 Remove old cxx common logic (#500)
* Remove old cxx-common references

* Test on this branch first

* Revert "Test on this branch first"

This reverts commit 888b584f8a.
2021-04-02 21:21:51 -04:00
Sonya 6322f794d1 New arch support (#461)
* This branch contains support for new architectures.

* Initial start to support for AArch 32

* Progress

* Forgot the new files

* Added all data Integer processing instructions without S + ADDS and started ANDS

* Updated

* Finished Integer Data Processing with three registers, added integer data processing with 2 regs + immediate, started MUL instructions

* UMULL, UMULLS, UMLAL, UMLALS

* Corrected condition for addend or 0 immediate for UMULL/UMLAL + SMULL/SMLAL instructions

* Correct ops in Binary.cpp

* UMAAL

* SMULL, SMULLS, SMLAL, SMLALS + corrected acc was missing shift left in concatination

* Updated decoding instructions based on top level encodings

* Update returns around kDataProcessingRI and kDataProcessingI with comments to explain the correlation to the instruction rep

* Added appropriate inst.category flags to Multiply and accumulate

* Load/Store Word, Unsigned Byte (immediate, literal) && start of Logical Arithmetic (three register, immediate shift)

* Was missing UMAAL DEF_ISEL in Binary.cpp

* AddAddrRegOp

* Logical Arithmetic (three register, immediate shift) without accounting for the possible PC jump

* Made DecodeA32ExpandImm much much smaller

* Replaced some imm ops with AddImmOp calls

* Created AddShiftOp

* Added interpreter for evaluating new PC value at decoding time to handle direct jumps and conditional jumps

* Created EvalPCDest added PC evaluation to Logical Arithmetic Instructions

* AddShiftOp -> AddShiftOp, AddShiftThenExtractOp, AddExtractThenShiftOp

* Cleaned up some formatting, Renamed DecodeA32ExpandImm to ExpandTo32AddImmAddCarry and added a clarifying comment

* Added comment to EvalPCDest for clarity

* Cleaned up some things, updated the decoding semantics and semantics for the logical instructions

* Shortened kLogArithEvaluators and fixed a bug

* Updates from testing instructions

* Fixed DEF_ISEL for pre/post index instructions in MEM.cpp

* Integer Test and Compare (two register, immediate shift)

* Logical Arithmetic (two register and immediate)

* Integer Test and Compare (one register and immediate)

* Added to the top level encoding infrastructure to handle the Data-processing register (register shift) set of instructions and 3 corresponding subsets

* Add structs for the 3 subsets of Data-processing register (register shift)

* Code status before refactoring operand types

* This branch contains support for new architectures.

* Initial start to support for AArch 32

* Progress

* Forgot the new files

* Added all data Integer processing instructions without S + ADDS and started ANDS

* Updated

* Finished Integer Data Processing with three registers, added integer data processing with 2 regs + immediate, started MUL instructions

* UMULL, UMULLS, UMLAL, UMLALS

* Corrected condition for addend or 0 immediate for UMULL/UMLAL + SMULL/SMLAL instructions

* Correct ops in Binary.cpp

* UMAAL

* SMULL, SMULLS, SMLAL, SMLALS + corrected acc was missing shift left in concatination

* Updated decoding instructions based on top level encodings

* Update returns around kDataProcessingRI and kDataProcessingI with comments to explain the correlation to the instruction rep

* Added appropriate inst.category flags to Multiply and accumulate

* Load/Store Word, Unsigned Byte (immediate, literal) && start of Logical Arithmetic (three register, immediate shift)

* Was missing UMAAL DEF_ISEL in Binary.cpp

* AddAddrRegOp

* Logical Arithmetic (three register, immediate shift) without accounting for the possible PC jump

* Made DecodeA32ExpandImm much much smaller

* Replaced some imm ops with AddImmOp calls

* Created AddShiftOp

* Added interpreter for evaluating new PC value at decoding time to handle direct jumps and conditional jumps

* Created EvalPCDest added PC evaluation to Logical Arithmetic Instructions

* AddShiftOp -> AddShiftOp, AddShiftThenExtractOp, AddExtractThenShiftOp

* Cleaned up some formatting, Renamed DecodeA32ExpandImm to ExpandTo32AddImmAddCarry and added a clarifying comment

* Added comment to EvalPCDest for clarity

* Cleaned up some things, updated the decoding semantics and semantics for the logical instructions

* Shortened kLogArithEvaluators and fixed a bug

* Updates from testing instructions

* Fixed DEF_ISEL for pre/post index instructions in MEM.cpp

* Integer Test and Compare (two register, immediate shift)

* Logical Arithmetic (two register and immediate)

* Integer Test and Compare (one register and immediate)

* Added to the top level encoding infrastructure to handle the Data-processing register (register shift) set of instructions and 3 corresponding subsets

* Add structs for the 3 subsets of Data-processing register (register shift)

* Code status before refactoring operand types

* Finished updates off master

* Start of operand refactor

* Finished Expression Operand Support

* Fix the .gitignore to add AArch32 to lib/Arch && removed all extra rrx ops from semantics

* Updated .gitignore again, Added AddShiftRegRegOperand, Updated AddShiftRegImmOperand, Finished Register shift instructions for Integer Test and Compare, Logical Arithmetic, Integer Data Processing

* Updated ROR in AddShiftRegRegOperand

* Created ExtractAndZExtExpr

* Fixed comment formatting in if else statements

* Created RORExpr

* Small fixes

* Small fix in Logical Arithmetic (two register and immediate)

* Corrected AddShiftRegRegOperand and cleaned it up. Split the carry op into a separate function.

* conditional support + Start of Branch instructions

* Created AddExprOp, cleaned up some expressions in reg shifted reg, and updated some occurances of ShiftThenExtractOp with ExtractAndZExtExpr

* Updates from testing register shifted by register value inst

* Fix to ROR in AddShiftRegCarryOperand

* Corrected negation in DecodeCondition

* DecodeCondition edit

* DecodeCondition and AddShiftRegCarryOperand edits

* Updated arch_for_decode to arch

* Halfword Multiply and Accumulate

* Edits from testing Halfword Multiply and Accumulate

* Changed order of operands in Halfword Multiply and Accumulate to better reflect inst format + updated inst errors

* Branch (Imm) & BX/BXL

* Update aarch32 cmake

* cmake update

* CLZ

* Forgot BITBYTE.cpp

* MOVT

* Integer Saturating Arithmetic

* updated semantics in SMLAWh & SMLAh to use Select for setting PSTATE.Q

* Started Load/Store Word, Unsigned Byte (register) & fixed MOV halfword

* Load/Store Word, Unsigned Byte (register)

* Finished testing load/Store Word, Unsigned Byte (register)

* Load/Store Dual, Half, Signed Byte (register)

* Rest of Extra load store: Load/Store Dual, Half, Signed Byte (immediate, literal)

* Finished testing all the Load/store additions

* Signed multiply, Divide

* Cleaned up SExt some

* Saturate Insts and Start of Load Store Multiple - STMDB and LDM (aliases which support PUSH and POP of multiple regs)

* Condensed args in STMDB and LDM semantics

* Rest of Multiple Load/Store that do not execute in a different mode

* Bitfield Extract

* Extend and Add

* fix

* NOP

* Small fix

* Simplified the bit reps in TryMoveSpecialRegisterAndHintsI

* Moved Bitfield extract semantics out of BINARY and into BITBYTE

* Finished correcting S/ZExt and Trunc use

* Ran scripts/format-files to format

* Smoke Test

* Add false delay slot to kCategoryConditionalDirectFunctionCall

* CI: Use single packaging job, add changelog support (#491)

* CI: Add tag handler (#492)

* Delay slot fixes to TraceLifter

Co-authored-by: Peter Goodman <peter.goodman@gmail.com>
Co-authored-by: Alessandro Gario <5714290+alessandrogario@users.noreply.github.com>
2021-02-24 14:01:09 -05:00
Eric Kilmer 671760c474 vcpkg: Support Windows and arm64 (#478)
* Support arm64 default vcpkg triplet

* Add default Windows release triplet support
2021-02-02 13:52:27 -05:00
Eric Kilmer 8739fc6740 Simplify clang find CMake (#472)
* Simpler clang find CMake

* Synchronize vcpkg CMakefile
2021-01-13 21:52:28 -05:00
Eric Kilmer 37741957d6 Support vcpkg dependency management (#463)
First step towards transitioning away from cxx-common's `pkgman.py` dependency management system towards compatibility with and use of vcpkg (https://github.com/microsoft/vcpkg) to manage dependencies.

This commit attempts to support both the new and old build systems until we can phase out the old completely.

Please see the updated trailofbits/cxx-common repository or run the `./scripts/build.sh` script to fetch the required dependencies.
2020-12-10 17:28:40 -05:00
Peter Goodman 3808e9951d Refactor and add sparc (#454)
* Refactors the code to improve directory layout, use more std::string_view in place of std::string, deletes some deprecated functions, deprecates some other functions for eventual deletion, and includes semantics for sparcv8 (sparc32) and sparcv9 (sparc64)

* Update new dir layout with llvm 11 support

* Whoops missing files

* Drop llvm 800 from workflow

* Minor fix

* Move where the install directives are in CMake

* Minor fixes

* Rename tools/ to bin/.

* Minor tweaks

* Should fix issues
2020-10-28 15:11:42 -04:00
Peter Goodman 3a16ad4a82 CMake improvements and refactor of __remill_basic_block (#447)
* Append project name to the check_git target to fix compound builds (#446)
* Change the way we get registers for __remill_basic_block so that it's the Arch class of the target that actually populates the function, and isn't based on reverse-engineering what's visible in the function as compiled by llvm
* Renamed a cmake var to reduce likelihood of conflicts, and tries to make sure remill only links against static llvm libraries
* Fix instruction dominance issues
* Minor fix on the type of PC on x86
* Added new implementation (in Arch.cpp) of the AArch64 __remill_basic_block function

Co-authored-by: Artem Dinaburg <artem@trailofbits.com>
Co-authored-by: Eric Kilmer <eric.d.kilmer@gmail.com>
2020-09-17 01:55:25 -04:00
Artem Dinaburg 5f74c389e9 Append project name to the check_git target to fix compound builds (#446) 2020-08-12 14:57:55 -04:00
Artem Dinaburg af9b410a75 Emit Version Information (#445)
* Emit Version Information

* Cut new versions in CI on passing master builds
* Emit detailed version information via --version

* add VERSION to gitignore
2020-08-07 15:52:24 -04:00
Artem Dinaburg cbd17b2c62 Stage CMake build changes from new API branch (#425) 2020-05-27 14:03:40 -04:00
Artem Dinaburg 86a6424d58 Find our local Z3 to build remill, even if its not in it usual spot (#420)
* Find our local Z3 to build remill, even if its not in it usual spot
2020-05-22 11:27:42 -04:00
Aiethel 74a5683459 Set required C++ standard to C++17. (#405) 2020-03-24 01:30:39 -04:00
Peter Goodman 6ea2e7ee01 Compile remill llvm 10 (#386)
* Compile with c++14

* Use non-fixed-width integers

* Revert unrelated lines

* Fixes uses of getPointerSize, using getPointerSizeInBits

* gep indices need to be 32-bit it seems
2019-12-13 11:47:59 -05:00
Alessandro Gario a3d00ec928 CMake: Fix ccache detection (#382) 2019-12-02 11:10:06 -05:00
Peter Goodman 6729755cad Llvm 900 (#377)
* Support for llvm 8.0.0 and llvm 9.0.0. Thanks to Peter Garba and John Regehr.

* Fixes for macOS to bake the SDK root into the config for the bc compiler

* Script fixes

* Update travis.sh

* Update travis.sh
2019-11-18 20:01:52 -05:00
Alessandro Gario 7197654279 CI/Travis: Fix broken if statements in travis.yml (#378)
* CI/Travis: Fix broken if statements in travis.yml

* CMake: Add ccache support

* CI/Travis: Update language for Windows, skip tests on macOS
2019-11-18 19:23:57 -05:00