Commit Graph

1642 Commits

Author SHA1 Message Date
Alessandro Di Federico 078daef537 More robust StackAnalysis test reference results
We recently bumped the GCC version used for the x86-64 toolchain. The
newer version makes slightly different choices of instruction breaking
the names of basic blocks.

This commit drops them, since they are not really necessary: checking
the order is already more than enough.
2020-10-22 11:22:26 +02:00
Alessandro Di Federico 3a78fae441 Polyfill for shutil.which 2020-10-21 10:34:35 +02:00
Alessandro Di Federico 782eb09ffc Switch to produce bitcode where possible 2020-10-21 10:34:34 +02:00
Alessandro Di Federico 0e4c4aad59 Make --use-debug-symbols the default 2020-10-21 10:34:34 +02:00
Alessandro Di Federico d72f69c975 Import GenericGraph
This commit imports `GenericGraph`, its tests and fixes some related
issues in `FilteredGraphTraits`.
2020-10-21 10:34:01 +02:00
Alessandro Di Federico 94b28d0514 bin/revng: more robust diff of opt --help output 2020-10-06 16:04:55 +02:00
Alessandro Di Federico 1c2d3e0613 bin/revng: introduce $REAL_ARGV0 2020-10-06 16:04:32 +02:00
Alessandro Di Federico 1fa5b0fe68 Install bin/revng from build directory 2020-10-06 16:03:59 +02:00
Alessandro Di Federico 62c1e3c564 Go back to version 0.0.0 2020-10-06 16:03:33 +02:00
Pietro Fezzardi 05e34ef6f9 Add functions to get installed resource files 2020-10-05 14:09:53 +02:00
Pietro Fezzardi 838ab5b247 CSAA: switch taint sets to SetVector
This makes iteration order deterministic, making bugs due to ordering
easier to reproduce.
2020-10-05 14:09:31 +02:00
Pietro Fezzardi 9fca2ba1e0 CSAA: fix handling of recursion again 2020-10-05 14:09:17 +02:00
Antonio Frighetto 11e9203de9 StackAnalysis: storing Type in copy() method
`FunctionType::Values Type` was not copied when returning an `IFS`
object. This issue was addressed by adding `Type` to `Result` as well.
2020-10-01 18:17:53 +02:00
Pietro Fezzardi a94371cca2 EnforceABI: promote CSV in ConstantExprs casts
EnforceABI promotes global variables representing parts of the CPU
states to arguments and return values of isolated functions.

This commit enables the promotion of CSV that are used in isolated
functions only indirectly, through `ConstantExpr`s casts.
2020-10-01 18:17:53 +02:00
Alessandro Di Federico 5a7d4d194a Install check-revng-conventions 2020-10-01 18:17:53 +02:00
Antonio Frighetto 883dd14f43 Declare the exception object with static storage
Fix an out-of-scope issue, where the `_Unwind_Exception` object was used
after the destruction of `raise_exception_helper`'s stackframe.
This issue has been addressed by placing the object into the `.bss`
segment.
2020-10-01 18:17:53 +02:00
Alain Carlucci 9034fcb235 scripts/revng: s/log/log_error/ 2020-10-01 18:17:53 +02:00
Pietro Fezzardi 510f503716 IRHelpers: improve prints for llvm::Value
This commit improves prints of Argument, Function, ConstantInt
2020-10-01 18:17:53 +02:00
Pietro Fezzardi 408b2c9592 IRHelpers: improve replaceAllUsesInFunctionWith
This helper function is now able to replace also uses that are inside
`ConstantExpr`s.
Before this commit they were not substituted correctly, causing problems
down the decompilation pipeline.
2020-10-01 18:17:53 +02:00
Alessandro Di Federico b4c78ad047 libtinycode is now bitcode 2020-10-01 18:17:53 +02:00
Pietro Fezzardi b8e2f85ddd CSAA: fix handling of recursion 2020-10-01 18:17:53 +02:00
Pietro Fezzardi 998d003d10 check-conventions.sh: better match C++ filenames 2020-10-01 18:17:46 +02:00
Pietro Fezzardi 44e47de54c check-conventions.sh: properly set exit status
Before this commit, the exit status was not really taken care of.
Now the exit status is set to error whenever some of the checks fail,
and to success only if all the checks succeed.
2020-10-01 18:17:46 +02:00
Pietro Fezzardi 643a79ede5 check-conventions.sh: add check helper functions
This commit adds two helper functions that run two set of checks:
- `run_clang_format` runs clang format
- `run_revng_checks` runs revng-specific checks

This is a preliminary commit to ease extension of `check-conventions.sh`
so that it can be better integrated with bash scripts and git hooks.
2020-10-01 18:17:45 +02:00
Pietro Fezzardi 1594664743 check-conventions.sh: drop --format option
This option is now redundant, since `clang-format` always runs.
2020-10-01 18:17:29 +02:00
Alessandro Di Federico 89651cbde8 revng-lift: fix new module's data layout
We used to hard code a data layout. We now copy it over from the helpers
module.
2020-10-01 17:41:55 +02:00
Alessandro Di Federico 72b840605c AVI: fix out-of-bound access
In `AdvancedValueInfo` we used to access an element in a vector that has
been shrinked.
2020-10-01 17:41:44 +02:00
Alessandro Di Federico 60fdcbc66a Whitespace changes 2020-10-01 17:40:17 +02:00
Alain Carlucci 3cafe56223 MetaAddress::fromString: fix error handling
StringRef::getAsInteger() returns true on error; false on success. This
commit fixes the off-by-not.
2020-09-14 17:19:14 +02:00
Alessandro Di Federico 724c4c0baa Add g_realloc to support.c 2020-09-08 17:06:54 +02:00
Alessandro Di Federico 85ec2e2e05 Produce artifacts for decompilation 2020-09-04 23:54:26 +02:00
Alessandro Di Federico cbe36d5267 FunctionIsolation: enable/disable safety checks 2020-09-04 23:53:00 +02:00
Alessandro Di Federico 270595632c Fix dependencies for revng-qa artifacts 2020-09-04 23:52:45 +02:00
Alessandro Di Federico 85058249c5 Avoid pygraphviz crash with Python 3
Just a workaround.
2020-09-04 17:40:00 +02:00
Alessandro Di Federico ae3c800109 Implement MetaAddress::{from,to}String 2020-09-02 18:21:07 +02:00
Alessandro Di Federico e62cbb5ceb Implement comparison operators for MetaAddress 2020-09-02 16:55:20 +02:00
Andrea Gussoni d48a15e607 Run revng translation test with function isolation
Re-enable the use of function isolation for the `translation` test
integrated in revng.
2020-08-03 22:11:18 +02:00
Andrea Gussoni a590159993 Use c++ compiler for linking the translated module
We now make use of the `__gxx_personality_v0` personality function to
handle the exception behavior.

For this reason, we now need to use a c++ compiler for linking the final
module after the translation process of a binary.
2020-08-03 22:11:18 +02:00
Antonio Frighetto 76a6403ebd FunctionIsolation: drop ExceptionFlag
ExceptionFlag has been superseded by proper use of stack unwinding.
Our custom personality routine has been replaced with the GNU GCC
personality one.
2020-08-03 22:11:06 +02:00
Alessandro Di Federico b7660a06c3 [MetaAddress] Fix tie type
The tuple returned by the `tie` method used to have the type of the
`Type` field (`uint16_t`) for the `Address` field (`uint64_t`) and
viceversa.
2020-06-29 23:49:52 +02:00
Alain Carlucci be9bc6ce0a MetaAddress: remove header dependency from IRBuilder 2020-06-25 14:28:07 +02:00
Alessandro Di Federico 314cae3a1e Abandon removeUnreachableBlocks
`llvm::removeUnreachableBlocks` doesn't just drop dead basic blocks,
it also turns certain `SwitchInst` into `BranchInst`, which leads to
hard-to-debug issues in parts of the code where we don't assume
unexpected changes such as this.
2020-06-23 15:01:52 +02:00
Alessandro Di Federico d8cbc86b1c Isolate: handle IndirectBranchDispatcherHelper
Function isolation used to mishandle blocks of type
`BlockType::IndirectBranchDispatcherHelperBlock`. This led to have
empty basic blocks instead of the dispatcher for handling indirect
branches.
2020-06-23 14:55:13 +02:00
Pietro Fezzardi 227e649175 Fix use of comparison parameter C in SmallMap 2020-06-14 23:51:36 +02:00
Pietro Fezzardi e4c8e7962a Make Iteratall a bidirectional iterator 2020-06-14 23:51:36 +02:00
Pietro Fezzardi 2bc5a52ef9 Iteratall: add constructors and public typedefs
These are necessary for this iterator to be a forward_iterator according
to the standard.
Missing these causes compilation errors in some cases when using
functions from the Standard Template Library with these iterators.
2020-06-14 23:51:36 +02:00
Pietro Fezzardi 2fc342d2e4 Add a global public Logger: VerifyLog
Rationale: it is a widespread practice, both in revng and in projects
that depend on it, to write verification functions that check specific
properties hold after different transformations on various data
structures.
Often, these verification function are very useful for debugging and
during development, but they can be very costly and we don't want to
always execute them at runtime.

This patch adds a global public Logger, called VerifyLog, that can be
enabled with the --debug-log=verify command line argument.
This Logger is intended to be used in revng and in projects that depend
on it, as a guard for costly calls to verification functions that do not
need to be performed on a typical execution, but only when debugging.

For now the only user is JumpTargetManager, but other uses are already
envisioned.
2020-06-14 23:34:14 +02:00
Pietro Fezzardi 0eb179baf8 GCBI: relax assumptions on AnyPC and UnexpectedPC
This commit makes possible to execute the GeneratedCodeBasicInfo (GCBI)
Pass even on LLVM IR where the AnyPC and UnexpectedPC BasicBlocks are
not present.
This makes the GCBI pass more flexible, enabling more other passes to
depend on it and to use it to retrieve informations on the generated
code without architecture-dependent hacks.

As an example, one can now use GCBI to retrieve the CSV representing the
Stack Pointer Register or the Program Counter Register without relying
on the register names (which are architecture-specific), even if some
optimization pass along the decompilation pipeline has removed AnyPC or
UnexpectedPC.

Notice that the contracts of GCBI's methods has not been changed.
Calling anyPC() or unexpectedPC() still asserts that those are not
nullptr.
The contract has just been moved from the execution stage of the pass
(basically runOnModule), to the APIs used to query the results.
2020-06-14 23:33:02 +02:00
Alessandro Di Federico e190c3189e check-conventions.sh: always run clang-format 2020-06-13 10:36:08 +02:00
Pietro Fezzardi 49b3c4b2c9 Upgrade to LLVM 10 2020-06-13 10:36:08 +02:00