Commit Graph

3168 Commits

Author SHA1 Message Date
Pietro Fezzardi 28cb749573 Fix usage of revng_call_stack_arguments in calls
Before this commit, we did not take into consideration that
revng_call_stack_arguments has reference semantics, and we were using
its AddressOf in call sites that were taking the stack arguments.

This commit fixes the problem, bypassing the call to AddressOf when
passing the arguments to calls.
2022-11-30 18:16:13 +01:00
Pietro Fezzardi daec840e37 Fix getStrongModelInfo for stack arguments
Before this commit, the code was assuming that we only passed stack
arguments to fuctions with RawFunction type. This is not true anymore.

This commit adds support to getStrongModelInfo for when we are passing
stack arguments to CABIFunctionType.
2022-11-30 18:16:13 +01:00
Pietro Fezzardi d3f2584158 DLA: fully support update of CABIFunctionTypes 2022-11-30 18:16:13 +01:00
Alessandro Di Federico f94ec452f4 SegregateStackAccesses: trunc stack arguments 2022-11-30 18:16:13 +01:00
Alessandro Di Federico 23dd27b6b6 Ignore stack arguments, if stack size unknown
This commit handles the situation in which we have a call site with
stack arguments, but it was not possible to determine the stack height
at the call site.

The solution is to simply ignore stack arguments and emit in the IR a
warning.
2022-11-30 18:16:13 +01:00
Alessandro Di Federico 800b8e6f16 DecompileFunction: handle string literals
We now emit global variables that are NULL-terminated strings inline.
2022-11-30 18:16:13 +01:00
Alessandro Di Federico 537c1e7524 IRHelpers: introduce emitMessage 2022-11-30 18:16:13 +01:00
Pietro Fezzardi acb4b495f7 MakeModelGEPPass: refactor YAML serialization 2022-11-30 18:16:13 +01:00
Pietro Fezzardi d34abf3706 DecompileFunction.cpp: fix ModelGEP traversal
handleSpecialFunction was still traversing Qualifiers in the wrong
order.
2022-11-30 18:16:13 +01:00
Pietro Fezzardi 1bec5bd2ab Define all primitive types in dedicated header
This commit does the following:
- drops revngfloat.h
- disables printing primitive types in ModelToHeader
- creates a new header revng-primitive-types.h which includes all the
  declarations of all revng primitive types
2022-11-30 18:16:13 +01:00
Pietro Fezzardi 7c643f3d1b ModelHelpers: support generic80_t and generic96_t 2022-11-30 18:16:13 +01:00
Pietro Fezzardi e92f6a3ddd ModelHelpers.cpp: refactor handling of ModelGEP 2022-11-30 18:16:13 +01:00
Pietro Fezzardi 2ab5b5d9bf Fix handling of UndefValue and PoisonValue 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
Alessandro Di Federico bff488b79e SegregateStackAccessesPass.cpp: drop bogus comment 2022-11-30 18:16:13 +01:00
Alessandro Di Federico 446db0b62c Model type purge: do not purge primitives 2022-11-30 15:06:54 +01:00
Massimo Fioravanti 452d10950e Pipeline: only remove targets in the container
This commit ensures that only content that is actually inside a
container is elegible to be removed.
2022-11-30 15:06:54 +01:00
Pietro Fezzardi e62aa0166e FunctionType::Layout: introduce argument kind
This commit introduces a `Kind` for arguments described in
`FunctionType::Layout`. We nowe basically have three types of arguments:

* Scalar: a regular scarlar argument;
* ReferenceToAggregate: a reference to an aggregete argument on the
  stack;
* ShadowPointerToAggregateReturnValue: a pointer to the storage for the
  (aggregate) return value allocated by the caller;
2022-11-30 15:06:54 +01:00
Pietro Fezzardi df30792435 PrimitiveType: support for 80 and 96 bits types
This commit completes the support of various rare PrimitiveTypes, that
has been added opportunistically over time and has remained inconsistent
across the codebase:

- float80_t
- float96_t
- generic80_t
- generic96_t

The first two are necessary because on some platforms long double is
either 10 or 12 bytes wide.

The second two are necessary because the Generic PrimitiveType should
allow all non-zero byte sizes allowed by any other PrimitiveType.
2022-11-30 15:06:54 +01:00
Pietro Fezzardi 8bf90e8bfd QualifiedType::isScalar: true for model::EnumType 2022-11-30 15:06:54 +01:00
Alessandro Di Federico 580ac34bf8 DwarfImporter: set Architecture if Invalid 2022-11-30 15:06:54 +01:00
Ivan Krysak e49f397d13 Layout: work around vector return value problems 2022-11-30 15:06:54 +01:00
Ivan Krysak 855999f5f0 Layout: add support for multiple return values 2022-11-30 15:06:54 +01:00
Ivan Krysak 535c9dd346 ABI: remove MinimumStackArgumentSize value
The architecture-specific pointer (generic register) size is used
instead.

For all the ABIs we support the value of this parameter was already
set to its pointer size. We might need to reintroduce the parameter
in the future if we want to support a super-exotic ABI with different
stack alignment requirements, but that seems highly unlikely.

This also introduces the argument extension helper for one stop all
treating small arguments when they are put into a register or pushed
into the stack.
2022-11-30 15:06:54 +01:00
Ivan Krysak 207668070a QualifiedType: add argument-less isPrimitive() 2022-11-30 15:06:54 +01:00
Alessandro Di Federico 85b7cf2b85 DetectABI: do not analyze functions with prototype 2022-11-30 15:06:54 +01:00
Alessandro Di Federico b83edd61c0 DwarfImport: fix handling of local functions 2022-11-30 15:06:54 +01:00
Alessandro Di Federico 98bea7dcec Minor changes 2022-11-30 15:06:54 +01:00
Pietro Fezzardi f7f5e5fd28 DLA: fix CompactCompatibleArrays 2022-11-30 11:37:00 +01:00
Pietro Fezzardi 1b05ff38be DLAPass: verify model after updating it 2022-11-30 11:37:00 +01:00
Pietro Fezzardi 1af6c75fc5 DLAUpdateModelTypes.cpp: new assertions & comments 2022-11-30 11:37:00 +01:00
Massimo Fioravanti 044071435e Fix handling of binaries with no functions
Fix various edge cases when a binary with no functions was analyzed.
2022-11-22 16:19:28 +01:00
Massimo Fioravanti a057ce54a7 Avoids missing outputs when empty
FileContainer should not be used when we wish to produce a empty output
file rather than no file at all.
2022-11-22 15:21:03 +01:00
Alessandro Di Federico 009c0c2434 flake8: disable R505 (else after return statement) 2022-11-22 15:10:52 +01:00
Massimo Fioravanti 0bfb73fe95 FunctionMetadata: introduce cache
FunctionMetadata was being deserialized every time they were
inspected. This commit introduces a cache structure to prevent this
excessive deserializations.
2022-11-22 14:15:00 +01:00
Massimo Fioravanti 335d402245 Change signatures to forward metadata cache. 2022-11-22 12:27:02 +01:00
Pietro Fezzardi fd0914b460 QualifiedType: add isConst method 2022-11-22 10:12:31 +01:00
Pietro Fezzardi 8aaa3ca92e Refactor PTML generation for functions 2022-11-16 16:02:09 +01:00
Pietro Fezzardi e72a578743 Refactor PTML generation for local variables 2022-11-16 11:24:37 +01:00
Pietro Fezzardi a23d4f8dcf Ranks.h: simplify ranks, delete unnecessary ranks 2022-11-15 15:54:20 +01:00
Pietro Fezzardi 7ab10df8f9 Remove useless location definitions for arguments
The actual ptml::attributes::LocationDefinition for arguments is already
generated when emitting the prototype of the functions.
The removed calls were just serializing the location definition once
more and disposing of it without serializing it anywhere.
2022-11-15 15:54:20 +01:00
Pietro Fezzardi 992302e9e3 ModelTypeNames.cpp: no space after ptr return type 2022-11-15 15:54:20 +01:00
Pietro Fezzardi ff631c5364 PTMLC.h: switch to string-based return values 2022-11-15 15:54:20 +01:00
Pietro Fezzardi c93392fa3b Refactor PTML generation for helpers 2022-11-15 15:54:20 +01:00
Pietro Fezzardi 38ce08edba PTMLC: add Const keyword 2022-11-15 15:54:20 +01:00
Pietro Fezzardi e1ded3a479 HelpersToHeader: refactor PTML Tags 2022-11-15 15:54:20 +01:00
Pietro Fezzardi 690056a4a6 DecompileFunction.cpp: refactor PTML Tags 2022-11-15 15:54:20 +01:00
Pietro Fezzardi 2ec8b7e32c ModelToHeader: refactor creation of PTML Tags 2022-11-15 15:54:20 +01:00
Giacomo Vercesi 7526d72492 Kinds: exposed locations produced
Expose the locations that can be found in each kind
2022-11-11 13:43:55 +01:00