Commit Graph

500 Commits

Author SHA1 Message Date
Alessandro Di Federico 54025b48ff s/ConvertToRawFunctionType/ConvertFunctionsToRaw/g 2024-02-09 10:04:23 +01:00
Alessandro Di Federico a9aaa8ced4 s/ToCABIFunctionType/FunctionsToCABI/s 2024-02-09 10:04:23 +01:00
Alessandro Di Federico 2bdca8ab03 Rename steps and analyses 2024-02-09 10:04:22 +01:00
Alessandro Di Federico b4817a4f14 Rename pipelines file 2024-02-09 10:04:22 +01:00
Alessandro Di Federico f74acda0f1 Import test for documentation 2024-02-09 09:04:25 +01:00
Alessandro Di Federico 490b9c6e7f Reorganize test suite 2024-02-09 09:04:25 +01:00
Alessandro Di Federico f6f542769b Convert all public strings to kebab-case 2024-02-09 09:04:25 +01:00
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 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 9c7aa51baa s/ToCABIFunctionType/FunctionsToCABI/g 2024-02-09 09:03:34 +01:00
Alessandro Di Federico 011d04eaaa Drop obsolete tools 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 11308a1bc7 Rename steps and analyses 2024-02-09 09:03:33 +01:00
Alessandro Di Federico 5c8c87a428 Rename pipelines file 2024-02-09 09:02:56 +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 da87b94a03 Drop VMA tests
VMA is obsolete and scheduled to be removed. The tests we had in the
test suite before this commit were for a mode of operation that we're
not actively using for decompilation now, and that will be dropped.
This commits just removes those tests.
2024-02-05 18:00:06 +01:00
Ivan Krysak be385fdfe8 model-to-header: avoid raw primitive arguments
After updating the function type conversion to be extra strict about
type alignment, the model-to-header tests for all these primitive
types no longer pass: it's no longer valid for a CFT to use any
primitives ABI is not aware of as part of the prototype.

As a simple workaround, this commit replaces all the primitives
used by said prototypes with pointers.
2024-02-01 11:38:57 +01:00
Ivan Krysak 4cb38a722c ABI: disallow ABI flags to be optional 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
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
Pietro Fezzardi c41a6392c0 Run loop-simplify to enable DLA to detect arrays 2024-01-26 16:49:52 +01:00
Pietro Fezzardi 04bb1d0fb3 Backend: avoid casting to uint8_t in conditions
Explicitly casting to uint8_t has the semantics of truncating, in case
the value being casted is larger than 8 bits.
Avoiding the cast default to regular C behavior, where every non-zero
integer is considered true.
2024-01-26 16:49:47 +01:00
Pietro Fezzardi 5d1ab13289 Drop old RemoveRefDeref pass
The pass has always been redundant, only used to simplify the IR and not
for anything useful.
Recently, after the work done to tidy up casts, it has started to give
problems: turns out ModelGEPRefs without indices are not always
redundant, and removing them can cause `trunc` instructions that then
end pessimizing the C code generation.

This commit drops the pass altogether.
2024-01-26 16:49:37 +01:00
Massimo Fioravanti f6ff8e544d Add tracking debug infrastructure
Add a mechanism to make the program crash when a given element of the
model is read or written.
2024-01-02 11:14:56 +01:00
Massimo Fioravanti e5347b2910 Remove llvm pipeline 2024-01-02 11:14:55 +01:00
Massimo Fioravanti 5a2e3b2359 Drop llvm pipeline 2024-01-02 11:05:50 +01:00
Alessandro Di Federico a3a549be48 EnforceABI step: reduce work done by InlineHelpers
InlineHelpers often inlines functions that contain a switch on an
argument that is constant on the call site. Specifically, this is true
for the `cc_compute_c` and `cc_compute_all` helpers of x86
architectures. The LLVM inliner, in such situations, is smart and
inlines a reduced amount of code, significantly reducing the maximum
size of the modules we work with.

However, before this commit, we couldn't capture this fact due to
`newpc` preventing constant propagation of the values of CSV set in an
instruction into their usage in the next instruction.

Running `PromoteCSV` before `InlineHelpers`, along with `mem2reg`
enables us to capture this behavior effectively.
2023-12-12 12:04:33 +01:00
Alessandro Di Federico 3709deebc8 SegregateStack: use alloca for stack arguments
This commit:

1. Introduces an alloca for stack arguments of a function. This enables
   us to "write" to stack argument. In order to do so, we simply map the
   relevant stack portion to the alloca that, since it's a memory
   object, can be `load`'d from and `store`'d to.

   Note that `llvm::Argument`s are always scalar since if the original
   argument was an aggregate, it would have been passed as a pointer,
   which is a scalar.

   Note also that previously we were using scalar arguments as if they
   were *pointers* to the stack arguments. This commit fixes that too
   (and updates the tests accordingly).

2. Introduces an alloca for *scalar* stack arguments of a call site.
   The alloca is then mapped to the corresponding part of the stack.
   Previously, there was no redirection and negative offsets from
   `_stack_frame` would pop up.
2023-12-12 12:04:15 +01:00
Alessandro Di Federico 071cdb1781 Enable ConvertToCABI analysis 2023-12-12 12:04:13 +01:00
Alessandro Di Federico 0e7d3a9a71 Pass PlainMetaAddress by pointer 2023-12-12 10:20:51 +01:00
Alessandro Di Federico 2e283fdf2a raise_exception_helper -> _abort and _unreachable 2023-12-12 10:20:35 +01:00
Alessandro Di Federico f2977128fa ABIs: mark link registers as callee-saved 2023-12-11 16:29:13 +01:00
Giacomo Vercesi 194bcecc41 Drop getReturnField
Drop the `getReturnField` helper, the cases in which it was used are now
covered by the `NamedTypeRegister::name` method.
2023-12-11 10:21:40 +01:00
Massimo Fioravanti b3a1aeaa89 Unify pipeline pipes yml files 2023-12-06 16:26:19 +01:00
Pietro Fezzardi 24cb43ce9c Make RawFunctionType::StackArgumentsType a TTR
This is homogeneous with all other nullable references to types in the
model, such as the StackFrameType in model::Function, and others.
2023-12-05 16:56:52 +01:00
Pietro Fezzardi 48b27af795 Make Segment::Type a TupleTreeReference
This is homogeneous with all other nullable reference to types in the
model, like the StackFrameType in model::Function, and others.
2023-12-05 16:19:38 +01:00
Massimo Fioravanti aa1a3e6764 Unify pipeline pipes files
Pipeline files are now a single file where the decompilation pipeline is
the main branch
2023-12-05 15:47:52 +01:00
Ivan Krysak fa7bf17dae IRCanonicalization: introduce ternary-reduction 2023-11-21 17:05:18 +01:00
Giacomo Vercesi 046612f11c revng.graphql: enforce index consistency
Force clients to provide the current index to run `produce` or
`runAnalysis`. Requests that do not provide the correct index return an
IndexError object.
2023-11-03 14:51:31 +01:00
Giacomo Vercesi 56af9c1f9d Propagate errors from Analysis/Pipes to daemon
Leverage the `rp_error` mechanism to propagate errors from analyses and
pipes to the GraphQL schema.
2023-11-03 12:13:58 +01:00
Giacomo Vercesi 4f94988a4d Add Globals Analyses
Add analyses that allow the modification of globals via the analysis
mechanism of Pipeline.
2023-11-03 12:13:58 +01:00
Ivan Krysak fc7d9841bf ABI-testing: simplify script structure 2023-11-02 17:10:04 +01:00
Ivan Krysak f3acdcdef3 ABI: rewrite the testing suite documentation 2023-11-02 17:10:04 +01:00
Ivan Krysak e9824977dd ABI: switch to the new testing toolchain 2023-11-02 17:10:04 +01:00
Ivan Krysak fdd3234e4f ABI: fix stdcall return value location 2023-11-02 17:10:04 +01:00
Ivan Krysak e4cbcaa520 ABI: remove an unnecessary repeat-for array 2023-11-02 17:10:04 +01:00
Ivan Krysak 99748a5cbc ABI: make microsoft ABIs more regparm-like
32-bit microsoft ABIs that allow using registers for accepting arguments
behave the same way `regparm` ABIs do, but weren't marked as such.
2023-11-02 17:10:04 +01:00
Ivan Krysak f4557f1353 ABI: fix alignment of scalars in 32-bit microsoft 2023-11-02 17:10:04 +01:00