470 Commits

Author SHA1 Message Date
Alessandro Di Federico 903617e79e IRHelpers: turn some functions into IRBuilder::* 2026-06-19 09:18:16 +02:00
Alessandro Di Federico ffaf735219 sqlite: open read-only when appropriate 2026-06-19 09:18:15 +02:00
Alessandro Di Federico a35da01bdd Minor changes 2026-06-18 16:44:15 +02:00
Ivan Krysak 31bd61ba2b Do not recompute type sizes unnecessarily 2026-06-15 17:28:22 +02:00
Ivan Krysak 051d0198b5 Adopt edges in the type size gatherer 2026-06-15 17:28:22 +02:00
Ivan Krysak 88b9e64e1e Drop an unnecessary intermediate container 2026-06-15 17:28:22 +02:00
Ivan Krysak 29ff972daa Move the opaque type gatherer to model::Binary 2026-06-15 17:28:22 +02:00
Ivan Krysak 602a4fe138 Model: improve naming configuration verification 2026-06-15 11:47:41 +02:00
Alessandro Di Federico 4daa276c45 DwarfToModelConverter: skip wide float primitives 2026-06-11 17:39:52 +02:00
Alessandro Di Federico ce6eda6836 FunctionTags: drop MemoryEffects on AddressOf pool 2026-06-11 17:39:52 +02:00
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 9596cf1151 Rework dropTypesDependingOnDefinitions 2026-06-03 13:58:33 +02:00
Alessandro Di Federico e0f62fe566 ELFImporter: use .{,gnu.}hash for symbols count 2026-05-15 11:27:51 +02:00
Alessandro Di Federico 49e3b9b28b ELFImporter: consider STT_GNU_IFUNC 2026-05-15 11:27:34 +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 e41c5780ce ELFLDDTree: get exported symbols via ELFImporter
We used to use dynamic_symbol_begin which does not use segments (uses
sections) and also tampers with `st_value` for ARM symbols.

This commit makes it reuse the more accurate logic implemented in
ELFImporter.
2026-05-15 11:27:33 +02:00
Alessandro Di Federico 8a28920773 Move *LDDTree* to Model/Importer/Binary 2026-05-15 11:27:33 +02:00
Alessandro Di Federico f11b9727b2 DwarfToModelConverter: detect cycles in getName
DW_AT_abstract_origin chains are walked recursively to find a DIE's
name, with no cycle check. Some binaries (e.g. debian-bookworm-mipsel
/usr/sbin/pwck) ship DWARF with a cycle in that chain, so getName ended
up in infinite recursion.

Make the walk iterative.
2026-05-15 11:27:33 +02:00
Alessandro Di Federico e0bf4e41f3 import-prototypes-from-db: query by ExportedNames 2026-05-15 11:27:33 +02:00
Alessandro Di Federico 7793543485 FindMissingTypes.h: split off findPrototype* 2026-05-15 11:27:33 +02:00
Alessandro Di Federico a10cb152fd DwarfToModelConverter: skip invalid child DIEs 2026-05-15 11:27:33 +02:00
Pietro Fezzardi 58e95d330f Drop assign_array macro
The macro is no longer necessary: the code now ensures we never
need to assign anything to an array, which would be ill-advised
nevertheless given that array-typed rvalues in C immediately
decay to pointers.
2026-05-08 11:37:10 +02:00
Pietro Fezzardi 85a9780d28 Drop bit_cast_to_array macro
The macro is no longer necessary: the code now ensures we never
need to bitcast anything to an array, which would be ill-advised
nevertheless given that array-typed rvalues in C immediately
decay to pointers.
2026-05-08 11:37:10 +02:00
Pietro Fezzardi 0251ddd37d Add assign_array and bit_cast_to_array
assign_array is necessary as a fallback for when the decompiled C
code may need assignments among array types. bit_cast_to_array is
necessary because when the target type of a bitcast is an array
the regular bit_cast macro is not enough.
2026-05-08 11:37:10 +02:00
Pietro Fezzardi 3bf02e6f60 Unify implementation of bit_cast, requiring typeof
Rework primitive-types.h so that the various bit_cast macros share
a single implementation based on `typeof`/`__typeof__`. As a
consequence both keywords are added to the model's reserved-name
set so that user identifiers cannot collide with them.
2026-05-08 11:37:10 +02:00
Pietro Fezzardi 21063f1844 NameBuilder: support opaque types
Teach NameBuilder and ModelCBuilder how to produce names and
references for opaque-array types: NameBuilder gains
opaqueTypeName(ByteSize), ModelCBuilder gains the matching
reference and definition tags. Both rely on the new
Configuration::OpaqueTypePrefix.
2026-05-08 11:37:10 +02:00
Lauri Vasama 9c5338913d Add TargetABI field in the model 2026-05-04 10:48:03 +03:00
Alessandro Di Federico 3ddd84bc8d mv CrossModelFindTypeHelper.h FindMissingTypes.h 2026-04-24 17:54:09 +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 36a1295a8f Introduce Binary.getIdentifierBinaryReference 2026-04-23 13:40:43 +02:00
Alessandro Di Federico 5b43a23060 BinaryIdentifier: s/.Name/.CanonicalPath/g 2026-04-23 13:40:42 +02:00
Alessandro Di Federico 7b3a80155e Model: introduce OperatingSystem and PlatformName
These are going to be used to select the correct root.
2026-04-23 13:40:42 +02:00
Alessandro Di Federico 7049f61baa Minor changes 2026-04-23 13:40:41 +02:00
Pietro Fezzardi e399f381ea CommonTypeMethods: add getters for function types 2026-04-10 15:27:24 +02:00
Giacomo Vercesi 90e8cce41e model: rework python mixin infrastructure
Rework the python mixin infrastructure for the model. Mixins are now
specified explicitly instead of using the `ast` module. The mixins are
loaded relative to the generated python file, this allows to have two
models: `revng.model` and `revng.project.model`. The latter is augmented
via mixins to have project-specific facilities such as `get_artifact`
and artifact accessors.
2026-04-10 11:45:12 +02:00
Lauri Vasama a37f3195d9 Homogenize static assertions in primitive-types.h 2026-04-08 11:12:41 +03:00
Lauri Vasama b062b23ad6 Include stddef.h in primitive-types.h 2026-04-08 11:12:41 +03:00
Lauri Vasama 71f1fa128a Remove unnecessary function type verification 2026-04-08 11:12:41 +03:00
Ivan Krysak de31315cd7 Model: rename Inline into AlwaysInline 2026-03-27 08:16:21 +00:00
Ivan Krysak 729b025de3 CAttributes.h: move back to PTML
When `revng` and `revng-c` were being merged, this header founds its
way into `revngSupport` even though it makes more sense under the PTML
umbrella.
2026-03-27 07:19:27 +00:00
Ivan Krysak e706628a49 Rename Annotations.h into CAttributes.h 2026-03-27 07:19:27 +00:00
Giacomo Vercesi 6ec9f9a952 TupleTree: overhaul reference caching
Overhaul the logic and method names involved in enabling and disabling
reference caching in `TupleTree<T>`. `TupleTreeReference<T, U>` now
lazily caches the target and will traverse the path only when needed.
Also expose and use these functions in the new pipeline, which should
provide some speedup when executing a `Schedule`.
2026-03-04 14:58:02 +01:00
Ivan Krysak 7501ef998b NameBuilder: unconditionally ban some prefixes 2026-02-25 12:47:27 +01:00
Ivan Krysak b5f98fcae9 check-conventions: ban anonymous header namespaces 2026-02-25 12:47:27 +01:00
Giacomo Vercesi 27f419c8cd Fix and ban namespace clobbering
Fix an instance where the `std` namespace got clobbered into the global
namespace by accident.
2026-02-16 10:34:38 +01:00
Lauri Vasama cb95b94785 Rename StackFrameVariableName 2026-02-13 08:41:39 +02:00
Lauri Vasama aa2597d13b model::Function: add stack frame name and comment
* StackFrameType() is removed.
* StackFrame() is introduced in its place.
* Use StackFrame().Type() to acess the stack frame type.
2026-02-13 08:41:39 +02:00