Commit Graph

1429 Commits

Author SHA1 Message Date
Alessandro Di Federico e5a5ff77c4 Ignore -Wunused-variable
Fails with LLVM headers built in release mode.
2020-02-20 12:16:56 +01:00
Alessandro Di Federico 525325d1c6 Add revng translate --output 2020-02-19 12:19:59 +01:00
Alessandro Di Federico 0a79b3d0f2 scripts/revng: fix order of post -- arguments 2020-02-19 12:19:31 +01:00
Alessandro Di Federico 0901fd7024 Reintroduce BOOST_TEST_DYN_LINK 2020-02-11 17:23:14 +01:00
Pietro Fezzardi f119be85e2 Always build with -Wextra
At this point, this branch is guaranteed to build without warnings with
our two supported compilers: clang-9 and gcc-9.

The dependencies are:
- llvm-9
- clang-9
- boost-1.71
- c++2a
2020-01-27 11:29:01 +01:00
Pietro Fezzardi 58428bdd4a IteratorWrapper: use implicit copy constructor 2020-01-27 11:29:01 +01:00
Pietro Fezzardi 67e762d668 Add breaks to switch to remove warnings 2020-01-27 11:29:01 +01:00
Alessandro Di Federico 109cea3496 Merge branch 'feature/llvm-9' 2020-01-22 12:53:42 +01:00
Alessandro Di Federico 1ccc7ec3d4 Cleanup RPATH management 2020-01-22 11:05:26 +01:00
Alessandro Di Federico 2006e5cd3c Expose CMake's add_flag_if_available 2020-01-22 11:04:26 +01:00
Alessandro Di Federico ed00c19a12 Switch to the Boost CMake package 2019-11-24 22:52:23 +01:00
Alessandro Di Federico b6658df052 Fix various warnings 2019-11-24 22:52:23 +01:00
Alessandro Di Federico 229a93367c Switch to C++20 2019-11-24 22:47:06 +01:00
Alessandro Di Federico 72f9c633d4 Make ConstantRangeSet LLVM 9-compliant
A `ConstantRange` such as `[5,0)` was not handled correctly in
`ConstantRangeSet` due to a spurious 0 at the end of the range.

This commit also fixes the testing infrastructure that was not checking
the size of the range before making the comparison with the reference
vector.
2019-11-21 23:50:59 +01:00
Alessandro Di Federico 7b2744f0ab Register ModuleAnalysisManager in new PassManager 2019-11-21 23:35:42 +01:00
Alessandro Di Federico cd41d055f4 DIBuilder::createFunction now takes SPFlags 2019-11-21 23:34:25 +01:00
Alessandro Di Federico ae8da14d46 Adopt FunctionCallee
`getOrInsertFunction` in LLVM 9 now returns `FunctionCallee`.
2019-11-21 20:52:55 +01:00
Alessandro Di Federico 0eb1bb583f Remove TerminatorInst
LLVM 9 drops the `TerminatorInst` class. This commit replaces it with
`Instruction` where possible and asserts
`Instruction::isTerminator()`. It also switches from
`TerminatorInst::successors` to `successors(TerminatorInst *)`.
2019-11-21 20:50:55 +01:00
Alessandro Di Federico 3818a4fcc6 Drop ConstantRange::ConstantRange
LLVM 9 prevents us from using the `ConstantRange` constructor. This
commit switches to use factory methods.
2019-11-21 20:50:03 +01:00
Alessandro Di Federico d247745df8 revng: informative error message on missing file 2019-09-04 11:52:07 +02:00
Alessandro Di Federico 25ede62813 Link librevngSupport to libLLVMSupport 2019-09-04 11:52:07 +02:00
Alessandro Di Federico 8d664c1588 Fix RPATHs
This commit replicates the structure of the install directory into the
build directory in order to simplify the management of RPATHs.

This commit also drop `QEMU_INSTALL_PATH`.
2019-09-04 11:52:07 +02:00
Alessandro Di Federico 981389d80a revng: handle different version of pyelftools
The contents of ELF dynamic tags is return either as a `str` or a
`bytes` depending on the versions of `pyelftools`.

This commit forces it to be a string to ensure compatibility with both
options.
2019-06-06 17:39:42 +02:00
Alessandro Di Federico 5d559367a4 PTCDump.cpp: use strncpy as appropriate
In `PTCDump.cpp` we were using `strncpy` in an invalid fashion: the `n`
argument was exactly the same size of the buffer, which might lead to a
missing NUL-terminator. This commit increases the buffer size by one
byte and initializes it with '\0'.

This bug was reported by `-Wstringop-truncation` of GCC 9.1.0 on a
Release build.
2019-05-28 21:32:40 +02:00
Alessandro Di Federico e445201b94 Restore getBasicBlockPC and fix FunctionIsolation
This commit restores the old implementation of `getBasicBlockPC` (which
was changed in an incompatible and wrong way) and fixes the bug the
original change tried to fix: in function isolation, jumping from a
function to a basic block that doesn't start with `newpc` now leads to a
basic block containing an `unreachable`.
2019-05-28 17:03:30 +02:00
Alessandro Di Federico bf9c6fa137 Merge branch 'feature/improve-robustness' 2019-05-27 19:50:25 +02:00
Alessandro Di Federico 707ec7c1fa Introduce preliminary Mach-O support 2019-05-27 19:36:12 +02:00
AndreaJegher 8492c56333 Enable AArch64 support (no tests)
This commit enables AArch64 as an input architecture. However, tests are
not enabled yet due to some known bugs.
2019-05-27 19:36:12 +02:00
Alessandro Di Federico c7e1c992de DropMarkerCalls: fix dangling pointer refs
`DropMarkerCalls` used to take an `ArrayRef<StringRef>` as an argument,
however the `ArrayRef` was copied in a class field, leading to a
reference to a temporary array.

This commit switches from `ArrayRef` to `SmallVector`.
2019-05-27 19:36:12 +02:00
Alessandro Di Federico 50396ab721 revng-merge-dynamic: handle missing DT_VERNEED 2019-05-27 19:36:12 +02:00
Alessandro Di Federico 9eb3cfd06a FunctionIsolation: update PHINodes
This commit improves the function isolation pass to fix references to
predecessor basic blocks in phi nodes.

The commit also improves handling of instruction operands to ensure no
unmapped Values are used.
2019-05-27 19:36:12 +02:00
Alessandro Di Federico 8d009296ef FCI: ignore non-translated basic blocks 2019-05-27 19:36:12 +02:00
Alessandro Di Federico b9ef70c8dc AdvancedValueInfo: handle pointer types 2019-05-27 19:36:12 +02:00
Alessandro Di Federico 877ba895af Rewrite get{BasicBlockPC,PrevPCWrite}
This commit reimplements `getBasicBlockPC` and `getPrevPCWrite` using
`BackwardBFSVisitor`, making them much more effective.
2019-05-27 19:36:12 +02:00
Alessandro Di Federico d0e5f61b20 CSAA: allow recursion in untainted paths 2019-05-27 19:36:12 +02:00
Andrea Gussoni 9f97826806 raise_exception_helper calls exception_warning
The call to `exception_warning` in `support.c` is now performed
directly by the `raise_exception_helper` function defined in
`support.c`, so that we can avoid calling two different functions in the
translated and isolated module.
2019-05-27 19:36:12 +02:00
Alessandro Di Federico 4b542de82f Drop unnecessary masking loading CSVs
When loading a CSV, we sometimes need to mask part of the loaded
value. However, this happened also when the source and target types had
the same size, leading to complex code doing nothing.

This bug has been discovered due to a problem in i386: all the function
calls were identified as indirect.
2019-05-27 19:36:12 +02:00
Alessandro Di Federico 1c6f8ee0f0 Fix disassembly printing too many instructions
This commit fixes a bug that lead to print 4096 disassembly instructions
at a time instead of one. This restore `--debug-log ptc` into a useful
state.
2019-05-27 19:36:12 +02:00
Alessandro Di Federico 53df3086ce FunctionIsolation: do not remove anypc and friends 2019-05-27 19:36:12 +02:00
Alessandro Di Federico 357d88377d EnforceABI: Killer branches are noreturn 2019-05-27 19:36:12 +02:00
Alessandro Di Federico c232e20be8 s/func.entry/revng.func.entry/ leftover 2019-05-27 19:36:12 +02:00
Alessandro Di Federico 7815c551db Support for file names in Logger
`Logger` can now print the file name from which it was called
(`--debug-location-max-length`).
2019-05-27 19:36:12 +02:00
Alessandro Di Federico 706b1d8e71 revng script: use sh instead of env
`env` sometimes is not a real executable but a shebang script spawning
/usr/bin/coreutils, which makes gdb unhappy.
2019-05-27 19:36:12 +02:00
Alessandro Di Federico 061906af3e Suppress GCC 9.1 warnings due to false positives 2019-05-27 19:36:12 +02:00
Alessandro Di Federico 5eee55ff11 Whitespace and other minor changes 2019-05-27 19:34:44 +02:00
Alessandro Di Federico 4103e1bbfb Merge branch 'feature/drop-osra' 2019-05-27 17:11:03 +02:00
Alessandro Di Federico 378d6366fe Let CpuLoopFunctionPass handle exception_index
`CpuLoopFunctionPass` is a pass performing some changes to
`cpu_loop`. Among these, calls to `cpu_*_exec` are replaced with the
value of `exception_index`.

This commit does not directly loads it but computes its address as an
offset from `CPUState`. This commit goes in tandem with the
corresponding QEMU commit which provide `exception_index` as an offset
from `CPUState` instead than from `env`. All of this makes CSAA more
effective.
2019-05-22 21:30:29 +02:00
Alessandro Di Federico 5009074e9e Introduce AdvancedValueInfo for JT discovery
* Introduce `ShrinkInstructionOperandsPass`: a transformation shrinking
  operands and the results of instructions if they are
  zero/sign-extended immediately before and after the instruction.
* Introduce `ConstantRangeSet`: similar to `ConstantRange` but allows
  disjoint ranges.
* Introduce `MaterializedValue`: a class that can represent a constant
  value or a symbol plus offset pair.
* Introduce `DropHelperCallsPass`: a transformation removing calls to
  helpers and replacing them with a function call reading the CSVs that
  the helper reads and writing the CSVs that the helper writes
  (according to CSAA).
* Introduce `DropRangeMetadataPass`: a transformation dropping the
  `range` metadata, which, in certain situations, lowers the quality of
  the results provided by `LazyValueInfo`.
* Introduce `AdvancedValueInfo`: an analysis exploiting results of
  `LazyValueInfo` but collecting them as `ConstantRangeSet` with a
  monotone framework. It produces `MaterializedValue`.
* Anticipate linking of helpers: `AVI` requires `CSAA`, which requires
  helper functions to be linked in.
* Drop `--no-link`.
* Force x86-64 `DataLayout`.
* Reorganize harvesting to either collect simple literals or go with
  (incremental) `AVI`.
* Drop `SET`, `OSRA`, the reaching definition analysis, the
  `SimplifyComparisonsPass` and all the sumjump-related code: e now
  clone `root`, optimize it and analyze it with `AVI`.
* Temporarily drop the `NoReturnAnalysis`.
* Link `libLLVMInstCombine`, `libLLVMCodeGen` and `libLLVMPasses`.
* Introduce tests for `AdvancedValueInfo`,
  `ShrinkInstructionOperandsPass` and `ConstantRangeSet`.
* Fix test results.
* Add `llvm.bswap.i64` and `@pc` to the LLVM template module for unit
  tests.
2019-05-22 21:30:29 +02:00
Alessandro Di Federico c8998cdece StackAnalysis: election of return SP value
Any stack pointer value greater than or equal to the original one used
to be OK for stack analysis to recognize an instruction as a
return. This commit changes this policy by collecting the value of the
stack pointer on all the return points and, at the end, elect a final
stack pointer value. All non-compliant returns are marked a
`BranchType::BrokenReturn`. The function is now considered fake only if
all the return instructions agree on a specific value of the stack
pointer, and it's lower than the original one.

* Drop `BranchType::IndirectTail`.
* `s/BranchType::FunctionSummary/BranchType::RegularFunction/`.
2019-05-22 21:30:29 +02:00
Alessandro Di Federico a9de053243 Introduce GraphAlgorithms
A series of algorithms working on `llvm::GraphTraits`.

* `nodesBetween` computes the set of nodes on all the paths from a node
  A to B.
* Factor out code to iterate over infinite loops into
  `exitless_scc_range`.
* Introduce unit tests.
2019-05-22 18:42:32 +02:00