Commit Graph

945 Commits

Author SHA1 Message Date
Alessandro Di Federico a65ccc3413 Introduce ValueMaterializer
`ValueMaterializer` is a rewrite of what was called `AdvancedValueInfo`
which follows the same principles.

The main benefits over the old version is:

* We materialize the data-flow graph and the CFG of the relevant part of
  root. This makes debugging significantly easier.
* We drop the old MonotoneFramework infrastructure in favor of
  getMaximalFixedPoint.
* We significantly reduce the amount of queries we make to
  AdvancedValueInfo.
2023-06-30 13:39:22 +02:00
Alessandro Di Federico 4edcb6dd49 MetaAddress::decomposeIntegerPC: accept APInt 2023-06-30 13:35:04 +02:00
Alessandro Di Federico 466871e866 Introduce RegisterClobberer 2023-06-30 13:28:36 +02:00
Alessandro Di Federico f120ad334c Statistics.h: rework 2023-06-30 13:06:58 +02:00
Alessandro Di Federico 6ca6692d1e getUniqueJumpTarget: do not abort if PC unwritten
Sometimes code performs an indirect jump without changing the value of
the PC.  In most cases this is due to non-code or some other faulty
situation, but it is in principle possible that an instruction performs
an indirect branch to its own address.

This commit ensures that this situation does not end up in an hard
failure.
2023-06-30 12:35:18 +02:00
Alessandro Di Federico 3706f77960 LDDTree: mark Logger static 2023-06-30 12:35:18 +02:00
Alessandro Di Federico 942cc1323a revng::verify: dump module upon failure 2023-06-23 17:54:55 +02:00
Alessandro Di Federico 55d433e020 Layout::verify: be stricter on return values
We now ensure that, if we have multiple return values, each one of them
covers at most one register.
2023-06-21 10:56:27 +02:00
Alessandro Di Federico 0af9b34a0a Layout: make ReturnValues empty in case of void 2023-06-21 10:55:50 +02:00
Djordje Todorovic f05c08547d ptml: Introduce PTMLBuilder class
By using this class we can create ptml::Tags without
XML tags. It is useful in the revng-c part when we
want to generate Plain C. All PTML Tags, from now on,
should be created via this class only.

In addition, port `Yield` library to be using this.
2023-06-09 17:15:30 +02:00
Ivan Krysak 66fc161f73 Assembly: choose disassembler based on basic block
Before now, it was choosen based on the function, but that led to
problems when disassembling thumb functions calling non-thumb PLTs.
2023-05-25 09:49:13 +02:00
Ivan Krysak 29eae116fd Assembly: handle addresses in a special way 2023-05-25 06:37:40 +00:00
Ivan Krysak 5cdb1642bb Assembly: rework tag processing 2023-05-25 06:37:30 +00:00
Ivan Krysak f0a29f17b9 Assembly: Introduce address style options 2023-05-25 06:37:21 +00:00
Ivan Krysak 9dfc350b1a Assembly: do not add "next instruction" as target 2023-05-25 06:36:26 +00:00
Ivan Krysak c21f2649c9 Assembly: introduce new tags
This also reorders the enum, because when two tags collide (they have
the same `from` and `to` points, they are sorted based on the enum
values.

The new order ensures that the values we are more likely to choose
to preserve are closer to the bottom. Since each token can only have one
type associated with it, we choose the lowest one by default.
2023-05-25 06:36:02 +00:00
Ivan Krysak 6a407a94bf Assembly: partition label helper
This moves the internal implemetation details into a separate
function `labelImpl` as well as renames the `label` into
`labelDefinition`.
2023-05-25 06:35:58 +00:00
Ivan Krysak f3918e3305 Assembly: change label to accept BasicBlockID 2023-05-25 06:25:25 +00:00
Ivan Krysak 02978910b0 STLExtras: introduce zip_pairs skip flavour
I found that it leads to better looking code when the check of whether
the range in question even has enough elements to skip is inside
the helper.

As such a separate type of skip entry point was introduced: one that
allows to iterate over the container pairwise

Now, instead of asserting, the loop just does nothing in cases like
```cpp
for (const auto &Element : zip_pairs(make_empty_range())
  do_stuff();
```
2023-05-25 06:25:07 +00:00
Ivan Krysak d1cefaee04 PTML: ensure invalid labels are never emitted 2023-05-25 06:25:07 +00:00
Ivan Krysak 560bf16d1f Disassembler: support arbitrarily sized tags 2023-05-25 06:25:07 +00:00
Ivan Krysak 4699c2da72 Assembly: remove ShouldSymbolizeOperands option 2023-05-25 06:25:07 +00:00
Ivan Krysak f9a72125d3 Aseembly: accept relative jump targets
Drops the comment about an attempt to switch to the absolute targets
and sets `setPrintBranchImmAsAddress` to `false` no matter what
immediate style is selected.
2023-05-25 06:25:07 +00:00
Ivan Krysak 83e48bbc3a LLVMDisassemblerInterface: remove unused argument 2023-05-25 06:25:07 +00:00
Ivan Krysak 5b2af637de Minor Changes 2023-05-25 06:25:07 +00:00
Ivan Krysak 0170c0dfeb Model: add segment overlap check to verification 2023-05-17 14:08:06 +02:00
Ivan Krysak c838d2b019 CrossRelations: greatly simplify Relation Targets
This improves readability of the serialized version quite a bit.
2023-05-17 14:08:06 +02:00
Ivan Krysak eae029d156 CrossRelations: merge IsCalledFrom flavors
`IsDynamicallyCalledFrom` is removed in favour of `IsCalledFrom`.

Looking at just how similar the actual uses of both are, there's not
much reason to keep them separate.
2023-05-17 14:08:06 +02:00
Ivan Krysak 641fb61f7b EFA: upgrade buildControlFlowGraph
It now assumes that the nodes of the graph it constructs also require
the function entry point on top of the basic block ID.
2023-05-17 14:08:05 +02:00
Ivan Krysak fade3ec01f CallGraph: switch to pipeline::Location 2023-05-17 14:08:05 +02:00
Ivan Krysak 7322d1a845 ControlFlow: switch to pipeline::Location 2023-05-17 14:08:05 +02:00
Ivan Krysak 50b5abf505 Yield: add isEmpty() helper to graph nodes 2023-05-17 14:08:05 +02:00
Ivan Krysak 013696a939 yield: move SVG out of the ControlFlow
Since the file is also used for call graphs, it's placement is not ideal
2023-05-17 14:08:05 +02:00
Ivan Krysak 045cdefcac GraphLayout: move outside of yield 2023-05-17 14:08:04 +02:00
Ivan Krysak d99b0241e8 Minor improvements 2023-05-17 14:08:04 +02:00
Alessandro Di Federico 14b40ebe45 CFEP: ignore if already part of another block
We used to ignore CFEPs that matched the starting address of a basic
block of a previously detect function.
We now also exclude such CFEPs even if the candidate is *part* of an
existing block.
2023-05-17 11:19:32 +02:00
Alessandro Di Federico 739bed3c1d DetectABI: serialize CFG in root
This is done mainly so that downstream passes do not need to run
`CollectCFG` to store information that has already been computed but not
serialized.

This come at the cost of computing the CFG also of functions we don't
want to analyze in `DetectABI`.
2023-05-17 11:17:44 +02:00
Alessandro Di Federico d0b235c1f4 JTM::findCodePointers: ignore non-aligned data 2023-05-17 11:17:41 +02:00
Alessandro Di Federico b3eaae6f83 ELFImporter: fix handling of DT_{INIT,FINI} 2023-05-17 11:17:39 +02:00
Giacomo Vercesi 31cd2b53f9 rcc: add codespell
Add codespell to the list of checks performed by
revng-check-conventions. This should reduce the amount of typos present
in the revng codebase.
2023-05-11 10:05:32 +02:00
Alessandro Di Federico 92c028235f Introduce WellKnownModels analysis 2023-05-10 11:16:08 +02:00
Alessandro Di Federico b112d51154 LDDTree: rewrite findLibrary
`findLibrary` has been rewritten to adhere more strictly to `man ld.so`.
Also, `lddtree` no longer relies on sections headers.
2023-05-10 11:04:52 +02:00
Alessandro Di Federico abc380017b {ELF,Dwarf}Importer: fix ExportedNames
Under certain conditions, upon import, functions where not being added
`ExportedNames`, which was preventing them from finding the prototypes
from dynamic libraries' debug information.
2023-05-10 09:21:43 +02:00
Alessandro Di Federico f562d0373f Importers: fix usage of BaseAddress
This commit ensure the BaseAddress is propagate as appropriate to all
levels of the importers and that it is ignored for executables
(non-PIC).

This was a recurring source of importing the same function twice, once
relocated, once not.
2023-05-10 09:20:40 +02:00
Alessandro Di Federico 5fbaebe153 DwarfImporter: handle DW_AT_abstract_origin 2023-05-10 09:20:15 +02:00
Alessandro Di Federico 73fb1a31c9 Outline TypeCopier
This commit also drop the suggestion that it should be used for copying
prototypes only.
2023-05-10 09:20:15 +02:00
Alessandro Di Federico 4c0f809626 Introduce PathList::list 2023-05-10 09:17:35 +02:00
Alessandro Di Federico 680c706771 DetectABI: introduce extra assertions 2023-05-10 09:15:04 +02:00
Alessandro Di Federico eca3e49b77 LLVMContainer: reduce verifications 2023-04-28 14:35:00 +02:00
Alessandro Di Federico da25162d74 JumpTargetManager: drop assertNoUnreachable
The assertion cannot really hold under certain CFG forms.
2023-04-28 14:34:58 +02:00