Commit Graph

3168 Commits

Author SHA1 Message Date
Alessandro Di Federico 911ab00107 s/CDecompilation/Decompile/g 2024-02-09 09:03:34 +01:00
Alessandro Di Federico ba94f0ddd4 s/DecompiledToYAML/Decompiled/g 2024-02-09 09:03:34 +01:00
Alessandro Di Federico 7a2e315e29 s/IRCanonicalization/Canonicalize/g 2024-02-09 09:03:34 +01:00
Alessandro Di Federico 2c9d50bdec s/DecompiledYAMLToC/DecompileToSingleFile/g 2024-02-09 09:03:34 +01:00
Alessandro Di Federico 23b3bc9e16 s/ImportModelFromC/ImportFromC/g 2024-02-09 09:03:34 +01:00
Alessandro Di Federico 539b2bd435 Rename dla analysis into analyze-data-layout 2024-02-09 09:03:34 +01:00
Alessandro Di Federico 92c22ce9f1 Minor changes 2024-02-09 09:02:56 +01:00
Pietro Fezzardi 0a90048663 DLA: recursively update nested struct types
This enables e.g. updating nested structs representing Sections inside
Segments.
2024-02-08 18:09:12 +01:00
Pietro Fezzardi fa48e50403 DLA: simplify fillStructWithRecoveredDLATypes
The function now takes 2 arguments less.
2024-02-08 18:09:12 +01:00
Alessandro Di Federico b34031f828 Import sections into segment's struct
Each model::Segment is associated to a model::StructType. Now we also
create sub-`structs` for sections, if available.
2024-02-08 16:57:40 +01:00
Pietro Fezzardi b70a5febfa IRCanonicalization: prefer getTypeStoreSize
This commit replaces all the uses on getTypeAllocSize with
getTypeStoreSize.
The result of the second method are more accurate, e.g. for i96
getTypeAllocSize returns 16, while getTypeStoreSize returns 12.
This makes it more suitable for reasoning about type sizes in a way that
is compatible with the model.
2024-02-08 09:03:55 +01:00
Pietro Fezzardi 51cbceaced DLA: remove dead code 2024-02-08 09:03:31 +01:00
Pietro Fezzardi fdf1720433 Drop ValueManipulationAnalysis (VMA)
This commit drops ValueManipulationAnalysis, which in its original
design based on MinCut and Karger, was never enabled in the
decompilation pipeline.

Until now, VMA was only used in a severely weakened form in
initModelTypes. That for was so weakened that it barely did anything.

We already have a new design for VMA so that it can work before
DataLayoutAnalysis, and on Clift.
At this point, the old VMA is basically useless anyway, and the very few
occasions where it can do something will simply be solved by the
upcoming work on making some of the remaining casts implicit.

At this point it does not make sense to keep VMA alive anymore.
2024-02-07 00:41:30 +01:00
Massimo Fioravanti ab856523dd Introduce clift types 2024-02-04 16:49:51 +01:00
Massimo Fioravanti 1434948e7e Add clift unit tests 2024-02-04 16:49:51 +01:00
Pietro Fezzardi f7eed33dac DLA Backend: only emit valid model::PrimitiveTypes
Before this commit, DLA didn't do any checks on the validity of the
model::PrimitiveTypes that it generated.
This could cause invalid PrimitiveTypes to be generated, with weird
sizes not supported by the Model.
This commit fixes this problem, generating empty model::StructTypes with
the proper sizes instead.
2024-02-04 16:07:31 +01:00
Pietro Fezzardi 11be91caaf DLA: drop unused Logger 2024-02-04 16:07:30 +01:00
Pietro Fezzardi f367eafad2 DLA: store node neighbours in increasing ID order 2024-02-04 16:07:30 +01:00
Pietro Fezzardi d07e661ab5 DLA: rework initialization of string literals
Before this commit, DLA's frontend was representing information about
string literals in a way that had a bad outcome: very often, all (or
most) places in the binary that were using string literals ended up
collapsed on the DLA graph on the same node, causing all their types to
be a weird struct.

This was wrong, and it was the result of an aggressive creation of
equality edges.

This commit avoids to emit equality edges, and replaces them with
instance edges, that represent the fact that a call to StringLiteral
actually returns a type that represents a pointer to char.
2024-02-04 15:21:27 +01:00
Ivan Krysak a331dcc878 ToCFT: improve naming 2024-01-29 11:57:54 +02:00
Ivan Krysak 82c2162d7d ABI: add an explicit void distribution helper 2024-01-29 11:57:54 +02:00
Ivan Krysak 78510010f8 ABI: rename isIncompatibleWith
The new name is `isPreliminarilyCompatibleWith`.
2024-01-29 11:57:54 +02:00
Ivan Krysak 81d365a24b ABI: assert on broken alignment calculation result 2024-01-29 11:57:54 +02:00
Ivan Krysak 79d68dcafc ABI: allow reusing the stack struct
When there's a single struct argument (as in, all we see is a nested
struct) and all the sizes match, just use the inner struct instead of
creating a new one.
2024-01-29 11:57:54 +02:00
Ivan Krysak d0b3777db4 ToCFT: use structs as a fallback
When a stack argument cannot be converted "as is",
use a struct instead to try and overcome the limitation.
2024-01-29 11:57:54 +02:00
Ivan Krysak 093cacdb6f ValueDistributor: enable working on model::Type 2024-01-29 11:57:54 +02:00
Ivan Krysak 35326b29ec ABI: streamline position-based argument handling 2024-01-29 11:57:54 +02:00
Ivan Krysak 4093cd30c4 ABI: provide alignment computation for model::Type 2024-01-29 11:57:54 +02:00
Ivan Krysak ce0ada6027 ToCFT: fix a invalid iterator access
Because of a mistake in the previous iteration, an invalid iteration was
dereferenced when a struct had non-zero size but no fields (padding only
struct).
2024-01-29 11:57:54 +02:00
Ivan Krysak 89b5cacc3b ToCFT: introduce more complete result verification 2024-01-29 11:57:54 +02:00
Ivan Krysak 39532658f9 ToCFT: improve alignment verification logger 2024-01-29 11:57:54 +02:00
Ivan Krysak 039efcfee8 ToCFT: use adjusted alignment for verification
Adjusted alignment means alignment when it's bigger than the pointer
size and pointer size otherwise.
2024-01-29 11:57:54 +02:00
Ivan Krysak 83bb28023c ToCFT: turn verifyAlignment into a free function 2024-01-29 11:57:54 +02:00
Ivan Krysak 7041d5ab4e ABI: expose argument distribution API
This allows external code to peek inside a layout and to tell how
a specific argument would be treated based on its type.
2024-01-29 11:57:54 +02:00
Ivan Krysak 11b1214896 ABI: avoid mentioning TrackingSortedVector
Use `decltype` to dynamically detect the type instead.
2024-01-29 11:57:54 +02:00
Ivan Krysak 386cb26f6d ABI: introduce a new ABI configuration option
It's called `AllowUnnaturallyAlignedTypesInRegisters` and explicitly
allows weirdly aligned structs in registers.
2024-01-29 11:57:54 +02:00
Ivan Krysak 16dc85cb0f ABI: improve unnatural alignment support 2024-01-29 11:57:54 +02:00
Ivan Krysak 54ffd723e6 ABI: decouple alignment from model::VerifyHelper 2024-01-29 11:57:54 +02:00
Ivan Krysak e97ce16240 ToRFT: rename DistributedArgument
The new name is `DistributedValue`, the change is warranted because it's
used for return values as well.
2024-01-29 11:57:54 +02:00
Ivan Krysak 75d0ba700c ToRFT: work on a single argument at a time 2024-01-29 11:57:54 +02:00
Ivan Krysak 7f1d14e149 ToCFT: streamline logger output 2024-01-29 11:57:54 +02:00
Ivan Krysak a2ef041cb2 Move TypeBucket to the model 2024-01-29 11:57:54 +02:00
Ivan Krysak 77b1acaf00 Prefer uint64_t to size_t wherever relevant 2024-01-29 11:57:54 +02:00
Ivan Krysak b25a32de2a Stop using std:: prefix for std::size_t 2024-01-29 11:57:54 +02:00
Ivan Krysak 15be26f9fa Minor Improvements 2024-01-29 11:57:54 +02:00
Giacomo Vercesi 456817eaf8 HeaderToModel: fix CustomName being wrong
This commit fixes a couple of corner cases in HeaderToModel where the
`CustomName` was erroneously assigned even though the name was the
default one.
2024-01-26 19:13:58 +01:00
Giacomo Vercesi 7f8a83c34a ModelToHeader: add DisableTypeInlining option
When running ModelToHeader in HeaderToModel, all types need to be
defined in the header for clang to successfully parse the file. Add an
option to `ModelToHeaderOptions` that forces all types to be printed
regardless of stack or inlining rules.
2024-01-26 19:13:58 +01:00
Giacomo Vercesi ed1ad5e040 Add type.h artifact
Add the required container and pipes to produce `type.h`, a type-wise
file that shows the definition of a Model type in plain C.
2024-01-26 19:13:58 +01:00
Giacomo Vercesi a09a4ab2bf Adapt switch to detail::GenericStringMap
This commit adapts the changes introduced in revng that generalize
`FunctionStringMap`.
2024-01-26 19:13:58 +01:00
Giacomo Vercesi 5f8143207d Generalize FunctionStringMap
Generalize `FunctionStringMap` into `detail::GenericStringMap`, which
supports any `Depth=1` rank. `FunctionStringMap` remains as an `using`
with `Rank = ranks::Function`.
2024-01-26 19:13:58 +01:00