Commit Graph

1642 Commits

Author SHA1 Message Date
Alessandro Di Federico c6d0ce9dec Don't use RPOT for DisjointRanges
Sorting the BasicBlocks on which DisjointRanges works is detrimental for
performance.  Using a random order takes less time. This is due to the
fact that the number of BasicBlocks to analyze is significantly smaller
than the whole list of BasicBlocks.
2020-11-23 14:52:46 +01:00
Alessandro Di Federico cbe4967aad SymbolTableList::size() is expensive
This simple commit reduces the number of times we query the size of the
`BasicBlock` list of a `Function` during the final reodering of blocks
before emission.

This change introduces a 25% speedup when lifting `/bin/bash`.
2020-11-23 10:20:43 +01:00
Alessandro Di Federico c313fdbcb0 CSAA: verify module only if --debug-log=verify
This commit brings a 6% speedup in lifting `/bin/bash`.
2020-11-23 10:20:43 +01:00
Alessandro Di Federico 0ccc32af08 Performance: destroy AVI PassManager ASAP
It is important to let the pass manager go out of scope ASAP:
LazyValueInfo registers a lot of callbacks to get notified when a Value
is destroyed, slowing down OptimizedFunction->eraseFromParent
enormously.

This commit introduces a speedup of approximately 25% when lifting
`/bin/bash`.
2020-11-22 15:14:44 +01:00
Alessandro Di Federico dab8a2dfae Install clang-format-style-file 2020-11-20 18:06:16 +01:00
Alessandro Di Federico 7cb569bf1b Merge branch 'feature/new-include-conventions' 2020-11-20 15:26:57 +01:00
Pietro Fezzardi e79dcaf780 check-revng-conventions: enforce #pragma once 2020-11-13 14:12:18 +01:00
Pietro Fezzardi 9869f057b9 Use #pragma once for header include guards 2020-11-13 14:12:18 +01:00
Pietro Fezzardi 1a09c00aa1 check-revng-conventions: regroup header includes 2020-11-13 10:00:27 +01:00
Pietro Fezzardi cd9bc34d9d Enforce new include conventions 2020-11-13 10:00:24 +01:00
Pietro Fezzardi dc4ab84ad3 Move .clang-format to scripts/
The format file has also been renamed to revng-clang-format-style-file.

The check-revng-conventions scripts now always uses the same format
file, unless otherwise specified with the new option
--use-local-clang-format-file.

In this way, the check-revng-conventions uses the same format in all the
projects by default, but if a project needs to customize it (e.g.
cold-revng which follows the Qt style) it can use the new flag to
fallback to using the local .clang-format file.
2020-11-13 09:59:42 +01:00
Alessandro Di Federico ab6c8276f5 AVI: handle pointer as smallest operation 2020-11-12 20:36:02 +01:00
Alessandro Di Federico bcd1554546 Do not add to CodePointers invalid addresses 2020-11-12 20:36:02 +01:00
Alessandro Di Federico 2fee00f01e Ignore undefined symbols 2020-11-12 20:35:58 +01:00
Alessandro Di Federico ae500fa314 Assert ELFs are executables or .so 2020-11-12 16:39:28 +01:00
Alessandro Di Federico 14cf2a399d Make assertion messages prettier 2020-11-12 16:39:03 +01:00
Alessandro Di Federico 56b6797f8c scripts/revng: backport shlex.join 2020-11-12 16:21:32 +01:00
Alessandro Di Federico 5e7d288530 Introduce PruneRetSuccessors pass
This commit introduces the PruneRetSuccessors pass, whose role is to
identify all the indirect jumps whose devirtualized destinations
correspond to return addresses. In fact, they are most likely to be
return instructions and devirtualizing them is always detrimental.
2020-11-12 15:28:31 +01:00
Alessandro Di Federico d609c2e74d ABI Analysis: more verbose logging 2020-11-12 15:15:27 +01:00
Alessandro Di Federico 5f25194ec8 IncoherentCallsAnalysis: introduce Logger 2020-11-12 14:56:05 +01:00
Antonio Frighetto cd4a8dcf79 StackAnalysis: remove cleanup in mergeASState
After combining two AS objects, removing an ASOContent in the cleanup
phase may lead to a mismatch in the CSVs promoted to function argument,
with some registers actually being used. In most cases, this results in
promoting only one or few alive registers as function argument.
2020-11-12 14:56:03 +01:00
Alessandro Di Federico 4b3562edce Handle failure of ptc_mmap 2020-11-12 14:55:57 +01:00
Pietro Fezzardi fc537a2fc7 Add missing MIT license headers 2020-11-12 14:55:57 +01:00
Alain Carlucci 42e8f8db02 revng-lift: Enable LLVM stack trace on kill signal
This commit enables LLVM stack trace mechanism when a kill signal is
raised.
2020-11-12 14:55:57 +01:00
Alessandro Di Federico 864bcdc471 scripts/revng: add --lldb 2020-11-12 14:55:57 +01:00
Alessandro Di Federico 29080a2f29 StackAnalysis: resetCacheMustHit on right entry
We used to accidentaly call `resetCacheMustHit` on the just popped
element of the set, resulting in an out-of-bounds access within the
container.

This bug has been spotted thanks to AddressSanitizer.
2020-11-12 14:55:57 +01:00
Alessandro Di Federico c7e0361acf scripts/revng: handle empty ASAN_OPTIONS 2020-11-12 14:55:57 +01:00
Alessandro Di Federico cf5fca85a1 Whitespace changes 2020-11-12 14:55:56 +01:00
Alessandro Di Federico 0b15c965ce scripts/revng: use subprocess.Popen directly
We used to use `subprocess.run`, but it's not supported in Pytnon 3.2
(Debian 7).
2020-11-10 10:04:31 +01:00
Alessandro Di Federico 6e68453d9c Assign copyright to rev.ng Srls 2020-11-09 08:52:51 +01:00
Andrea Gussoni 9c910604fd EnforceABI: add opaque store to PC after call
Add an additional opaque store the the `pc` after each function call in
the enforced functions. In this way, when the `pc` will be promoted to
an alloca, we won't have an inconsistent state of the IR (the callee
cannot propagate the correct value of pc, the safety check introduced by
the function isolation will always be false, and llvm will place a
`llvm.assume` which will in turn make the rest of the code dead and
purged by an additional `-simplifycfg`).
2020-11-08 20:52:03 +01:00
Alessandro Di Federico acb896e934 PE/COFF: consider ImageBase as code 2020-11-06 22:14:44 +01:00
Alessandro Di Federico 10d3561212 StackAnalysis: disable expensive assertions 2020-11-06 10:59:00 +01:00
Alessandro Di Federico d0a61e7947 Add logger to dump CFEPs 2020-11-06 10:59:00 +01:00
Alessandro Di Federico 124d5e88b1 Merge branch 'function-isolation-use-func-call' 2020-11-06 10:58:18 +01:00
Alessandro Di Federico 6bfae0409b FunctionIsolation: drop isolate-no-safety-checks
This commit drops the `--isolate-no-safety-checks` flags since we
adopted a new approach later on in the decompilation pipeline, i.e.,
dropping calls to `raise_exception_helper` and running dead code
elimination.
2020-11-02 11:21:32 +01:00
Alessandro Di Federico ccb0b183a5 FunctionIsolation: member.type, not function_call
FunctionIsolation used to base its work on calls to the marker function
`function_call`, as opposed to information provided by the StackAnalysis
(i.e., `revng.member.type` along with `func.call`).

This also affected EnforceABI, which took care of finishing the work
left over by FunctionIsolation. This was hackish and inelegant.

This commit makes FunctionIsolation work exclusively employing
information from StackAnalysis and purges away code that is no longer
necessary from EnforceABI.
2020-11-02 11:21:07 +01:00
Alessandro Di Federico 7f90bc4fe0 StackAnalysis: callee saved must pass by the stack
We used to detect callee-saved registers only by checking if their final
value was identical to the initial one. However, the need for a more
precise heuristic emerged: we now also check if at least on of the stack
slots contains that same value.
2020-11-02 09:05:12 +01:00
Alessandro Di Federico dd774af288 ABIAnalysis: merge DefaultMap::Default last
This commit fixes a subtle bug that was preventing us from correctly
considering the effects of function calls during ABI analysis.

Specifically, when merging information from the call site to the caller,
in case the caller did not provide any information about a certain
slots, we used the `DefaultMap::Default` field, which is the correct
thing to do, except for the fact that, in two methods, the `Default`
field was being updated to early.

This basically had the effect of not considering arguments of function
calls as used, e.g., in URAOF.
2020-11-02 09:05:12 +01:00
Alessandro Di Federico dd29699aed FunctionsSummary: print the callee too 2020-11-02 09:05:12 +01:00
Alessandro Di Federico 51b29afc30 Make ABIAnalysis mandatory 2020-11-02 09:05:12 +01:00
Alessandro Di Federico f7cb681b23 Whitespace changes 2020-11-02 09:05:12 +01:00
Alessandro Di Federico ea832c5063 script/revng: print command upon failure 2020-11-02 09:05:03 +01:00
Andrea Gussoni fac6b4d8ed Add artifacts with no dispatcher inline
Add artifacts for decompilation that do not inline the function
dispatcher during the enforceABI. Also, serialize as `.ll` all the
artifacts.
2020-10-30 14:17:57 +01:00
Andrea Gussoni 02a4970fa6 EnforceABI: outline function_dispatcher on flag
When the `--enforce-no-safety-checks` flag is passed during the
enforcing, we avoid emitting the inlined `function_dispatcher` and we
emit instead a call to an `indirect_handle` disposable call created on
the fly to respect the ABI information on the callsite.
2020-10-30 14:17:57 +01:00
Alessandro Di Federico d1ea87e536 revng-merge-dynamic: make Python 3 compatible
Wow, we no longer need Python 2.
2020-10-30 09:50:03 +01:00
Alessandro Di Federico bf2ac34b38 FunctionSymbol blocks are tier-1 CFEPs 2020-10-30 09:10:00 +01:00
Alessandro Di Federico 5791429f91 ABIIR: prune on finalization
Under certain conditions, we ended up having code in the ABI IR which
was not reachable. This was due to the fact that a certain instruction
was initially detected as an indirect call, triggering inclusion in the
function of the fallthrough code, and then as a return, which has no
successors within the function.

This commit simply prunes the ABI IR in the finalization method.
2020-10-24 17:40:54 +02:00
Alessandro Di Federico a08d5a14e0 scripts/revng: fix matching libraries to link 2020-10-23 17:40:13 +02:00
Alessandro Di Federico 2e995fdaa7 Pretty print JSONs 2020-10-22 11:25:31 +02:00