Without this patch, the import part would fail with an assertion
even for a simple case since it doesn't expect that file size
could be larger than virtual.
From the microsoft documentation:
```
Because the SizeOfRawData field is rounded but the VirtualSize field
is not, it is possible for SizeOfRawData to be greater than
VirtualSize as well. When a section contains only uninitialized data,
this field should be zero.
```
We rather choose not to percolate this into the Model.
`Segment` now includes a `Type` of struct kind. This is intended to
emit the segment as a struct later in decompilation. The implementation
of name has also been added.
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.
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.
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.
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.
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.
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.
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
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.