24 Commits

Author SHA1 Message Date
Duncan Ogilvie bed042f2d9 Fix signature of memory_f80 intrinsics 2025-11-24 12:04:51 -05:00
Duncan Ogilvie 1be540eeef Implement FMADD in terms of std::fma 2025-11-05 20:46:01 -05:00
Duncan Ogilvie eba0652f86 Replace cfenv dependency with new remill FPU intrinsics 2025-11-05 20:46:01 -05:00
Eric Kilmer 66832ffeae Fix SIGSTKSZ no longer being constant in glibc 2.34+ (#646)
Set our own constant and use that
2023-01-10 11:33:07 -05: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 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
Alex Cameron 65549b31d3 Pass opaque pointer flag to Clang so it can handle Remill's IR (#605)
* Pass the opaque pointer flag to Clang so it can handle Remill's IR

* Fix linker errors in tests

* Turn down optimization in the Remill optimizer
2022-06-27 12:48:02 -04:00
Artem Dinaburg 96a1dd28ef Artem/fix aarch64 build (#582)
* Native float80_t ops for arm64 test
2022-03-22 18:40:21 -04:00
Artem Dinaburg 65d68f7a83 Fix aarch64 errors (#581) 2022-03-22 17:33:15 -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 769c280720 Populate the register table even in the absence of semantics (#558)
* Populate the register table even in the absence of semantics

* Modify the test suite
2021-11-02 14:11:54 -04:00
Artem Dinaburg d93575e0d4 Fix AArch64 test runner (#538)
* Fix AArch64 test runner
* Fix x86 test runner
2021-08-31 15:43:27 -04:00
kumarak 9006baf7db WIP: Fix FPU types (#536)
Update remill's FPU semantics to use 80-bit floats, at least on x86/amd64.

Co-authored-by: Artem Dinaburg <artem@trailofbits.com>
2021-08-25 12:26:21 -04:00
Artem Dinaburg ab27539b86 Better AArch64 Test Runner (#475)
* More detailed AArch64 test runner
2021-01-21 14:54:19 -05:00
Artem Dinaburg 5903d273f1 Fixes for aarch64; some semantics tests do not yet pass (#455) 2020-10-29 11:00:41 -04:00
Peter Goodman 99df2e19d4 Running clang-format on files with some additional custom scripts for… (#444)
* Running clang-format on files with some additional custom scripts for my style

* Fix missing unique_ptr in remill/BC/Optimizer.h

* Fixes and selective disabling of clang-format
2020-08-05 15:42:25 -04:00
Peter Goodman 2b206fb1a9 Implements some ring 0 instructions in terms of hyper calls and new I/O port intrinsics. (#252)
* Random tests.

* More decode error info

* more playing around

* more system instructions. instrinsics for accessing I/O ports. Split our writes to individual control regs for better identification via hyper calls.
2018-05-16 19:24:32 -04:00
Akshay K 807c47f791 Atomic intrinsics defined for aarch64 tests. Need to fix the atomic instruction semantics to use them. 2017-12-26 18:09:11 -05:00
Peter Goodman 026ea1afec Issue 150 lift bin dir (#167)
* Added semantics and tests for SDIV

* Semantics and tests for SCVTF.

* Working on integer to/from float conversion bugs related to managing the fpu status register.

* Switch to using the check float function wrapper

* Remove unintentional call to fetestexcept

* Adding in a compiler reordering barrier.

* Added inline assembly that will force clang's optimizer to give up and filed a clang bug

* Adds some trailing spaces into some files. Re-enables all aarch64 tests.

* Added semantics and tests for SDIV

* Semantics and tests for SCVTF.

* Switch to using the check float function wrapper

* Remove unintentional call to fetestexcept

* Added inline assembly that will force clang's optimizer to give up and filed a clang bug

* Adds some trailing spaces into some files. Re-enables all aarch64 tests.

* Bringing the aarch64 branch back in line with master.

* Adds in a test and ISEL for LDR_BL_LDST_REGOFF, and fixes up the instructions in some SMOV and UMOV tests.

* Various fixes and some minor debugging aids for aarch64

* Resets the fenv before running lifted code.

* All existing aarch64 tests should now pass.
2017-11-29 22:53:58 -05:00
Peter Goodman 927998635a Implements more accurate tracking of x87 exception flags, last instru… (#163)
* Implements more accurate tracking of x87 exception flags, last instruction pointer, last data pointer, and floating point instruction opcode.

* Fix that masks out the MXCSR register from being compared at the end of tests. We don't yet have good enough info to do this well. Moves the FCMOV instruction set to be under the purview of X87.cpp and its tests.

* Tests should pass now.

* Addressing issues Mike mentioned.
2017-11-14 22:50:28 -05:00
Peter Goodman 26a9aee588 Minor fix 2017-09-25 13:34:46 -04:00
Peter Goodman bed610be6b Issue 137 lift bin ls (#142)
* Post-decoder, semantics, and tests for BFM.

* Semantics and tests for ANDS

* Minor naming conflict fix

* Semantics and tests for SMADDL and SMULH

* Semantics and tests for MADD

* Minor symbol renaming fix

* Semantics and tests for EXTR, which also implements ROR

* Minor fix to number of arguments to test

* Semantics, but NO tests for LSLV, LSRV, ASRV, and RORV.

* Semantics and tests for ORN

* Minor fix

* Semantics for SBC, but no tests. Added an AddWithCarryNZCV primitive, untested

* Missing two's complement negation in subs using new addwithcarrynzcv

* Tests for SBC. Semantics and tests for SBCS

* Semantics and tests for UCVTF

* Update state save/restore code to record SIMD regs

* Attempt to fix save/restore code

* More attempts at getting the save/restore assembly right, this time with the fpsr bits.

* More fixes

* More tests extracting the fpsr state. Also trying without including RestoreState.S. I don't remember why I had that.

* Semantics for SVC and BRK
2017-09-25 13:29:10 -04:00
Peter Goodman 8ae0bdcdf6 Aarch64 tests (#131)
* Implemented tests for a few add and sub variants. Made it so that the post-decoders of some of the add/sub variants refer to eachother.

* Tests and another decoder for EOR

* Fixes to semantics generated for shift register operands

* Fixes and tests for cmp instruction. Really interesting because it does a - b, but as an adc(a, ~b, 1).

* Added post-decoders and tests for the add and sub variants that use extract, extend, and shift operators

* Minor fixes

* Minor fixes

* Minor fixes

* Minor improvements, though tests still failing

* Fix. Passed the wrong data size into the AddExtendRegOp function.

* Fix. Passed the wrong data size into the AddExtendRegOp function.

* Not sure if I did anything significant

* Changed the aarch64 test case lifter to support testing branches

* Tests for CBZ and CBNZ

* CBZ and CBNZ were testing the wrong operands

* Added semantics and tests for CMN

* Semantics and tests for SUBS

* Tests for ADDS

* Semantics and tests for AND, ORR, and BIC

* Reordered pc, state, and memory to help with mcsema's legacy mode
2017-08-16 20:58:51 -04:00
Peter Goodman bef332fd2a Aarch64 tester (#128)
* Added in more aarch64 instructions. Fixed some x86 instructions. The x86 test cases now exercise each test through every possible combination of flags.

* Adding missing files

* Another missing file

* Rename file

* Fixup some macros

* IPR

* More improvements on the test runner

* Test runner fixes related to me not being familiar with aarch64 assembly

* Fixing default data layout

* Trying to use llc to compile bitcode to aarch64 assembly. wth.

* Revert back to using the CMAKE_BC_COMPILER for building the test assembly file instead of the whole CMAKE_LL_COMPILER stuff, now that I've adjusted cxx-common to use the right build target for aarch64.

* Documentation updates. Fixes for aarch64.

* Making progress. The native tests can run, but the first lifted test faults. Not yet sure why.

* Weirdest issue is happening on aarch64. A pointer argument is being compiled to an integer, and that's really screwing things up.

* Add caching of the libraries path to the main cmakelists to avoid having to re-run build.sh all the time when the TRAILOBITS_LIBRARIES env var is not globally defined. Experimenting with trying to force the semantics to be compiled using the x86_64 target, regardless of host arch, or modelled arch of the semantics. This is to try to get around the issue where a single-element struct containing a pointer is lowered into a uintptr_t when passed by value as an argument on aarch64.

* Alright, falling back on handling this problem in the lifter (for now, at least). Really not ideal.

* Test runner works afaict
2017-08-04 15:24:46 -04:00