Commit Graph

1429 Commits

Author SHA1 Message Date
Alessandro Di Federico 467d25693e MonotoneFramework: support user-provided BB list
Let the user provide the list of the basic blocks to visit, in a
specific order. This is useful when the same graph has to be visited
multiple times to avoid having `MonotoneFramework` recompute the reverse
post order each time.
2019-05-22 18:42:32 +02:00
Alessandro Di Federico b7ce437469 EnforceABI: completely ignore the stack pointer 2019-05-22 18:42:32 +02:00
Alessandro Di Federico 09cf8ecfbc StackAnalysis: fix bug involving EmptyCallSummary 2019-05-22 18:42:32 +02:00
Alessandro Di Federico 0e9d453be3 ZipMapIterator changes
* Introduce `KeyContainer::compare` and drop the `getKey` method.
* Let users of ZipMapIterator specify a trait class instead of using the
  default one.
2019-05-22 18:42:32 +02:00
Alessandro Di Federico 19f6f84d73 Various improvements to the revng script
* Handle SIGINT in children gracefully (`run` function).
* `run_translate`: return 0 on success.
* Move useful information about the `revng` installation from
  `--version` to `--help`.
* Do not `execv` on external commands, otherwise the script will not
  proceed.
* Print current directory-relative paths with `--verbose`.
2019-05-22 18:42:32 +02:00
Alessandro Di Federico 3bef125a54 PTCInstructionList: release memory after free
To release memory of a `PTCInstructionList`, we used to call
`ptc_instruction_list_free` only. However, that function does not
release memory. This commit calls `delete` to actually release the
memory and prevent memory from leaking.
2019-05-22 18:42:32 +02:00
Alessandro Di Federico 8627a32b4e dlopen: use RTLD_NODELETE to make ASan happy 2019-05-22 18:42:32 +02:00
Alessandro Di Federico ddb23e7147 CSAA: use more conventional metadata names 2019-05-22 18:42:32 +02:00
Alessandro Di Federico 00d5a00d86 CSAA: handle casted users of env 2019-05-22 18:42:32 +02:00
Alessandro Di Federico 806108d34a Tag unit tests with the unit label
Now you can run them in a single shot with `ctest -L unit`.
2019-05-22 18:42:32 +02:00
Pietro Fezzardi f205a28d97 CPUStateAccessAnalysis: handle recursion 2019-05-22 18:42:32 +02:00
Pietro Fezzardi e5e7d760e7 Improve debug print for nullptr Value * 2019-05-21 16:46:20 +02:00
Pietro Fezzardi 90bdfb07c8 Make CPUStateAccessAnalysisPass lazy on demand
CPUStateAccessAnalysisPass can now run lazily and accumulate partial
results. Actual fixes to the accesses to the CPU State (to make them
explicit) are only applied when the analysis is run in non-lazy mode.
2019-05-21 16:46:20 +02:00
Alessandro Di Federico 6ae3b6f22f Whitespace and other minor changes
* `GeneratedCodeBasicInfo::getCSVUsedByHelperCall` and
  `GeneratedCodeBasicInfo::extractCSVs`: make the call argument an
  `Instruction`.
* Introduce `blockByName`
* Introduce `getUniqueUser`.
* Fix linking issues.
2019-05-14 16:27:13 +02:00
Alessandro Di Federico feb06d180c Use revng --verbose in tests
This enables more informative debug logs.
2019-04-22 05:40:28 +02:00
Alessandro Di Federico 17eaaa1b0c Whitelist architectures in tests
We used to list all the architectures supported by QEMU in tests,
however this not optimal. This commit switches to a whitelist for the
list of architectures to tests so that we don't test architectures for
which we have a toolchain but aren't ready for the testsuite.
2019-04-22 05:40:28 +02:00
Alessandro Di Federico d411978af7 revng translate: invoke revng-lift directly 2019-04-22 05:40:27 +02:00
Andrea Gussoni 616c162523 DotGraph and DotNode
This commit implements a simple wrapper class able to parse a GraphViz
file in an object implementing the LLVM `GraphTraits`.
2019-04-22 05:40:27 +02:00
Alessandro Di Federico 4d5493fe7f Warning on translation of non-x86-64 dynamic ELF
We can currently successfully translate only dynamic binaries for
x86-64. Warn the user about this early on instead of failing in
`revng-merge-dynamic`.
2019-04-21 10:17:08 +02:00
Alessandro Di Federico 39a5a217c4 revng script: detect AArch64 2019-04-21 10:16:51 +02:00
Alessandro Di Federico 2f2b1f6ffe revng script: wrap executables 2019-04-12 19:17:23 +02:00
Alessandro Di Federico d75e5f3b6a Improve detection of external function calls
This commit enlarges the set of external function calls we
detect. Basically, instead of assuming that the instruction jumping to
the external function is the call, we now also consider instructions in
previous basic blocks, as long as there's only one possible path
backward.
2019-04-11 19:51:32 +02:00
Alessandro Di Federico d50fbe969a Update documentation and add revng. to metadata 2019-04-11 19:51:32 +02:00
Alessandro Di Federico 2a5081328c NRA: do not iterate while deleting calls 2019-04-11 18:16:53 +02:00
Alessandro Di Federico 9f4711b770 Improve revng help and ASAN support
This commit improves the output of `--help` and reduces the output of
`--version`.  This commit, when calling `opt`, injects a `LD_PRELOAD`
for `libasan.so` in case a `librevng*.so` library uses it.
2019-04-11 18:16:53 +02:00
Alessandro Di Federico d77ad08917 Drop leftover references to revamb 2019-04-11 17:44:39 +02:00
Alessandro Di Federico dda91e8c90 ClassSentinel prevent test failures
`ClassSentinel` makes use of an undefined behavior to check if an object
has been destroyed. Disable this check in case of presence of address
sanitizer or even regular optimizations.
2019-04-04 22:58:21 +02:00
Alain Carlucci 51a58a5513 Add support for PE32+ (x86-64) 2019-04-04 22:55:45 +02:00
Alessandro Di Federico 8337f70ca6 Merge branch 'feature/preliminary-c' 2019-03-08 15:25:39 +01:00
Alessandro Di Federico 63f0efbada Temporarily disable OSRA-related failing tests 2019-03-08 15:05:10 +01:00
Pietro Fezzardi 76135b76fb Add RemoveDbgMetadata FunctionPass 2019-03-08 15:00:59 +01:00
Alessandro Di Federico 28ceefcac3 SA: unify management of CSV indices 2019-03-08 15:00:59 +01:00
Alessandro Di Federico 02273d58e6 Add ABI registers for architectures missing them 2019-03-08 15:00:59 +01:00
Alessandro Di Federico 489e4b1d87 ABI analysis: ignore non-CSV used by helpers 2019-03-08 15:00:59 +01:00
Alessandro Di Federico 5904e78bdb Disable exceptions 2019-03-08 15:00:59 +01:00
Alessandro Di Federico c2d39fb702 SA: reorganize the way functions are registered 2019-03-08 15:00:59 +01:00
Alessandro Di Federico baef567365 ABI: ECSR are not "No" for function calls
Register marked as explicitly callee saved in a function used to be
marked as No both for the current function and all of its function
calls. However, the latter action is not accurate.
2019-03-08 15:00:59 +01:00
Alessandro Di Federico 9b070d8856 SA: use deque were appropriate
In certain locations we were using a `std::vector`, taking a reference
to it, adding elements and ending up in a reference invalidation issue.

This commit replaces those `std::vectors` with `std::deque` which do not
present this issue.
2019-03-08 15:00:59 +01:00
Alessandro Di Federico 05d16b6470 ResultsPool::dump: consider call sites too 2019-03-08 15:00:59 +01:00
Alessandro Di Federico fcb5315b7d Bug: FunctionABI::copy ignored a field 2019-03-08 15:00:59 +01:00
Alessandro Di Federico 57693f3653 NRA: compute PredecessorsMap internally 2019-03-08 15:00:59 +01:00
Alessandro Di Federico 9925243398 Handle infinite loops in ABI analysis
The ABI analysis used to ignore actions happening in CFG-level infinite
loops due to the fact that they had no exists. This commits detects
infinite loops and marks certain nodes as exits.
2019-03-08 15:00:59 +01:00
Alessandro Di Federico 467d916aac Ignore pc and sp in ABI analysis
They are not really part of the ABI.
2019-03-08 15:00:59 +01:00
Alessandro Di Federico e73def0c31 Register additional metadata in isolated functions
This commit reorganizes a bit the function isolation pass and, in
particular, copies over the `func.call` and `member.type` metadata.
2019-03-08 15:00:59 +01:00
Alessandro Di Federico 5dc8056b8c Introduce enforce-abi pass
This commit introduces the `enforce-abi` pass, which consumes the
information provided by the ABI analysis and enforces them in the
isolated functions adding actual arguments.

This commit also rewrites the logic of `ResultsPool::finalize` and
changes the semantic of `Yes` statements on arguments to `YesOrDead`.
2019-03-08 15:00:59 +01:00
Alessandro Di Federico 2bd8c468bc Introduce empty-newpc pass
`empty-newpc` is a simple pass suppose to provide an empty body for
the `newpc` function, allowing further optimization pass to take out
all its calls.
2019-03-06 10:31:23 +01:00
Alessandro Di Federico cb2bd9a3ce IRHelpers: introduce getCallToHelper 2019-03-06 10:31:23 +01:00
Alessandro Di Federico 0fa2d79fe4 Introduce ZipMapIterator
`ZipMapIterator` allows you to iterate in parallel over two
`std::map`-like containers.

In the ABI analysis, this allows us to be much more efficient. In
practice, if we have two maps with M and N elements, we pass from
performing N*log(N) + M*log(M) queries to the size of the union of the
set of keys of the two maps.
2019-03-06 10:31:23 +01:00
Alessandro Di Federico 7476eb5cbf MonotoneFramework: allow successors in final BBs
This will be necessary to correctly handle infinite loops.
2019-03-06 10:31:23 +01:00
Alessandro Di Federico 4076fbc8cd revng script: use -load and debugging options
Due to `opt` loading multiple times the same library, we had to switch
to `LD_PRELOAD`. However, this is suboptimal. This commit goes back to
use the `-load` flag but excludes the libraries that are dependencies of
other libraries. This requires parsing the ELF but it's a more neat
solution.

In addition, several shortcuts for popular debugging tools (namely,
`gdb`, `valgrind`, `callgrind`, `heaptrack` and `perf`) have been added
to the root command.
2019-03-06 10:31:23 +01:00