Commit Graph

64 Commits

Author SHA1 Message Date
Ivan Krysak 4e2159d9b5 MakeModelGEP: fix aggregate return value support 2023-03-15 10:28:24 +01:00
Ivan Krysak 56cdd8f876 Model: make model::Type::size() stricter 2023-03-15 10:28:24 +01:00
Ivan Krysak c2f0fc19e5 ABI: FunctionType.h -> FunctionType/Layout.h 2023-03-15 10:28:24 +01:00
Alessandro Di Federico f5a5990a30 Drop buildStringPtr in favor of getUniqueString 2023-03-13 13:42:33 +01:00
Alessandro Di Federico e9b9ba50d1 MakeModelGEP: ignore negative strides 2023-02-21 16:48:35 +01:00
Pietro Fezzardi 72b32dafa2 MakeModelGEP: array accesses jumping many elements
Before this commit we couldn't handle gracefully situations where the
model had an array with elements of given size X and the IR had strided
accesses with a stride Y that was larger than X.

This commit gracefully handles that case, but for now it always bail
out.

In the future we could think of handling this better if Y is a multiple
of X.
2023-02-07 08:12:42 +01:00
Pietro Fezzardi f0573995ba MakeModelGEP: use branch-and-bound approach
Before this commit, MakeModelGEPPass was materializing all possible
traversals of the type system to select the best match for translating
some pointer arithmetic on the IR into ModelGEPs.

This proved to be very slow and to do a lot of useless computation on
larger binaries with big type systems.

This commit partially rewrites MakeModelGEPPass to adopt a
branch-and-bound approach to only explore paths on the type system that
have some chance of improving the best match.
2023-01-31 11:39:28 +01:00
Pietro Fezzardi e33f6818cd MakeModelGEPPass: ignore non-pointer-sized Values 2023-01-17 11:11:55 +01:00
Massimo Fioravanti 87aef3fbad revng-c now uses Model accessors 2022-12-12 11:35:52 +01:00
Pietro Fezzardi b0e974f7a4 MakeModelGEPPass: fix adds with constants 2022-12-02 17:23:25 +01:00
Alessandro Di Federico d5f1ee1155 MakeModelGEP: handle returning aggregates 2022-11-30 18:16:13 +01:00
Pietro Fezzardi acb4b495f7 MakeModelGEPPass: refactor YAML serialization 2022-11-30 18:16:13 +01:00
Ivan Krysak 033ccbe51a Adopt FunctionType::Layout to improve CABI support 2022-11-30 18:16:13 +01:00
Ivan Krysak 654afbef0c Move pointer creation away from model::Binary 2022-11-30 18:16:13 +01:00
Massimo Fioravanti 335d402245 Change signatures to forward metadata cache. 2022-11-22 12:27:02 +01:00
Pietro Fezzardi 8497ab4b88 MakeModelGEP: don't crash on undef and poison 2022-11-10 13:05:51 +01:00
Pietro Fezzardi 0097af6dd0 Fix peelConstAndTypedefs for model::TypedefType
Before this commit typedefs were not unwrapped correctly, leading to
infinite loops.
2022-11-09 11:59:51 +01:00
Pietro Fezzardi 35b8d1b298 MakeModelGEP: avoid crash on function pointers 2022-11-08 14:09:07 +01:00
Pietro Fezzardi 73210ab4ae Adopt TupleTreeReference caching 2022-10-31 09:08:17 +01:00
Pietro Fezzardi 25119c4377 Drop bugged addPointerQualifier for getPointerTo
This commit removes the bugged addPointerQualifier helper function,
that was wrongly pushing the pointer qualifier at the end.

Instead, we now use the correct model::Binary::getPointerTo method.
2022-10-21 09:45:28 +02:00
Pietro Fezzardi 4df861a099 MakeModeGEPPass: fix makeBestGEPArgs for arrays 2022-10-18 17:05:50 +02:00
Pietro Fezzardi 46f54c4065 MakeModelGEPPass: std::move pickBestTAP results 2022-10-18 17:05:50 +02:00
Pietro Fezzardi 83737745af MakeModelGEPPass: fix ChildInfo dump() method 2022-10-18 17:05:46 +02:00
Pietro Fezzardi 8ab42d2899 MakeModeGEP: prevent copy of intermediate results 2022-10-07 18:15:25 +02:00
Pietro Fezzardi 688df14d55 MakeModelGEPPass: use caching more often 2022-09-29 15:14:48 +02:00
Alessandro Di Federico 2a7f685aa6 MakeModelGEP: use TupleTreeReference::getConst 2022-09-26 16:52:18 +02:00
Pietro Fezzardi eb16f4141a MakeModelGEP: remove too strict assertion 2022-09-01 14:31:19 +02:00
Pietro Fezzardi 7948d8ce56 MakeModelGEPPass: ignore callees of indirect calls 2022-07-29 09:24:21 +02:00
Alvise de Faveri c9930528ee ModelGEP: Fix pointee type in makeBestGEPArgs 2022-07-15 17:17:04 +02:00
Alvise de Faveri ad524a4d4d ModelGEP: Return the size of the gepped field
ModelGEP calls in LLVM IR now return an integer that has the same
size of the field being addressed by the ModelGEP.

AddressOf calls, instead, can accept any integer size as argument but
always return a pointer-sized integer.
2022-06-28 10:14:10 +02:00
Alvise de Faveri f010aea785 ModelGEP: Don't generate index-less GEPs 2022-06-28 10:13:37 +02:00
Pietro Fezzardi ad81bc7020 Enable addtional compilation warnings
These warnings are not enabled by default with -Wall nor with -Wextra.
2022-06-14 12:48:54 +02:00
Pietro Fezzardi 71b99464fe MakeModelGEPPass: consider type size in scoring 2022-06-14 10:56:56 +02:00
Pietro Fezzardi 43fb18219b MakeModelGEPPass: fix comparison of QualifiedTypes
This comparison was used to sort the best results among candidates for
creating ModelGEPs.

However the comparison itself was broken, i.e. you could have 2
different QualifiedTypes T1 and T2 such that T1 < T2 AND T2 < T1.
This caused broken sorting and non-deterministic selection of the best
ModelGEP substitution.

This commit fixes the comparison and as a result the selection of the
best candidate for the emission of ModelGEPs is not completely
deterministic.
2022-06-13 16:52:17 +02:00
Alvise de Faveri 7f37a22b5d Support: Improve peelConstAndTypedefs constness 2022-06-01 11:21:02 +02:00
Pietro Fezzardi 67c6c81e53 MakeModelGEP: ignore undef and null addresses 2022-05-31 12:40:52 +02:00
Pietro Fezzardi c88504afbf Drop old flag -single-decompilation
This flag was used with the old C backend to decompile only a single
function from a binary.

The logic of selecting functions in a binary for decompilation is now
part of revng-pipeline, so the -single-decompilation option and the
associated TargetFunctionOption library can be dropped.
2022-05-11 12:42:38 +02:00
Alvise de Faveri 96074c7938 ModelHelpers: Make dropPointer recursive 2022-04-20 17:35:05 +02:00
Alvise de Faveri 3fe9f687cc Move TypeMap initialization to InitModelTypes
Move the code that initializes the TypeMap in a separate library,
that will be shared between ModelGEP and the backend.
2022-04-20 17:35:05 +02:00
Giacomo Vercesi ab125b35b0 Fix License headers
Change company name to "rev.ng Labs Srl" in all license headers
to reflect changed company name and legal status
Add missing license headers to files that didn't have one
2022-04-19 12:17:59 +02:00
Pietro Fezzardi 36541ae5cd QualifiedType RawFunctionType.StackArgumentsType 2022-04-08 17:58:06 +02:00
Giacomo Vercesi da06acf29e Update to reflect removal of tags from model YAML 2022-04-08 17:57:23 +02:00
Antonio Frighetto 765219d58c Support for control-flow graph out of the model
The control-flow graph has been taken out of the model. Related changes
to `getCallSitePrototype` have been here addressed.
2022-04-06 16:25:05 +02:00
Pietro Fezzardi 58cdd814de MakeModelGEP: fix scoring for array accesses
This commit relaxes some assertions related to DLA, that were too strict
for general type systems not generated by DLA, and fixes the scoring of
the best access to select ModelGEPs.
2022-03-31 16:21:12 +02:00
Pietro Fezzardi ddf6c23be6 Migrate AddressOf to OpaqueFunctionsPool 2022-03-31 10:36:57 +02:00
Pietro Fezzardi b0ce5466d6 MakeModelGEP: fix off-by-minus error in assertion 2022-03-28 17:58:42 +02:00
Pietro Fezzardi d9906b572f MakeModelGEP: use perfect type match in scoring
Before this commit we did not take into account a perfect type match
when deciding the best ModelGEP to emit.

This commit changes the score to take it into account and score higher a
ModelGEP with perfect type match.
2022-03-28 09:51:52 +02:00
Pietro Fezzardi cd826fc52f MakeModelGEPPass: use CallToLifted tag 2022-03-28 09:51:50 +02:00
Alvise de Faveri 096ab1f5a1 Segregate: copy metadata on the new Call
Before this commit, SegregateStackAccessPass did not update properly the
metadata. Missing metadata did not allow the rest of the pipeline to
detect the special call.

This commit properly copies the metadata and updates the rest of the
pipeline to take care of the special call.
2022-03-22 11:48:27 +01:00
Alvise de Faveri 4d7e41e62a Add model type helpers to ModelHelpers 2022-03-22 10:55:11 +01:00