Commit Graph

54 Commits

Author SHA1 Message Date
Alessandro Di Federico bc4872f2f4 DwarfImporter: handle STT_GNU_IFUNC symbols
In DWARF, `STT_GNU_IFUNC` symbols are associated to a function prototype
returning the actual prototype.
2026-06-03 13:59:53 +02:00
Alessandro Di Federico 9e9451247b Drop --import-debug-info command-line option
The --import-debug-info CLI flag and the ImporterOptions::
AdditionalDebugInfoPaths field it populated were a side-channel that
loaded extra DWARF files outside the normal ELF dependency-resolution
path. It bypassed the symbol-aware machinery and is no longer needed.
2026-06-03 13:59:53 +02:00
Alessandro Di Federico cc28786000 DwarfToModelConverter: match existing functions
Unfortunately, in DWARF, there's no widespread indicator on whether a
function is regular ARM or Thumb. Therefore, in this commit, instead of
blindly creating a new function, we first check if, in the model, we
already have a function at that address.

This means that, if we have a Thumb function in DWARF, but it doesn't
already exist in the model, we will import as regular ARM, which is
wrong.
Specifically, this can happen with `revng model import debug-info`.
2026-05-15 11:27:34 +02:00
Alessandro Di Federico 7793543485 FindMissingTypes.h: split off findPrototype* 2026-05-15 11:27:33 +02:00
Alessandro Di Federico c1b3f23cf5 Uniform Binary::get{Definition,Binary}Reference 2026-04-24 17:54:09 +02:00
Alessandro Di Federico 2629f95dd1 Introduce ImportPrototypesFromDatabase
This commit introduces an analysis to import prototypes from a SQLite
database of well-known prototypes, typically built from debug info of
operating systems.

This analysis supersedes import-well-known-models.
2026-04-24 17:54:09 +02:00
Alessandro Di Federico 6894862ef2 Implement platform roots support
Refactor the binary import and dependency resolution infrastructure to
support multiple platforms (Linux, Windows, macOS) via a
configuration-driven root system.

Major changes:

* Overhaul PDB and DWARF importers for platform-aware debug info
  loading.
* Refactor LDDTree into a template-based architecture with
  platform-specific implementations (ELF, PE/COFF).
* Mostly rewrite the PDB importer, which had significant limitations.
2026-04-24 17:54:09 +02:00
Alessandro Di Federico 4a51b67700 TypeCopier: improve performance
This commit refactors `TypeCopier`. Among other things, it ensures we
invoke `initializeReferences` only in `finalize`, as opposed to every
time we invoke `copyTypeInto`.
2026-04-23 13:40:43 +02:00
Alessandro Di Federico e928664380 Introduce ImportLogger
`ImportLogger` is a simple support class to report on how many elements
have been imported in the model between the start and the end of its
lifetime.
2026-04-23 13:40:42 +02:00
Alessandro Di Federico afa52dfbd5 BinaryImporterHelper: use executableRanges
This ensures we don't create functions at addresses in a zone where
executable code is not allowed, despite being in a +x segment.
2025-12-22 11:34:47 +01:00
Alessandro Di Federico 250e69fdc7 Introduce MetaAddressRange 2025-12-22 11:34:47 +01:00
Alessandro Di Federico d9123fcd49 PECOFFImporter: fix handling of relocations
This commit ensures relocations imported from PE/COFF binaries have
generic `Address`. The fact that this was not the case lead to not
detecting dynamic calls.

The commit also improves logging and fixes the handling of maximum depth
visit of the PDB importer.
2025-12-19 14:44:07 +01:00
Giacomo Vercesi 265af3768f Binary importers: fix debug info detection
Fix the behavior of binary importers by propagating the path of the
input binary from revng2 downwards, allowing finding `.debug` files in
the correct paths.
2025-12-19 10:28:29 +01:00
Giacomo Vercesi 405733369b Add ImportWellKnownModelsAnalysis to pypeline 2025-12-10 15:05:53 +01:00
Giacomo Vercesi 47038d46ec Add ParseBinaryAnalysis to pypeline 2025-12-10 15:05:53 +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 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 fd1c9115c0 Model: set default values where viable 2025-10-13 18:33:10 +03:00
Ivan Krysak f070f1f1e1 Model: sunset double name system 2025-04-17 11:19:17 +03:00
Ivan Krysak 705e4a5955 auto [...] -> auto &&[...] 2025-02-13 13:10:51 +02:00
Alessandro Di Federico 832840c307 Importers: ignore unmapped code
This commit ensures that parts of the model that must point to code
(specifically `Binary::EntryPoint`, `Binary::ExtraCodeAddresses` and
`Function::Entry`) actually point to a segment mapped as +x.
2024-11-28 15:22:10 +01:00
Alessandro Di Federico cba1d6fa51 PDBImporter: fix .pdb path lookup 2024-08-16 13:01:57 +02:00
Alessandro Di Federico 7b00473859 PDBImporter: rework .pdb search 2024-08-05 17:41:34 +02:00
Ivan Krysak 4a2db0ba4f UpcastablePointer: streamline empty behavior 2024-06-27 11:05:52 +02:00
Ivan Krysak dfa7478685 Adopt reworked model::Type 2024-06-27 11:05:51 +02:00
Ivan Krysak 927e8006b9 Model: rename TypePath to DefinitionReference 2024-06-27 11:05:49 +02:00
Ivan Krysak ac587cbb4f Model: rename Type into TypeDefinition 2024-06-27 11:05:48 +02:00
Ivan Krysak d613023a53 Model: drop an obsolete assert 2024-06-27 11:05:48 +02:00
Alessandro Di Federico fe1dffcffd Add some missing includes
This is in preparation of reducing headers in Debug.h.
2024-05-03 21:52:40 +02:00
Alessandro Di Federico d9367954a4 Convert all public strings to kebab-case 2024-02-09 10:04:24 +01:00
Massimo Fioravanti c276a439b5 Add pipeline invalidation
Replace the stub implementation of invalidation with the proper
implementation. A ReadPathCache is added to each global so that it can
keep tracks of what target are associated to which read paths.
2024-01-02 11:14:56 +01:00
Ivan Krysak cfe28d8e56 Stop using std:: prefix for u?int\d+_t types 2023-11-02 17:10:03 +01:00
Alessandro Di Federico 2cbf3a8313 TypeCopier: minor rework 2023-10-05 10:19:44 +02:00
Alessandro Di Federico 26310efc1c TypeCopier::copyTypeInto: fix returning wrong type
TypeCopier::copyTypeInto used to return a random type among those just
created instead of the new version of the originally requested type.
2023-09-11 14:15:37 +02:00
Alessandro Di Federico 247879f7fc model::Type::ID: switch to progressive IDs
This commit switches `model::Type::ID` from being a GUID to be a
progressive number, in order to make things easier for humans.

On top of this, this commit introduces the following changes:

* TypeCopier: import all the necessary PrimitiveTypes and improve
  handling of CustomName.
* Move Kind as the last field of the key of each TupleTree type used in
  an `UpcastablePointer`.
* Update the ground truth of tests to ignore the `CustomName` in favor
  of focusing on `OriginalName`.
* Increase adoption of `model::Binary::makeType`, equivalent to
  `Binary.recordNewType(makeType<model::*Type>())`.
2023-08-23 16:14:04 +02:00
Ivan Krysak 9f1d9fd5d0 Use Container::contains() where appropriate 2023-07-02 15:06:11 +00:00
Ivan Krysak bc98e0079f Formatting: change PenaltyReturnTypeOnItsOwnLine
The new value is 21.
2023-07-02 13:20:49 +02:00
Ivan Krysak 01b4ec36c9 Formatting: set AllowShortEnumsOnASingleLine
The new value is `false`.
2023-07-02 13:15:08 +02:00
Alessandro Di Federico f1f8c217e7 TypeCopier: reset TTR's root pointer after copy 2023-05-17 11:17:35 +02:00
Giacomo Vercesi 31cd2b53f9 rcc: add codespell
Add codespell to the list of checks performed by
revng-check-conventions. This should reduce the amount of typos present
in the revng codebase.
2023-05-11 10:05:32 +02:00
Alessandro Di Federico f562d0373f Importers: fix usage of BaseAddress
This commit ensure the BaseAddress is propagate as appropriate to all
levels of the importers and that it is ignored for executables
(non-PIC).

This was a recurring source of importing the same function twice, once
relocated, once not.
2023-05-10 09:20:40 +02:00
Alessandro Di Federico 73fb1a31c9 Outline TypeCopier
This commit also drop the suggestion that it should be used for copying
prototypes only.
2023-05-10 09:20:15 +02:00
Ivan Krysak 64856306c4 BinaryImporter: rework command line interface 2023-03-15 10:19:03 +01:00
Djordje Todorovic 961f9e5461 Model: search debug info locally upon import
Also find prototypes in Models of dynamic libs for both PE and ELF.
2022-12-13 11:26:54 +01:00
Alessandro Di Federico b83edd61c0 DwarfImport: fix handling of local functions 2022-11-30 15:06:54 +01:00
Massimo Fioravanti 9363bbd70a Pipeline: every container type has now a C++ type 2022-09-29 15:51:17 +02:00
Massimo Fioravanti 633f49c1ef Introduce dedicated namespace for kinds and ranks 2022-08-29 14:44:53 +02:00
Massimo Fioravanti 915c083661 Pipes: reorganize who defines pipes 2022-08-29 14:44:35 +02:00
Djordje Todorovic a36e22729f Model: Add PDB support 2022-07-28 14:52:50 +02:00