392 Commits

Author SHA1 Message Date
Giacomo Vercesi 97b471c888 Add Lift to pypeline 2025-11-18 17:47:54 +01:00
Alessandro Di Federico 5d3973b111 Model verify: allow / in most places
`/` is now supported in names except for the parts of the model that use
the name as the key, i.e., `DynamicFunction` and `LocalIdentifier`.

Eventually, `/` should be allowed there as well, but we first need to
make sure that when they end up in a location they are properly
escaped/unescaped.
2025-11-11 17:56:54 +01:00
Alessandro Di Federico 21d9cb56a0 Ban functions in .bss 2025-11-05 12:02:58 +01:00
Alessandro Di Federico c883bed765 Drop Logger's StaticEnabled feature 2025-10-31 17:25:03 +01:00
Alessandro Di Federico 6b78293b22 RawBinaryView: outline to .cpp 2025-10-31 17:25:03 +01:00
Alessandro Di Federico 1429b526ab Introduce libtcg
This commit drops libptc in favor of its new form libtcg.

It brings several improvements, among which:

* The QEMU version we work on has been upgraded.
* CPUStateAccessAnalysis has been reimplemented in a way that makes it
  easier to debug and solves some limitations (e.g., tracking leaking
  pointers).
* Identification of pieces of the CPU state that are read by each helper
  and fixing access to the CPU state is now performed at build-time.
* We no longer mmap the code we need to translate, dropping all the
  issues related to code that needed to be mapped where something is
  already present.
* We now have two distinct flavors of helper modules: the full one and
  the "slim" one. The latter contains the definition only of functions
  we intend to inline. It is used in most of the pipeline, a good thing
  since we spend less time optimizing code we don't really care about.
  The full module is only used on the re-compilation branch of the
  pipeline.
* We no longer split the `cpu_loop` function.
* We change MetaAddress to rely on architectures from `model::` as
  opposed to the LLVM ones.
* We no longer attach debug info to LLVM IR containing the original
  assembly.
* We now verify that the lifted code only contains code we expect.
2025-10-31 17:25:03 +01:00
Ivan Krysak 5b419540cc Disable IRBuilder checks in some additional places 2025-10-31 09:04:59 +01:00
Alessandro Di Federico 0d066767f2 mips: fix f register size 2025-10-24 18:24:03 +02:00
Alessandro Di Federico fb80f4b8bd FunctionCallIdentification: handle delay slot 2025-10-24 18:21:07 +02:00
Alessandro Di Federico ed3fc26166 MaterializedValue: handle loading mutable data 2025-10-24 18:20:54 +02:00
Alessandro Di Federico 4fb6b5f4e1 Minor changes 2025-10-24 18:20:48 +02:00
Alessandro Di Federico f8bd4c3bac Move around some files in preparation for libtcg
* Make the following private headers public:
  * Lift/CPUStateAccessAnalysisPass.h
  * Lift/CSVOffsets.h
  * Lift/PTCDump.h
  * Lift/VariableManager.h
* Move from revngSupport to revngLift:
  * IRAnnotators.{h,cpp}
  * SelfReferencingDbgAnnotationWriter.{h,cpp}
* Move from revngSupport to revngModel:
  * FunctionTags.{h,cpp}
  * ProgramCounterHandler.{h,cpp}
* Move from revngSupport to revngRecompile:
  * OriginalAssemblyAnnotationWriter.{h,cpp}
2025-10-24 15:34:11 +02:00
Giacomo Vercesi 40da49548b Add Binaries list to the model
Add to the model an entry detailing the list of input binaries under
`Binaries`. This will be referenced by `Segments` when needed.
2025-10-16 17:48:45 +02:00
Ivan Krysak ecb9d76c64 Model: drop obsolete default value handling 2025-10-13 18:33:10 +03:00
Ivan Krysak fd1c9115c0 Model: set default values where viable 2025-10-13 18:33:10 +03:00
Ivan Krysak cc57e57fd1 TTG: remove support for optional: true fields
After this commit, every non-key field is treated as if it was optional
while every key field (plus every auto-generated `Kind` field) - as if
it was required.
2025-10-13 18:33:10 +03:00
Ivan Krysak b38185c979 Model: rewrite TTG documentation
Big chunks of this file were outdated or otherwise awkward,
this brings it up-to-date with the current state of the TTG.
2025-10-13 18:33:10 +03:00
Ivan Krysak 10ca432cb2 TTG: simplify reference field usage
This allows to avoid having to specify the `rootType` (stable within
the entire tree) manually each time a reference is introduced.
Thanks to that, a much nicer syntax of:
```yaml
- name: MyTypeField
  reference-to: TypeDefinition
```
can replace the current one:
```yaml
- name: MyTypeField
  reference:
    pointeeType: TypeDefinition
    rootType: Binary
```
2025-10-13 18:33:10 +03:00
Ivan Krysak 480443f358 TTG: drop upcastable: configuration option
Instead, detect whether `UpcastablePointer` wrapping is needed or not
based on the type.
2025-10-13 18:33:10 +03:00
Ivan Krysak d9ee804211 Do not use std::vector in model TTG docs
Currently, using `std::vector` in these breaks invalidation, so to
avoid potential confusion, we shouldn't use it in docs either.

Note that it's fine to use `std::vector` in non-invalidation-enabled
TTG instances.
2025-10-13 18:33:10 +03:00
Ivan Krysak d1fbf2eee6 Model: Drop ToolHelpers.h 2025-10-08 12:22:34 +03:00
Lauri Vasama 653d451e6c Remove undef name configuration support
Also adds a model migration removing
Configuration.Naming.UndefinedValuePrefix.
2025-09-29 18:05:55 +03:00
Giacomo Vercesi c2afb05049 VerifyHelper: set ReasonBuffer with simple str
When using `maybeFail(bool, llvm::Twine)` the `ReasonBuffer` variable
was not being set, leading sometimes to the verify reason being an empty
string.
2025-09-09 12:27:33 +02:00
Giacomo Vercesi eba55456f6 NameBuilder: fix a use-after-free bug 2025-09-08 16:33:51 +02:00
Ivan Krysak c80309088a NameBuilder: add shouldUseAutomaticName method
It provides a way to dynamically check whether a custom name is
going to be emitted for a specific entity or not.
2025-09-04 16:57:16 +03:00
Ivan Krysak 2b9b925e8c TTG: make doc mandatory in fields too 2025-07-23 11:38:52 +02:00
Ivan Krysak 9589721b52 Model schema: reorder and reformat
This improves readability and navigation in this big file.
2025-07-23 11:38:52 +02:00
Ivan Krysak f49ec25de3 TTG: make doc mandatory in structs and enums 2025-07-23 11:38:52 +02:00
Ivan Krysak a11215bd73 Model schema: drop trailing newlines from docs 2025-07-23 11:38:52 +02:00
Ivan Krysak 461c49df25 Model: bump version to 5 and introduce migration 2025-07-23 11:38:52 +02:00
Ivan Krysak c9072ec28f TypePathHelpers: add variable and goto label paths 2025-07-23 11:38:52 +02:00
Ivan Krysak 0572de8990 TypePathHelpers: fix incorrect return value paths 2025-07-23 11:38:52 +02:00
Ivan Krysak 21734cad34 CTypeBuilder: add new variable and label tagging 2025-07-23 11:38:51 +02:00
Ivan Krysak 4265644adf NameBuilder: introduce counting sub-builders 2025-07-23 11:38:51 +02:00
Ivan Krysak 554ffa376a model::Function: introduce GotoLabels field 2025-07-23 11:38:51 +02:00
Ivan Krysak 1ebeb8f493 model::Function: introduce LocalVariables field 2025-07-23 11:38:50 +02:00
Ivan Krysak 4e3c6cccd0 Model: introduce LocalIdentifier struct 2025-07-23 11:38:50 +02:00
Ivan Krysak b982ae68d0 NamingConfiguration: add UnnamedGotoLabelPrefix 2025-07-23 11:38:50 +02:00
Giacomo Vercesi d62b7b6b1a TTG: inline root type in schema
Move the root type inside the schema definition, as it is a property of
it and not of the generator.
2025-06-25 15:40:13 +02:00
Lauri Vasama a7eb86174b Add revng/Support/Identifier.h for id validation 2025-06-04 15:13:47 +02:00
Pietro Fezzardi 0426c773b2 CABIFunctionDefinition: drop array argument/return
This commit bans from the model array types in as argument or return
types in CABIFunctionDefinition.
CABIFunctionDefinition implies we're decompiling towards C, and C does
not support array arguments (passed by copy) nor array return types.

Banning these from the model reduces the number of situations where we
have to emit artificial array wrappers (not present in the model) around
types when printing C code, simplifying the handling of such situations
when translating to clift and in general in the decompilation pipeline.
2025-05-28 17:11:11 +02:00
Pietro Fezzardi b106024a13 NameBuilder: fix artificialArrayWrapperNameImpl
This commit fixes a copy-paste error that unfortunately did not lead to
compilation errors, but caused null pointer dereference every time the
method was called with a model::PointerType or model::PrimitiveType
argument.
2025-05-14 10:15:14 +02:00
Pietro Fezzardi 76c63ae5b7 CommonTypeMethods: add getArrayElement 2025-05-14 10:12:03 +02:00
Ivan Krysak 17a5d19135 NameBuilder: add name overload for primitives 2025-05-08 15:42:00 +02:00
Ivan Krysak 0d868894a2 model::Function: switch to indices as comment keys 2025-05-08 15:42:00 +02:00
Khaled Ismaeel 9d80594ddc Bump model version to v3 2025-04-30 15:08:45 +02:00
Khaled Ismaeel 383af5b6b0 Add the version field to schemas YAML
Here we start restructuring the the schemas YAML such that it
contains a top-level `version` field. In this commit we only modify
the YAML, the build system changes will come later, to avoid
enormous commits.
2025-04-30 15:08:45 +02:00
Khaled Ismaeel 53a5ff07cf Remove embedded TUPLE-TREE-YAML 2025-04-30 15:08:45 +02:00
Khaled Ismaeel f384b10435 Check schemas into the codebase
These schema files are currently generated at build time by
collecting various TUPLE-TREE-YAML comments using the
`extract_yaml.py` script. In this commit we move them to the codebase
but we don't use them yet, this will be done at a later commit for
the sake of readability.
2025-04-30 15:08:40 +02:00
Ivan Krysak 1622bb91a1 Introduce automatic names for dynamic functions 2025-04-24 13:22:14 +02:00