Commit Graph

575 Commits

Author SHA1 Message Date
Pietro Fezzardi 067f2fffe1 Add ModelToHeader 2021-11-15 11:47:17 +01:00
Pietro Fezzardi 432cf351d7 AddSCEVBarrierPass.h: declare function extern 2021-11-12 18:36:19 +01:00
Pietro Fezzardi 15cc5d2a42 libRestructureCFGPass: link revngModel 2021-11-04 10:00:11 +01:00
Pietro Fezzardi 032463c539 Fix handling of calls with unnamed callees 2021-10-12 09:57:30 +02:00
Alvise de Faveri e90020b94c Don't visit the same union twice during dedup
Optimization to avoid checking the same union node multiple times.
2021-10-11 18:28:03 +02:00
Alvise de Faveri a6d0d52107 Remove leftover call from debugging session
RemoveConflicts should not be needed here, as it runs before in a
separate step and is also ran during deduplication.
2021-10-11 18:25:18 +02:00
Alvise de Faveri e2dd34e08e Avoid comparing a node with itself in union dedup 2021-10-11 18:21:53 +02:00
Alvise de Faveri 43ae7a91cb DLA: Add DeduplicateUnionFields Step
Add a step that recognizes if two subtrees of a union node are
topologically equivalent and merges them. This corresponds to removing
duplicate fields in unions.

This deduplication was prevously done while emitting layouts.

A check is inserted into DLAMakeLayouts to assert that, after
constructing unions, no union has only one child, which could be the
case if we didn't deduplicate union fields in the graph.
2021-10-06 16:37:37 +02:00
Alvise de Faveri 637bf70ff3 DLA: Make CollapseSingleChild a function
Since the reasoning behind single child collapsing can be reused in
other points of the DLA pipeline, move the logic that acts on a single
node in a static function out of the CollapseSingleChild step.
2021-10-05 18:16:21 +02:00
Alvise de Faveri 7e72fc4be1 DLA: Add RemoveConflictingEdges step
Add a DLA step that removes all instance-at-offset-0 edges between nodes
that already have an inheritance edge between them.
2021-10-05 18:16:21 +02:00
Pietro Fezzardi fda2b0042f Drop Beautify dependency on MarkForSerialization 2021-09-22 19:01:44 +02:00
Pietro Fezzardi 7ceb6d2f16 Extract BeautifyGHAST in a separate library 2021-09-22 19:00:09 +02:00
Pietro Fezzardi ce0083a7ff Extract MarkForSerialization in separate library 2021-09-22 15:03:12 +02:00
Pietro Fezzardi eea93438cc Alphabetically sort lib/CMakeLists.txt 2021-09-22 14:57:32 +02:00
Pietro Fezzardi a2a29c7942 Fix missing linking with revng and LLVM libraries 2021-08-31 12:30:04 +02:00
Pietro Fezzardi f057441ce8 Fix linking 2021-08-20 11:21:04 +02:00
Andrea Gussoni 55c620ab31 RegionCFGTree: refactor connectContinueNode
THe creation and connection of continue nodes is now down in the
population of the collapsed region, avoiding external methods.
2021-08-19 18:51:24 +02:00
Andrea Gussoni 7323cecec1 RestructureCFG: improve break node creation
Break node creation is now improved to avoid edge index swapping that
can cause inversion of conditions later on in the decompilation
pipeline.

To do this, the creation and connection of the break nodes is done
during the bulk insertion of nodes in a collapsed region.
2021-08-19 18:51:14 +02:00
Andrea Gussoni 866ab7cbed CDecompilerAction: fix expression negation
The `negateExpr` function incorrectly changed the `OpCode` of a binary
comparison, resulting in not intended side effects.
2021-08-19 18:50:39 +02:00
Alvise de Faveri a0f95e0370 Modify CollapseSingleChild to allow single members
* Inheritance straight lines are now collapsed by CollapseSingleChild
* Don't collapse if parent has more than one parent or if the child has
more than one parent
* Allow the possibility to construct single-member struct: if this
struct is inherited by many other structs, "flattening" the struct is not
the most sensible thing to do, since inheritance information is something
we want to preserve in these cases.
2021-07-27 11:59:48 +02:00
Pietro Fezzardi 10d1eab7f4 Decompiler: update to new model APIs 2021-07-21 11:09:28 +02:00
Pietro Fezzardi e1ab2ff553 ASTBuildAnalysis.cpp: disable array accesses 2021-07-21 10:48:06 +02:00
Pietro Fezzardi 88ade5e105 Handle non-decreasing nested AddRecs
These may happen in nasty functions like memchr, where you have a loop
pre-header iterating over single bytes, a loop iterating over 4 bytes,
and finally the loop exit iterating over single bytes again.

Now we stop at the first non-decreasing nested AddRec.
2021-07-21 10:48:06 +02:00
Pietro Fezzardi f2dd2d89de ASTBuildAnalysis: improve logging 2021-07-21 10:48:06 +02:00
Pietro Fezzardi c994dc0b44 ASTBuildAnalysis: drop assertion for handled case 2021-07-21 10:48:06 +02:00
Pietro Fezzardi 81cb8422ad ASTBuildAnalysis: build member access expressions 2021-07-21 10:48:06 +02:00
Pietro Fezzardi ae0095e90a DLA: handle Values with unknown Layouts 2021-07-20 15:20:53 +02:00
Alvise de Faveri 4eb50d0bb5 Add Unit Test for DLACollapseSingleChild 2021-06-30 17:50:12 +02:00
Alvise de Faveri c1e4b940d0 Add CollapseSingleChild step to DLA 2021-06-30 17:50:12 +02:00
Alvise de Faveri 47db3fdb11 Promote AccessSizes to full-fledged TS nodes
While doing thie, also drop `printAccessNode()` from DLA DebugPrinter.

The information about which LLVM instruction originated a given access
node is already available in the csv generated by the `dla-accesses-log`
logger.
2021-06-25 18:07:17 +02:00
Pietro Fezzardi d09c7c6ab3 Handle inheritance in with interfering children
Until now, in makeLayout, inheritance edges were ignored when the
children were interfering.
Now the inheritance edges are treated as if they were instance edges at
offset 0.
2021-06-24 17:24:59 +02:00
Pietro Fezzardi 18bff2dba1 DLAMakeLayouts.cpp: drop unused variable 2021-06-24 17:24:59 +02:00
Pietro Fezzardi 6a2e130ec6 Move openFunctionFile to new Utils library 2021-06-21 14:15:30 +02:00
Alvise de Faveri bfdef657f2 Move DLA files to separate folder 2021-06-18 18:24:04 +02:00
Alvise de Faveri 105edb69a3 DLA: Decouple DLATypeSystem from LLVM Values
- Remove `CreateInterProceduralTypes` and `CreateIntraProceduralTypes`
  from the StepManager and put them in a separate
  `DLATypeSystemLLVMBuilder` object that is in charge of initializing
  the DLATypeSystem graph.
- Remove `MakeLayouts` from the StepManager and split into two free
  functions: `makeLayouts` and `makeLayoutMap()`
- Remove all LLVM-related stuff (Module, LayoutTypePtrs and mappings
  between these and DLATypeSystemNodes) from DLATypeSystem
- Add an IntEqClasses member to DLATypeSystem, to use to map between
  LayoutTypePtrs and Layouts
- Add a TSDebugPrinter object inside the DLATypeSystem, which by default
  prints only IDs
- Define an LLVMTSDebugPrinter inside DLATypeSystemBuilder which
  overrides the default printer's behavior, printing LLVM-related info.
- Add the possibility to dump into a .csv file the bindings between
  Nodes in the TypeSystem and `llvm::Value`s
2021-06-18 18:12:14 +02:00
Pietro Fezzardi dfd81a017d Use std::has_single_bit and std::bit_ceil 2021-06-09 14:37:37 +02:00
Pietro Fezzardi 260df31adc ASTBuildAnalysis.cpp: fix emission of ternary 2021-05-31 12:23:32 +02:00
Pietro Fezzardi 65907f892f decompileFunction: add pass required by llvm-12 2021-05-28 17:45:59 +02:00
Pietro Fezzardi 2fea7e3076 TypeFlowGraphWriter: update to llvm-12 API 2021-05-27 17:14:25 +02:00
Pietro Fezzardi 36e42855a5 PromoteStackPointer.cpp: fix deprecated include
This caused compilation error with llvm-12.
2021-05-27 17:14:25 +02:00
Pietro Fezzardi 9d3216970a IRASTTypeTranslation: handle new llvm-12 types 2021-05-27 17:14:25 +02:00
Pietro Fezzardi 80f1e2fd6d Explictly convert llvm::StringRef to std::string
Implicit conversion is not available anymore in llvm-12.
2021-05-27 17:14:25 +02:00
Pietro Fezzardi a5b42ea913 DLATypeSystem.cpp: update scc_iterator API 2021-05-27 17:14:25 +02:00
Pietro Fezzardi a63d1768ee DLACreateIntraProceduralTypes: add missing include 2021-05-27 17:14:25 +02:00
Pietro Fezzardi 8494034931 ASTBuildAnalysis.cpp: explicitly handle new kinds 2021-05-27 17:14:25 +02:00
Pietro Fezzardi 73ee5e8c34 Update to clang-12 API for AST creation 2021-05-27 17:14:25 +02:00
Pietro Fezzardi 798ea21963 Replace constprop with instsimplify
Constant Propagation has been dropped by llvm-12
2021-05-27 16:07:49 +02:00
Pietro Fezzardi 3436ed4125 DLATypeSystem.h: add missing include
This was causing compilation error with llvm-12
2021-05-27 15:04:03 +02:00
Alvise de Faveri e8dfaa3a86 DLA: Fix missing AccessLayout field in structs
The BaseLayout should be the fist field of each StructLayout, but it
is never really added.
2021-05-21 18:50:58 +02:00
Pietro Fezzardi 13170f0a2a DLARemoveTransitiveInheritanceEdges: fix UAF
Accessing NextChildPos is not safe if Pushed is true.
This commit switches the conditions so that NextChildPos is never
accessed unsafely thanks to short-circuiting.
This fixes a use-after-free bug, that was activate when calling tryPush
triggered realloc on the Stack.
2021-05-19 10:31:07 +02:00