Commit Graph

465 Commits

Author SHA1 Message Date
Giacomo Vercesi 8b2da15c18 revng-pipeline: introduce artifacts
Add a new key to a Step, named Artifacts. If present, it indicates that
the step has a "default" Kind and Container that can be easily retrieved
without explicitly specifying either when producing an artifact.
2022-04-26 15:05:30 +02:00
Giacomo Vercesi 9b16efefc2 Add MIMEType to container
Add additional field MIMEType to Container.

This allows API consumers to know at runtime how to treat the data
within a container without any prior knowledge.
2022-04-26 15:05:30 +02:00
Giacomo Vercesi f4d63759de PipelineC: expose kinds, ranks and more
Adds missing API functions to PipelineC that will be needed by the
GraphQL API:

* Kinds enumeration
* Get Rank and parent of a Kind
* Enumerate and inspect Ranks
* Get a Step's parent

Included are some docstring fixes
2022-04-26 15:05:30 +02:00
Giacomo Vercesi b90773b642 Move librevngRecompile to analyses 2022-04-26 15:05:30 +02:00
Giacomo Vercesi a831fa8e74 ContainerSet: add isContainerRegistered
This function allows to check if a container is registered,
irrespective of its initialization status
2022-04-26 15:05:30 +02:00
Filippo Cremonese 1bab3d8137 PipelineC: fix returning reference to local
'PathComponents` was copied on the stack by the assignment and then a
pointer to it is returned by `c_str`, leading to a use-after-free since
it is freed when going out of scope
2022-04-26 15:05:30 +02:00
Filippo Cremonese 19ff90e499 PipelineC: fix off-by-! in LoadLibraryPermanently 2022-04-26 15:05:30 +02:00
Pietro Fezzardi 0ff8a6933b Add StringMapContainer 2022-04-20 17:39:59 +02:00
Alvise de Faveri a3110c0b59 Add QualifiedType::is(TypeKind) 2022-04-20 11:25:46 +02:00
Antonio Frighetto ab4bdf398d EFA: leverage ABI-specific layer
Architecture-agnostic results provided by EarlyFunctionAnalysis
are refined through an ABI-specific layer.
2022-04-15 18:25:11 +02:00
Antonio Frighetto 7235f69a99 EFA: add final results to ABIAnalysis::dump
Output `FinalReturnValuesRegisters` results for aiding debugging tasks.
2022-04-15 18:25:11 +02:00
Ivan Krysak 66c96fb128 ABI: improve RegisterStateDeductions
Split the interface into two functions: `enforce.*` returning the map by
value and `tryApply.*` returning an `std::optional`.

Improve non-positional single deduction function to better reflect
some corner cases (for example how a required `NoOrDead` register
argument is handled).

Enforce a position-based deduction corner case where it's impossible to
deduce whether the argument is passed in the GPR or the vector one -
now GPR takes precedence in those cases.
2022-04-15 18:25:11 +02:00
Massimo Fioravanti ea02b4080a PipelineC: introduce rp_apply_model_diff
This exposes the invalidation to users of the C API.
2022-04-15 15:18:56 +02:00
Massimo Fioravanti 3d752f6c7f Introduce revng pipeline --invalidate-all 2022-04-15 15:18:28 +02:00
Massimo Fioravanti eef9ba74da Introduce ModelInvalidationEvent 2022-04-15 15:17:58 +02:00
Massimo Fioravanti 60fd53b1fb Introduce Kind::verify 2022-04-15 15:17:37 +02:00
Massimo Fioravanti 1b489d9d8c FileContainer: remove invalidated container
If a file container becomes empty, it the old file on disk has to be
removed.
2022-04-15 15:16:24 +02:00
Massimo Fioravanti 44720eedbd Redesign TupleTreeDiff
`TupleTreeDiff` is now type-safe and owns the changes.
2022-04-15 15:14:13 +02:00
Pietro Fezzardi 7f65b1117a New AddPrimitiveTypesPipe
This pipe is executed during the Lift step and populates the model with
all the required primitive types.
2022-04-12 16:40:27 +02:00
Pietro Fezzardi 0c12c47514 Pipes: initialize all llvm passes 2022-04-12 16:17:57 +02:00
Pietro Fezzardi a4dc1e52fd EnforceABI: add FunctionTags::ABIEnforced tag 2022-04-12 14:15:01 +02:00
Pietro Fezzardi 69d65956bf PromoteCSV: add FunctionTag::CSVsPromoted tag 2022-04-12 14:14:19 +02:00
Pietro Fezzardi 77cdc09e37 TaggedFunctionKind: skip Fake functions targets 2022-04-11 09:41:53 +02:00
Pietro Fezzardi 6b2b2e8ada Make model::Type::edges() method const 2022-04-08 18:58:58 +02:00
Pietro Fezzardi e40ded965f QualifiedType RawFunctionType.StackArgumentsType
The `StackArgumentsType` field of `RawFunctionType` was the only
cross-reference between `model::Type`s that did not use
`model::QualifiedType` but a naked `TupleTreeReference`.

Switching it to `QualifiedType` make all cross-references across
`model::Type`s homogeneous.
2022-04-08 18:58:58 +02:00
Pietro Fezzardi 63a6676551 Make EnumType.UnderlyingType a QualifiedType
This was one of the few places left in the type system where a
`model::Type` referred to another one not using QualifiedType, but a
naked `TupleTreeReference`.

Switching it to be a `model::QualifiedType` makes cross-references
between `model::Type`s more homogenenous, requiring less corner-cases
to handle for whoever manipulates types.
2022-04-08 18:58:58 +02:00
Giacomo Vercesi a2b5dbb1dc TupleTreeGenerator: autogenerate Kind 2022-04-08 17:36:59 +02:00
Giacomo Vercesi a5e3606144 Introduce model::FunctionEdge::Kind 2022-04-08 17:31:40 +02:00
Giacomo Vercesi 039f7db93e model::*: ensure Kind -> Class correspondence 2022-04-08 17:31:05 +02:00
Antonio Frighetto 276d168e32 Introduce LoadFunctionMetadataPass
LoadFunctionMetadataPass lazily loads a `std::map` from isolated
function MetaAddress to `efa::FunctionMetadata`, and caches it.
2022-04-05 20:50:20 +02:00
Antonio Frighetto 9980fc8c67 EFA: support dynamic function calls
EarlyFunctionAnalysis now can handle calls to
dynamically linked functions.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 499a837aac EFA: take a const model in Analyzer constructor
EarlyFunctionAnalysis now takes a `const TupleTree<model::Binary> &`
as part of `Analyzer` constructor, `finalizeModel` method excepted,
since it needs to write into the model.
2022-04-05 15:37:57 +02:00
Antonio Frighetto d6a1611c0a EFA: full ABI analysis or CFG collection only
EarlyFunctionAnalysis now can be invoked to schedule a full
ABI analysis over the collected functions via `--detect-abi`
option, or it can limit itself to simply recover the CFG and
serialize it onto the LLVM IR via `--collect-cfg` option.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 20cdfe668a EFA: take the control-flow graph out of the model
The control-flow graph and all its hierarchy components
have been moved from `model` to `efa`. The CFG is now
serialized onto the LLVM IR module as a metadata.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 98b79766be EFA: initialize cache by loading from model
The results of the model are loaded into the EarlyFunctionAnalysis
cache, and only those functions which are not in the model have
an EarlyFunctionAnalysis scheduled. The model is updated appropriately.
2022-04-05 15:37:57 +02:00
Antonio Frighetto ddc7fede5a EFA: optimize cross-call site propagation
Take advantage of directly iterating over the call-sites of a
function and perform the cross-call site merge, instead of
iterating over all the functions for each function.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 08b790329a EFA: fix end address of a jump target
EarlyFunctionAnalysis was considering jump targets as part of the
current basic block, thus computing the final address erroneously.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 12d8b1f222 EFA: remove reference template parameter
Code simplification to lighten the syntax.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 31926b7fe1 EFA: fix results on ABIAnalysis::dump method 2022-04-05 15:37:57 +02:00
Antonio Frighetto dad721941e JTM: set symbol name to OriginalName in newpc 2022-04-05 15:37:57 +02:00
Antonio Frighetto aae31a3a05 Introduce function entry-points collection passes
The collection of the function entry-points has now been separated
from EarlyFunctionAnalysis into two distinct passes: the first one,
which collects functions which are in call-sites of a direct call,
and the second one which collects code pointers in `.rodata` (e.g.,
function pointers, vtables; jump-tables are possibly skipped).
2022-04-05 15:37:57 +02:00
Antonio Frighetto c42909f2f2 FunctionIsolation: relax boundaries handling
FunctionIsolation used to expect the model to adhere too much to what
is on the IR. We relax some assumptions, particularly: 1) if there is
a leftover direct boundary, `IndirectBoundary` is set to it regardless;
2) in `handleDirectBoundary`, the actual successors of a block should
include all those in the model, however, we permit extra successors,
if they exist.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 5848063b66 TupleTree: make const TupleTree& behave as such
A logic issue was addressed with improved state management.
2022-04-05 15:37:57 +02:00
Antonio Frighetto c5b3fc4405 Rename ABIRegisters to ABICSVs 2022-04-05 15:37:57 +02:00
Antonio Frighetto 7ad5772c55 Move revng/ABIAnalyses/Common.h in EFA 2022-04-05 15:37:57 +02:00
Antonio Frighetto 7ace65adad Drop old CFEP notation 2022-04-05 15:37:57 +02:00
Antonio Frighetto 93cc2a5356 Drop Dump/CollectCFG.cpp
Unmaintained code has been removed.
2022-04-05 15:37:56 +02:00
Alessandro Di Federico f6c9b04c81 Adopt clang-tidy: readability-identifier-naming 2022-04-04 21:15:52 +02:00
Alessandro Di Federico 5576bfe86a EFA: add required libraries 2022-03-31 14:35:56 +02:00
Alessandro Di Federico 1a2a729e92 Rework FunctionTags::Tag 2022-03-31 12:51:24 +02:00