Commit Graph

3168 Commits

Author SHA1 Message Date
Ivan Krysak ea6148e616 DetectABI: leave a todo on droping RS deductions 2023-03-15 10:19:03 +01:00
Ivan Krysak a0adafeab0 ABI: take advantage of register state deductions
This makes the conversions more robust, since everything can rely on
the same tools for filling in missing registers and ordering them based
on the ABI requirements.
2023-03-15 10:19:03 +01:00
Ivan Krysak 0c82ff91b1 ABI: move the conversion ouside the helper class
This will allow reusing the helper class as the type manager.
2023-03-15 10:19:03 +01:00
Ivan Krysak 3422a9bf0f ABI: reintoduce conversion logs 2023-03-15 10:19:03 +01:00
Ivan Krysak b966637373 Layout: improve shadow return value handling
This brings the layout-side handling of these closer to the way they are
handled when converting the function.

The biggest change is the fact that now the return value location can
also be passed as the first stack argument.
2023-03-15 10:19:03 +01:00
Ivan Krysak a093d166b1 ABI: revamp basic floating point argument handling
This was a necessary change because without at least basic shortcuts
introduced here, we get a whole lot of failures downstream due to
layouts of such functions and the layout production is by design not
allowed to fail.
2023-03-15 10:19:03 +01:00
Ivan Krysak 9f7427c776 ABI: fix desynchronization of argument indices
When a shadow return value location argument is distributed, it is
shifting all the other argument indices by one. This was not taken into
the account previously. This commit fixes the indices.

It also makes it so the arguments `SizeOnStack` does not account for
padding. This is useful for some layout users.
2023-03-15 10:19:03 +01:00
Ivan Krysak f7be81737b ToRawConverter: don't attempt to recover types 2023-03-15 10:19:03 +01:00
Ivan Krysak 5bf13ac420 ABI: restructure ToRaw conversion root
This reorders the algorithms, so that the return values are handled
before the arguments. It also improves the wordind and extends
the comments annotating the function.

Moreover, it takes advantage of the `TypeBucket` to decouple type
management from the "raw" binary.
2023-03-15 10:19:02 +01:00
Ivan Krysak 4ecb88ab9d ABI: move ToCABIConverter onto the runtime trait 2023-03-15 10:19:02 +01:00
Ivan Krysak 51beb8fc1b ABI: move ToRawConverter onto the runtime trait 2023-03-15 10:19:02 +01:00
Ivan Krysak 59d3b627a1 ABI: simplify default prototype stack traces 2023-03-15 10:19:02 +01:00
Ivan Krysak 039de1fe6d ABI: move function prototype onto the runtime trait 2023-03-15 10:19:02 +01:00
Ivan Krysak 9e393578c9 ABI: move state deduction onto the runtime trait 2023-03-15 10:19:02 +01:00
Ivan Krysak b19572ea67 Model: Leave a note about the alignment 2023-03-15 10:19:02 +01:00
Ivan Krysak 84229d92b1 Model & ABI: make size and alignment stricter 2023-03-15 10:19:02 +01:00
Ivan Krysak 769e5c1cbe ABI: add a natural alignment calculation helper 2023-03-15 10:19:02 +01:00
Ivan Krysak 8b675e131e ABI: introduce runtime abi definition 2023-03-15 10:19:02 +01:00
Ivan Krysak 87bded80d3 ABI: rename RegisterList into RegisterVector 2023-03-15 10:19:02 +01:00
Ivan Krysak 3d3348b84a ABI: rename Converter into ToCABIConverter
This also moves members definitions outside the class boundaries
2023-03-15 10:19:02 +01:00
Ivan Krysak b1b9453585 ABI: rename Converter into ToRawConverter
This also moves members definitions outside the class boundaries
2023-03-15 10:19:02 +01:00
Ivan Krysak 0e8aee95e9 ABI: rename ArgumentContainer into ArgumentSet 2023-03-15 10:19:02 +01:00
Ivan Krysak 395191cdf1 ABI: use replaceReferencesIf when updating types 2023-03-15 10:19:02 +01:00
Ivan Krysak 01a05e2037 ABI: separate convertions based on the direction 2023-03-15 10:19:02 +01:00
Ivan Krysak 2f3128cb43 ABI: separate reused helpers into Support.h 2023-03-15 10:19:02 +01:00
Ivan Krysak 67bc7f8331 ABI: rename TheBinary into Binary 2023-03-15 10:19:02 +01:00
Ivan Krysak f5679262e9 DwarfImporter: prevent removal of valid arrays
The algorithm was looking for any array qualifier on a zero-sized
type, which led to some valid types being discarded in the case
when there was a pointer qualifier in-between.

`void a[100]` is not a valid type, while void *a[100]` is.
2023-03-15 10:19:02 +01:00
Ivan Krysak eb67826da6 PathList: accept non-owning strings as arguments 2023-03-15 10:19:02 +01:00
Ivan Krysak 058807ca00 model::Register: rename getArchitecture
The new name is `getReferenceArchitecture`
2023-03-15 10:19:02 +01:00
Ivan Krysak 726baf5318 Model: make Binary::recordNewType stricter 2023-03-15 10:19:02 +01:00
Ivan Krysak 3687869795 Model: make AddPrimitiveTypes a pure analysis 2023-03-15 10:19:01 +01:00
Ivan Krysak 03be19fab8 Pipeline: fix pure (model only) analysis support
Because of a missing function overload, no container-less analysis
could have been created. This adds the said overload.
2023-03-15 10:19:01 +01:00
Giacomo Vercesi 15da250710 api/daemon: fix single analysis handling
* Let GraphQL accept zero or more parameters for analyses
* Handle the general case of analyses using zero or more containers with
  a variable ammount of targets
2023-03-15 10:19:01 +01:00
Ivan Krysak 11c0d7f02e Stop using \brief doxygen command 2023-03-15 10:19:01 +01:00
Ivan Krysak 1c44e492af yield: improve command-less pipe error messages 2023-03-15 10:19:01 +01:00
Ivan Krysak 0b1aaeaede Minor improvements 2023-03-15 10:19:01 +01:00
Alessandro Di Federico 09541be398 getUniqueString: do not rely on named metadata
`getUniqueString` returns a dedup'd char array `GlobalVariable` given a
string. We used to rely on named metadata to dedup them. However, this
lead to issues with `LLVMContainer` cloning and linking.

The new implementation uses the name of the variable as the
de-decuplication key, circumventing the problem entirely and improving
performance.
2023-03-13 22:53:44 +01:00
Alessandro Di Federico 6f47231695 LLVMContainer: pruneDICompileUnits pre linking 2023-03-13 22:53:44 +01:00
Alessandro Di Federico 927f5b38be PromoteCSVs/EnforceABI: handle declarations
PromoteCSVs and EnforceABI were not handling declarated functions
properly, leading to issues downstream.
2023-03-13 22:53:44 +01:00
Alessandro Di Federico 54e8393cb8 Minor changes 2023-03-13 22:53:44 +01:00
Alessandro Di Federico bd61df1ddd PromoteCSVs::getUsedCSVs: fix non-helpers 2023-03-13 22:53:44 +01:00
Alessandro Di Federico 77ea6c6db6 Fix serialization of Segment key 2023-03-13 13:42:33 +01:00
Alessandro Di Federico e73bd95493 Improve handling of declarations
SegregateStackAccesses and PromoteStackPointer were not handling
functions declarated (but not defined) properly.

This commit fixes this, in part by adopting `TaggedFunctionPass`.
2023-03-13 13:42:33 +01:00
Alessandro Di Federico f6cdd8ad6d s/revng.register/revng.abi_register/ 2023-03-13 13:42:33 +01:00
Alessandro Di Federico f5a5990a30 Drop buildStringPtr in favor of getUniqueString 2023-03-13 13:42:33 +01:00
Djordje Todorovic 5482083e79 DecompileFunction.cpp: print debug info in PTML 2023-03-08 09:57:48 +01:00
Pietro Fezzardi f3e466c989 DecompileFunction.cpp: fix format for int literals 2023-03-01 12:22:35 +01:00
Alessandro Di Federico 9efe5e1366 PromoteCSVs: rename metadata to revng.abi_register 2023-02-23 14:51:10 +01:00
Alessandro Di Federico f68b7866b3 Introduce BasicBlockID
This commit introduces `BasicBlockID` as the unique identifier for a
`efa::BasicBlock` into the CFG. A `BasicBlockID` is defined by a
`MetaAddress` plus an incremental integer. This enables us to have
multiple instances of the same block in a single function, which is
particularly useful when inlining multiple times the same function.

Apart from this, the commit also does the following:

* It drops representing `MetaAddress`es a `structs` in the IR. This created
  several issues related to ABI. We now represent them as strings.

* It defines more functions in `support.h`, instead of defining prototypes
  by hand in `CodeGenerator.cpp` and the like. Specifically, `unknownPC`
  and `raise_exception_helper`. We also introduce a C "constructor" for
  `PlainMetaAddress`.

* It significantly reduces the API of `GeneratedCodeBasicInfo`, which
  was supposed to be put on a diet since a long time.  Specifically,
  many jump target related methods have been moved to free functions in
  `IRHelpers.h`.  Also `GCBI::getSuccessors` has been pushed into its
  only user, `PruneRetSuccessors`, to prevent further usage of a
  deprecated API. In the future, it would be nice to drop it entirely.

* It introduces `efa::BasicBlock::InlinedFrom`.

* Introduce an enum to represent named argument indices for `newpc`.
  This enables us to more effectively manipulate its argument list.

* It improves the verification and error reporting for
  `efa::FunctionMetadata`.

* Update tests.

This commit is preliminary to another piece of work to improve the
generality of inlining beyond the simple "fake function" scenario, for
which the feature was originally conceived.
2023-02-23 14:51:10 +01:00
Alessandro Di Federico 8886792ebb Logger: ensure we consume llvm::Error 2023-02-23 14:51:03 +01:00