Commit Graph

21 Commits

Author SHA1 Message Date
Pietro Fezzardi b98228eed0 Fix generation of bool typedef in C 2021-02-04 14:33:41 +01:00
Pietro Fezzardi 6ad6d5294d Fix getPointedLayouts for struct types
Before this commit, we assumed that given a Value V, if only a single
entry was found for in ValueLayouts, it meant that is was a scalar type.

This assumption was wrong, because it could be a struct type for which
we didn't have information about memory access for all fields but one.
This caused some struct type to be wrongly identified as scalar types.

This commit fixes the issue.
2021-02-03 12:13:14 +01:00
Pietro Fezzardi c02db52709 IRASTTypeTranslation: fix bug in getPointedLayouts 2021-02-02 11:23:53 +01:00
Pietro Fezzardi 6c0cc326a4 Fix comment 2021-02-02 11:23:53 +01:00
Pietro Fezzardi ba0e57e956 DeclCreator: unify type mapping 2021-02-02 11:23:53 +01:00
Pietro Fezzardi 3f1ee6ea64 Stub of DLA integration in Clang AST emission 2021-02-02 11:23:53 +01:00
Pietro Fezzardi 2ff7044bb9 Decompiler: forward-declare types coming from DLA
This commits enable the emission of rich types associated with function
signatures. This types are forward-declared in the decompiled C code
before the definition of each decompiled function that uses them.

The types we emit for now are the types that the DLA is able to compute
(if any) for the return values and the arguments of the function.

Such types are not yet used in the body of the function, nor in the
function declaration. These are the next steps to come.
2021-02-02 11:23:53 +01:00
Pietro Fezzardi ca999a7c3c Add DeclCreator class to unify forward declaration
Before this commit, the logic to generate all the emitted C forward
declarations (types, global variables, and functions) that has to be
printed before each decompiled function was scattered across three
classes: FuncDeclCreationAction, TypeDeclCreationAction, and
GlobalDeclCreationAction.

These are all gone now, because the scattered logic was very confusing
to follow. Now we only have a single class that takes care of
declarations with global scope: DeclCreator.

Thanks to this, I was able to drop a bunch of useless layers of software
engineering used to shape the creation of the declaration as if it was
some kind of clang ASTConsumer, which is pointless.
2021-02-02 11:23:53 +01:00
Pietro Fezzardi 1e825a8201 Create IRASTTypeTranslator class
This class handles the creation of type declarations in clang's AST, and
holds the relationships between llvm Types and Values with those clang's
type declarations.
2021-02-02 11:23:53 +01:00
Pietro Fezzardi 93d9cbb67b Enforce new include conventions 2020-11-12 18:00:45 +01:00
Alessandro Di Federico 37fde04594 Move licensing details to LICENSE.md 2020-11-09 10:03:33 +01:00
Pietro Fezzardi 87611643ad Fix names of struct types declarations
Before this commit, we assigned names to struct types without looking at
the function names of which they were return types.
Now we do, so that the name of the generated type for the function `f`
is `f_ret_type`.

This also fixes errors when reparsing the generated C code, where the
names of the struct types did not match.
2020-11-03 12:53:11 +01:00
Andrea Gussoni 1daf3662f3 DIRTY: handle the array tipe of CPUState struct 2019-06-13 12:20:19 +00:00
Pietro Fezzardi b058c326c6 Enforce coding style 2019-05-08 17:40:53 +02:00
Pietro Fezzardi b68f4fd89c Print all types before variable declarations 2019-05-08 17:40:53 +02:00
Pietro Fezzardi de7089cbc4 Handle breaks from loops from within switches 2019-05-06 11:19:41 +02:00
Pietro Fezzardi ed3d1b1ab8 Properly print bool variables from stdbool.h 2019-04-05 18:52:13 +02:00
Pietro Fezzardi 28a9804143 Print int types from inttypes.h 2019-04-04 17:30:48 +02:00
Pietro Fezzardi 3f7965cf7f Fix emission of global struct types 2019-04-02 16:19:27 +02:00
Pietro Fezzardi 9e4c5f0ece Add support for functions returning structs 2019-04-02 11:57:07 +02:00
Pietro Fezzardi 2640bbfeeb Use uniform naming for decompiler source files 2019-03-11 18:11:05 +01:00