Commit Graph

2366 Commits

Author SHA1 Message Date
Ivan Krysak 04efcb8ed8 Drop the revng yield .* tools 2022-06-14 18:55:59 +03:00
Ivan Krysak bc775a91b4 Improve the String wrapper 2022-06-14 18:55:59 +03:00
Pietro Fezzardi 8b812680ea DLACollapsSingleChild: push padding to parent 2022-06-14 12:51:48 +02:00
Pietro Fezzardi af760942e7 DLATypeSystem: add API to move edge target 2022-06-14 12:51:48 +02:00
Ivan Krysak 150fab6bbc Fix a minor pipeline::Target construction issue 2022-06-14 12:40:11 +03:00
Ivan Krysak 257bcb9b3c Make MetaAddress constexpr constructible 2022-06-14 12:40:11 +03:00
Ivan Krysak dffe311ad8 Add efa::FunctionEdgeType::needsFallthrough 2022-06-14 12:40:11 +03:00
Massimo Fioravanti 22bce466b1 revng-pipeline: support handles multiple branches
This commit introduces the possibility to have multiple pipeline
branches in a single YAML pipeline file.
2022-06-13 18:34:03 +02:00
Pietro Fezzardi 9898c980d7 DLA: make TypeLinkTag serializable to Loggers 2022-06-08 14:11:55 +02:00
Alvise de Faveri e3e5210084 DLA: Ignore offsets greater than 64K
When creating the DLA graph, we want to avoid inserting `instanceOf`
edges with huge offsets, so we set a limit to 64K.

This is a workaround to handle cases in which we make wrong decisions
about the base address of a SCEV expression. One of the situations in
which this occurs are expressions such as `&val + BIG_CONST`, for which
we always identify `%val` as the address and `BIG_CONST` as the offset.

When fixing this case, we should still verify that this never happens.
2022-06-01 11:25:59 +02:00
Alvise de Faveri 64c096df0b GHAST: Mark printing helpers as debug_functions 2022-06-01 11:22:43 +02:00
Alvise de Faveri 00c022119e Support: Add isCallToTagged() helper 2022-06-01 11:19:24 +02:00
Alvise de Faveri 190e91f4f4 Support: Add getPointerSizedInteger() 2022-06-01 11:17:42 +02:00
Alvise de Faveri c7264badae Support: Add serializeToLLVMString(QualifiedT) 2022-06-01 11:08:29 +02:00
Alvise de Faveri 189fbe4651 Support: Fix the key for OpaqueExtractValue pool
Calls to `OpaqueExtractValue()` are meant to replace `extractvalue`s
found in the LLVM IR. Since the type of an `OpaqueExtractValue` is
identified by both the return type (extracted value) and the first
argument's type (aggregate operand of the `extractvalue` instruction),
we need to consider both when building the associated FunctionPool.

Previously, we were identifying each `OpaqueExtractValue` variant using
only the returned value, which was wrong. In fact, if we have two
`extractvalue` instructions that extract a value of the same type
(e.g. i32) from two different aggregate types (e.g. structA and
structB), we have to define two different `OpaqueExtractValue`: one
that returns an i32 and has a parameter of type structA, and one that
returns an i32 and has a parameter of structB. If we use only the
return type, we are not able to distinguish the two.
2022-06-01 11:05:31 +02:00
Pietro Fezzardi 31419a5fd1 Remove old unused dla::Layout class
This class was introduced before having model::Type, to represent
roughly the same information.

Now it's dead code and this commit removes it.
2022-05-26 16:46:47 +02:00
Giacomo Vercesi 7052f2a8a0 Support analyses and globals in Python
This commit adds the newly implemented functionality in PipelineC both
in revng.api and the graphql api, allowing:

* retrieval of global variable names
* unwrapping of a single target
* execution of analyses
2022-05-24 10:56:02 +02:00
Massimo Fioravanti 1508a1bc72 revng-pipeline: support out of line analyses 2022-05-24 08:59:08 +02:00
Massimo Fioravanti e38dfc74cc PipelineC: introduce run_all_analyses 2022-05-24 08:59:08 +02:00
Massimo Fioravanti f0a5ffe3b3 revng-pipeline: globals, extractOne and analyses 2022-05-24 08:58:48 +02:00
Massimo Fioravanti 2c48713af9 Make TupleTreeDiff compatible with regular vectors 2022-05-24 08:50:24 +02:00
Pietro Fezzardi 1bb5bd6eee ModelGlobal: don't move the underlying model::Binary
Moving it was causing the address of the model to change, while for the
functionality of revng-pipeline we need it to be stable.

So we pay the price of expensive copy, for the sake of downstream
stability.
2022-05-12 16:59:47 +02:00
Pietro Fezzardi 741d55279b TupleTree: add copy-constructor and -assignment
The copy of a TupleTree is potentially very expensive, so it was
disabled until now and only allowed via the explict method clone().

We have now decided to make TupleTree copiable.
This commit adds a copy-constructor and a copy-assignment, killing the
clone() method that was already unused and is now effectively useless.
2022-05-11 16:16:49 +02:00
Pietro Fezzardi b190f1a47c Refactor logic to compact function targets
This commit introduces a reusable function to compact
pipeline::TargetLists that represent functions.

Initially this reasoning was only needed by TaggedFunctionKind, but now
also FunctionStringMap needs it, and potentially others in the future,
so it makes sense to keep only a single implementation for it instead of
duplicating code (and likely bugs).
2022-05-11 16:16:49 +02:00
Pietro Fezzardi ca566a76f0 Rename StringMapContainer to FunctionStringMap
This new naming more closely describes the fact that each element in the
map must be associated with a model::Function
2022-05-11 16:16:32 +02:00
Pietro Fezzardi 7d097ba3e0 Move CDecompilationPipe in lib/Backend 2022-05-11 15:21:41 +02:00
Pietro Fezzardi 42b52bb22b Add DecompiledYAMLToCPipe 2022-05-11 15:21:39 +02:00
Pietro Fezzardi 4188b709be Merge BeautifyGHAST back into RestructureCFG
The beautification library was split into a separate library for
historical reason, having to do with LLVM passes, their dependencies,
and dirty hacks we had around.

Now the LLVM passes, and the hacks are gone, so we can merge back
everything together.
2022-05-11 15:19:34 +02:00
Pietro Fezzardi 97f0f8c521 IRHelpers: add deleteOnlyBody helper 2022-05-11 15:19:34 +02:00
Pietro Fezzardi 604d370239 Remove LLVM passes RestructureCFG, BeautifyGHAST
Now that the late stage of the decompilation pipeline is managed with
revng-pipeline, and we have a standalone tool for decompilation, we
have no need to use LLVM passes anymore for those stages.

This commit also renames the directories to avoid the confusing Pass
suffix, not what LLVM passes are gone.
2022-05-11 15:19:34 +02:00
Pietro Fezzardi fc40f646a4 Replace CBackendPass with revng-decompile tool
This commit replace the old CBackendPass with a standalone tool:
revng-decompile.
This pass at the moment runs the three stages of decompilation:
  - CFG restructuring
  - Beautify GHAST
  - C Code generation
2022-05-11 15:19:25 +02:00
Pietro Fezzardi bce0bd70b1 StringMapContainer: fix enumeration for * target 2022-05-11 14:52:22 +02:00
Pietro Fezzardi 2dea29d926 StringMapContainer: use multiline strings in YAML 2022-05-11 14:39:31 +02:00
Pietro Fezzardi 0f4df96ad6 Mark some dump() methods as debug_function 2022-05-11 14:39:31 +02:00
Pietro Fezzardi bfe67413d3 StringMapContainer: find() and contains() methods 2022-05-11 14:39:31 +02:00
Pietro Fezzardi 1c6dac225a Add dedicated non-generated TypeKind.h header
This is necessary because now QualifiedType.h needs TypeKind, but
including Type.h directly would result in a circular dependency between
Type.h and QualifiedType.h
2022-05-11 14:39:31 +02:00
Pietro Fezzardi 238b98c3da Switch all revng-c to revng-pipeline 2022-05-11 12:42:38 +02:00
Pietro Fezzardi f8c512f0b8 Drop LLVM passes from lib/HeadersGeneration
Now the emission of C headers for decompilation is entirely handled
through the new revng-pipeline infrastructure and/or via standalone
tools.
2022-05-11 12:42:38 +02:00
Pietro Fezzardi c88504afbf Drop old flag -single-decompilation
This flag was used with the old C backend to decompile only a single
function from a binary.

The logic of selecting functions in a binary for decompilation is now
part of revng-pipeline, so the -single-decompilation option and the
associated TargetFunctionOption library can be dropped.
2022-05-11 12:42:38 +02:00
Pietro Fezzardi 5071fe8dc4 Add CDecompilationPipe 2022-05-11 12:42:38 +02:00
Pietro Fezzardi 56de892efb Add HelpersToHeaderPipe 2022-05-11 12:42:38 +02:00
Pietro Fezzardi 7e926db200 Add ModelToHeaderPipe 2022-05-11 12:36:32 +02:00
Giacomo Vercesi 8a61d7c2b9 Model/ABI.h: make doc fields multiline 2022-05-09 13:35:10 +02:00
Ivan Krysak 282b4e238d Add yield-assembly pipeline 2022-05-06 18:51:47 +02:00
Ivan Krysak cf3845b78d Add a way to output assembly as plain text 2022-05-06 18:51:47 +02:00
Ivan Krysak 1adc74e660 Import an assembly to html converter from caliban 2022-05-06 18:51:47 +02:00
Ivan Krysak 6e81dbe06c Add a disassembly helper 2022-05-06 18:51:47 +02:00
Ivan Krysak 36c63c1bb9 Implement the disassembler interface 2022-05-06 18:51:47 +02:00
Ivan Krysak 6125ad4a71 Define internal assembly representation 2022-05-06 18:51:47 +02:00
Ivan Krysak cfc9915b39 Add ModelInModule::getModule. 2022-05-06 18:51:47 +02:00