Commit Graph

89 Commits

Author SHA1 Message Date
Filippo Cremonese 2b221ca66e tuple-tree-gen: support generating python 2022-03-22 14:53:01 +01:00
Alessandro Di Federico 2b55d1df22 Adopt cmake-format 2022-03-17 18:52:18 +01:00
Pietro Fezzardi fb54cc22a2 QualifiedType: new typedef-aware helper methods
This commit reworks the helper methods for model::QualifiedType, to
properly traverse typedefs.

These methods are used to check if a QualifiedType is:
- scalar
- primitive
- float
- void
- pointer
- array

This commit add the methods for checking pointers and arrays (that
weren't available before), reworks all the helpers so that they all
traverse typedefs, and adds comments so that it's clear that they
traverse typedefs.
2022-03-17 17:03:28 +01:00
Pietro Fezzardi 630fee4500 model::Qualifier: add static methods for filtering
This commit adds the static methods:
- model::Qualifier::isConst
- model::Qualifier::isArray
- model::Qualifier::isPointer

These methods replace the old, non-static, methods:
- model::Qualifier::isConst
- model::Qualifier::isArray
- model::Qualifier::isPointer

Having these method static is very helpful for filtering, when
iterating on sequences of qualifiers, such as:

  for (const auto &Q :
       llvm::make_filter_range(Qualifiers, Qualifier::isPointer)) {
    // do stuff with Q
  }

This will be very helpful for defining other helper functions for
model::QualifiedType.

This commit also drops the non-static version of the methods, since they
are redundant, and because they would cause ambiguity and failure of
type inference in the snippet above, making them effectively useless for
the goal they were designed for, which is filtering ranges.
2022-03-17 17:03:22 +01:00
Pietro Fezzardi 0158354dc7 DwarfImporter: fix order of Qualifiers
Before this commit the DwarfImporter was importing qualifiers in
reverse order.

As an example the following declaration in C:

  int *x[4];

was imported as a pointer to array, instead of an array of pointers.

This commit fixes the order of the qualifiers.
2022-03-17 17:02:48 +01:00
Alessandro Di Federico ea6383c476 mv {d,registerD}efaultFunctionPrototype 2022-03-17 14:10:50 +01:00
Alessandro Di Federico bc8e6a6a24 Minor changes 2022-03-16 22:10:15 +01:00
Alessandro Di Federico 0793e4afcb Turn lifting into a pass 2022-03-11 15:37:12 +01:00
Alessandro Di Federico ee0b8f44c1 Introduce BinaryImporter
This is a big step to split revng-lift in two parts: one that only
writes the model and one that actually lifts to LLVM IR.

* Introduce `revng import binary`
* Split off `BinaryFile.h`
* Drop `revng.h`
* `GeneratedCodeBasicInfo`: use model
* Reduce role of `GeneratedCodeBasicInfo` in favor of
  `model::Architecture` and `model::Register` methods
* `CodeGenerator`: adopt `RawBinaryView` and model
* `JumpTargetManager`: adopt `RawBinaryView` and model
* `ExternalJumpsHandler`: adopt model
* `InstructionTranslator`: discard `Architecture` in favor of
  `EndianessMismatch`
* Many other changes
2022-03-08 15:15:24 +01:00
Alessandro Di Federico e9b1879067 Handle invalid model::DynamicFunction::Prototype 2022-03-08 15:04:34 +01:00
Alessandro Di Federico 0a5d2c04a7 Rework LoadModelPass 2022-03-08 15:04:34 +01:00
Alessandro Di Federico 1a57229693 Introduce model::Binary::DefaultPrototype 2022-03-08 15:04:34 +01:00
Alessandro Di Federico a88a9e52c3 Improve model::Segment 2022-03-08 13:06:47 +01:00
Alessandro Di Federico 97f0941aee Introduce model::Section 2022-03-08 12:26:07 +01:00
Alessandro Di Federico 8570923d64 Introduce model::Relocation 2022-03-08 12:25:59 +01:00
Alessandro Di Federico 39ace7dc56 mv revng{DwarfImporter,ModelImporterDwarf} 2022-03-08 12:25:47 +01:00
Alessandro Di Federico 0589697dca CMake: sort headers for tuple_tree_generator 2022-03-08 12:25:35 +01:00
Massimo Fioravanti b982b69c5d revng-model-inject: support model-less modules
Inject is meant to inject a model into an `llvm::Module`, but it fails
when operating on a Module that had no model metadata.

This commit fixes the bug.
2022-03-02 15:40:27 +01:00
Ivan Krysak 2c35fc87d5 Conversion to RawFunctionType cannot fail 2022-02-25 00:31:14 +01:00
Ivan Krysak 541643afc3 Move function type conversion to librevngABI 2022-02-24 23:56:30 +01:00
Filippo Cremonese 09a995ba51 python-model: generate from jsonschema 2022-02-23 18:03:35 +01:00
Alessandro Di Federico b7f5884f8c DynamicFunction::name: no OriginalName direct use 2022-02-14 17:54:32 +01:00
Ivan Krysak 9771ae29d6 Move RegisterState to ABI 2022-02-14 13:35:37 +01:00
Ivan Krysak 8d876b0def ABI: introduce bulk function conversion 2022-02-14 13:35:37 +01:00
Ivan Krysak e20e65ca9a Require a description when registering a pass 2022-02-14 13:35:36 +01:00
Ivan Krysak 7369e49eba Implement "best effort" function type convertion 2022-02-14 13:35:36 +01:00
Alessandro Di Federico ec6d4dbe74 Ensure all files end with a newline 2022-02-14 10:56:15 +01:00
Pietro Fezzardi 29c50fa909 Model: reserve names defined in stdint.h
This commit adds a bunch of type names and macro names to the set of
reserved keywords that cannot be used for names in the revng Model.
These are the names defined in the stdint.h standard C header, that is
included automatically by the decompiler in decompiled code.

We need to reserve these names otherwise it would be possible to add
things to the revng Model with names that clash with the names defined
in stdint.h, which would in turn break recompilation of decompiled code
because of conflicting definitions.
2022-02-08 15:54:02 +01:00
Alessandro Di Federico 280848484e SerializeModelPass: verify model 2022-01-31 16:28:17 +01:00
Alessandro Di Federico a353e00ac1 Introduce model passes 2022-01-31 16:28:14 +01:00
Alessandro Di Federico b3d6c721ad Introduce purgeUnnamedAndUnreachableTypes 2022-01-27 11:51:03 +01:00
Alessandro Di Federico f14e722c86 Introduce deduplicateEquivalentTypes 2022-01-27 11:51:03 +01:00
Alessandro Di Federico dd7477664c Update CustomName verification criteria
This commit ensures `CustomName` is unambiguous according to C symbols
rules.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 74a7496020 deduplicateNames -> promoteOriginalName
This commit switches from `deduplicateNames`, which changed certain
`CustomName` values, to `promoteOriginalName`, which updates empty
`CustomName` using non-ambiguous versions of `OriginalName`.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 863652f480 Introduce OriginalName in the type system
The goal of `OriginalName` is to keep track of the original name of a
symbol upon import.

In future, this will also be used to promote it to `CustomName`.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 8d22c5205f Push CustomName to model::Type
Before this commit `CustomName` was in each inheritor, except for
`model::PrimitiveType`.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico b31e7b1f5e Introduce model::Type::edges()
This makes building a graph for the type system very easy.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 80ed065206 model::Type: move makeTypeWithID to .cpp
It needs to see the full declaration of all concrete types.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 92ea78b0a8 Fix ReservedKeywords list
Commas were missing.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico c9d47d4ee7 Drop model::EnumEntry::Aliases
They turn out to be problematic to handle in the model and not very
usable in practice.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 1ce1f1cbd6 model::Function::verify: relax assumptions
Now `model::Function` can miss the CFG, the `Prototype` and have
`Invalid` type.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 3799f1e973 Whitespace and other minor changes 2022-01-25 21:27:05 +01:00
Alessandro Di Federico 3ab32cd2ef tuple_tree_generator: make fully standalone 2022-01-21 18:05:51 +01:00
Alessandro Di Federico d19879d4e8 Minor changes 2022-01-17 16:30:42 +01:00
Filippo Cremonese 74217b4fe5 Generate C++ model from YAML definition
Model classes are now described by a YAML document, which is used to
generate C++ headers containing classes and all the boilerplate
required for YAML serialization/deserialization, usage in
SortedVectors, etc. See the README in include/revng/Model for more
info.
2022-01-13 14:34:11 +01:00
Filippo Cremonese fbeee896e1 Rename model::abi -> model::ABI 2022-01-10 10:31:27 +01:00
Alessandro Di Federico 546efa345a More verbose model verification failures 2022-01-09 19:00:57 +01:00
Massimo Fioravanti fdfeb2b6e9 LoadModelPass: support for external model 2022-01-05 14:45:01 +01:00
Pietro Fezzardi b689f7f0c0 lib/Model/Type.cpp: add global using llvm::Twine
This using was defined many times with local scope.
This commit makes it global.
2022-01-05 14:37:37 +01:00
Pietro Fezzardi 94c1c5323a Improve error reporting for model::UnionType 2022-01-05 14:37:37 +01:00