Commit Graph

1642 Commits

Author SHA1 Message Date
Pietro Fezzardi 12364e6d63 Update BinaryFile to new llvm::object APIs
This is required to compile against llvm-12
2021-06-14 23:04:02 +02:00
Pietro Fezzardi d3d4e1ea5e JumpTargetManager.cpp: include missing header
Before the addition of this include, the file failed to compile with
llvm-12.
2021-06-14 23:04:02 +02:00
Pietro Fezzardi 370dfdaf13 Update InlineFunction API to LLVM-12 2021-06-14 23:04:02 +02:00
Pietro Fezzardi f8d20946d8 RecursiveCoroutine: add noexcept where needed
Fix compilation error: the expression 'co_await
__promise.final_suspend()' is required to be non-throwing

This compilation error started being triggered when switching to
clang-12.
2021-06-14 23:04:02 +02:00
Alessandro Di Federico 1c403b5dd8 Merge branch 'feature/improve-model' 2021-06-09 20:25:59 +02:00
Pietro Fezzardi a7a55f974a Require TupleTreeCompatible concept on TupleTree 2021-06-09 20:13:27 +02:00
Pietro Fezzardi 3cb6dcd163 Move IsYamlizable generic lambda in TupleTree.h 2021-06-09 20:13:27 +02:00
Pietro Fezzardi 75bff8f29c Move CompositeScalar in YAMLTraits.h
Soon Binary.h will not be the only user.
This commit makes the same machinery usable elsewhere.
2021-06-09 20:13:27 +02:00
Pietro Fezzardi c9b3cdd88b Fix UpcastablePointer copy/move ctor/assignment 2021-06-09 20:13:27 +02:00
Pietro Fezzardi 4b7f383ea5 Conceptify YAMLTraits.h 2021-06-09 20:13:27 +02:00
Pietro Fezzardi 432b75f2ba TupleTreePath.h: fix copy/move ctors/assignments 2021-06-09 20:13:27 +02:00
Pietro Fezzardi 8557a30206 TupleTree: improve serialization 2021-06-09 20:13:27 +02:00
Pietro Fezzardi 83a629444a Default operator== for TupleTreePath 2021-06-09 20:13:27 +02:00
Pietro Fezzardi b78d52ac3c Add TupleTreeReference::operator==, ignoring Root 2021-06-09 20:13:27 +02:00
Pietro Fezzardi 88a48015dc TupleTree.h: require IsKeyedObjectContainer
Requires IsKeyedObjectContainer in TupleTree.h wherever possible,
instead of IsContainer. This enables using std::vectors.
In this way, they will not be diffed based on the key, but on the entire
vector. This is intended.
2021-06-09 20:13:27 +02:00
Pietro Fezzardi 0a293b5881 CallByPathVisitorWithInstance on UpcastablePointer
Add a specialization for
CallByPathVisitorWithInstance::visitContainerElement to handle cases
where the element of the container is an UpcastablePointer, that needs
to be unwrapped before visiting.

This fixes a problem causing bad TupleTree traversal with
TupleTreeReference. Specifically, CallByPathVisitorWithInstance did not
know how to visitContainerElement when the element of the container was
an UpcastablePointer. This caused the visit to always return nullptr
even when the TupleTreeReference was well-formed. This has been fixed by
adding an overload with proper concept constraint, that teaches
CallByPathVisitorWithInstance how to properly traverse
UpcastablePointers.
2021-06-09 20:13:27 +02:00
Pietro Fezzardi baeae84c65 UpcastablePointer: use std::is_void 2021-06-09 20:13:27 +02:00
Pietro Fezzardi b4395794dd KeyedObjectTraits: drop useless template parameter
The second template parameter, defaulted to void, was only used for
SFINAE with enable_if. Now that all uses of enable_if are gone replaced
by concepts, this parameter does not serve any purpose anymore.
2021-06-09 20:13:27 +02:00
Filippo Cremonese 478baf1f43 Fix use-after-free in InstructionTranslator 2021-06-09 18:42:56 +02:00
Filippo Cremonese 5004ec789e Fix multiple cppcoro issues
* Assert that the coroutine has reached its final suspension point
  when the destructor is called.
* Ensure the move assignment operator takes an rvalue reference.
* Explicitly delete the copy assignment operator.
2021-06-09 18:42:34 +02:00
Antonio Frighetto 1e68b6e665 EnforceABI: drop handleRoot
Unmaintained code has been removed.
2021-06-09 18:39:43 +02:00
Antonio Frighetto 67b6bc491b BinaryFile: always relocate addresses
Always relocating addresses allows to include symbols on
dynamically linked position independent objects as well.
2021-06-09 18:15:16 +02:00
Matteo Giordano 04c5b5c5c3 MetaAddress.cpp: fix on fields processing order
Adjusted methods `MetaAddress::toConstant()` and
`MetaAddress::fromConstant()` in processing the order of MetaAddress
field.
2021-06-09 18:14:16 +02:00
Ivan Krysak bc8c8f82d2 Prevent separation of 'main' headers into group 0
The prevention mechanism uses a dummy suffix:
'_THIS_SEQUENCE_IS_NEVER_GOING_TO_HAPPEN'.
2021-06-09 18:05:20 +02:00
Ivan Krysak 2e214bc661 Add an include category for Qt headers 2021-06-08 17:03:58 +02:00
Alessandro Di Federico b150274a1f Import overview document 2021-05-14 13:45:00 +02:00
Alessandro Di Federico 5a002a6fc9 Merge branch 'feature/various-bugfixes' 2021-05-12 18:59:56 +02:00
Alessandro Di Federico 0af0fea277 Handle R_386_32 relocations 2021-05-12 18:42:17 +02:00
Alessandro Di Federico 5878fee3e2 Make PCH::addCaseToDispatcher more efficient
Checking if a `SwitchInst` has a certain case triggers a linear search.
When we have *a lot* of jump targets this is an issue.

This commit assumes that when we add a case to a dispatcher, that case
is not already there.
2021-05-12 18:42:13 +02:00
Alessandro Di Federico ec0a1c7d3e Fix dispatcher.external
`dispatcher.external` used to jump to itself due to a misuse of
`replaceAllUsesWith`.
2021-05-12 18:42:08 +02:00
Alessandro Di Federico 10eb8e498a AVI: handle Undef
Also, be more verbose on an unexpected instruction.
2021-05-12 18:31:23 +02:00
Alessandro Di Federico 9be97248ce Reorganize VariableManager
This commit slightly improves VariableManager's API and, most
importantly, undef-initializes all TCG variables in order to avoid
creation of complex PHIs.
2021-05-08 19:27:57 +02:00
Alessandro Di Federico cfddcceb3e IRHelpers: non-const getModule(...) 2021-05-08 19:27:57 +02:00
Alessandro Di Federico 82260c2693 Make dumping assembly and PTC optional
Output files can become *very* large.

This commit disables by default dumping disassembled instructions and
PTC code into the IR.
2021-05-08 19:27:57 +02:00
Alessandro Di Federico 91991bb694 Handle PHIs in lifted code
In large binaries PHI nodes show up. As a consequence, calls to `newpc`
are no longer the first instruction.

This commit uses the `getFirstNonPHI` method to fix this issue.
2021-05-08 19:19:41 +02:00
Alessandro Di Federico c04a30e703 Model: fake functions have no blocks 2021-05-08 11:39:10 +02:00
Alessandro Di Federico 1ac2884f2e Handle blocks ending with unreachable
Sometimes basic blocks end with an
2021-05-08 11:39:10 +02:00
Alessandro Di Federico 871931b9cd Test TupleTreeDiff on Model
`TupleTreeDiff` was not being tested.

This commit implements several `operator==` that are required to
successfully instantiate `TupleTreeDiff`.
2021-05-06 15:42:16 +02:00
Alessandro Di Federico e62f888381 Drop KeyTraits
This commit drops the KeyTraits in favor of a std::any-like solution.
Basically, we type erase any key the user wants to employ, just exposing
a virtual version of the destructor, a comparison operator and a clone
primitive.
2021-05-06 15:42:00 +02:00
Pietro Fezzardi b58693b8e8 RecursiveCoroutine: enable direct continuation
Before this commit, the execution logic of RecursiveCoroutine used an
underlying std::stack allocated on the heap to hold all the
coroutine_handles. It also manually managed passing return values from
callees to callers.

This commit drops this unnecessary auxiliary stack.
When a RecursiveCoroutine co_awaits another one, the handle of the
awaiter is injected into the awaitee, so that when the awaitee is done
it can directly execute the remaining part of the awaiter as a
continuation.
2021-05-05 17:48:04 +02:00
Alessandro Di Federico bca502aeaa Merge branch 'feature/extend-model' 2021-05-05 17:13:16 +02:00
Alessandro Di Federico 7e637beef3 Import static TupleTree validation routines 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 9650369fa7 Import TupleTree and TupleTreeReference 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 0d77258109 Introduce HasKeyObjectTraits concept 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 508bc4eb00 Minor changes 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 6fd8a87572 TupleTree, visit: rename and make more usable 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 51682eb024 model::FunctionEdge: carve out CallEdge 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 582dee6fcc TupleTree: support UpcastablePointer 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 702f4230ac Import UpcastablePointer 2021-05-05 17:10:12 +02:00
Alessandro Di Federico a6468d8d22 Minor changes 2021-05-05 17:10:12 +02:00