Commit Graph

6113 Commits

Author SHA1 Message Date
Alessandro Di Federico 4353beff22 LLVMContainer: fix how we adjust linkage
We used to turn `internal` linkage to the equivalent of C++'s inline.
We need to do the same for `private`. If we don't do this, the number of
`private` variables grows exponentially.
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
Giacomo Vercesi 8e05ae5ead rcc: fix report output with multiple rules
The rule output logic was wrongly coded to do `"\n".join` where
appending a newline to each line was the correct behavior.
Also remove a leftover typo in `rcc-config.yml`.
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 77ea6c6db6 Fix serialization of Segment key 2023-03-13 13:42:33 +01:00
Alessandro Di Federico 9be304ece2 areMemOpCompatible: drop redundant check 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 7361da3629 Merge branch 'feature/fixes-for-hostname' 2023-02-23 14:51: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 892922794e rcc-config.yml: ban "#pragma clang optimize off" 2023-02-23 14:51:10 +01:00
Alessandro Di Federico 1d4fc9de5b rcc-config.yml: add documentation 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
Pietro Fezzardi 599cad1359 Merge branch 'feature/fixes-for-hostname' 2023-02-23 12:55:43 +01:00
Alessandro Di Federico d3f6d43ffe PromoteCSV: tag init_ functions with register
This enables downstream passes to selectively purge calls to `init_`
functions.
2023-02-23 08:30:22 +01:00
Alessandro Di Federico 969b3c0cb7 SystemV_x86_64: ignore fs register 2023-02-23 08:30:22 +01:00
Alessandro Di Federico deddd8ebd1 PromoteInitCSVToUndef: only preserved registers
Do not promote registers to `undef` initializers of registers not marked
as being preserved by the current function.

This is useful to highlight usages of registers that are not an
argument, nor a callee saved register. Mainly this has been introduced
to preserved reads from x86-64 `fs` register.
2023-02-21 16:48:35 +01:00
Alessandro Di Federico dfb18bd1cf RemoveLiftingArtifacts: drop makeInitRegsUndef
Redundant w.r.t. PromoteInitCSVToUndef.
2023-02-21 16:48:35 +01:00
Alessandro Di Federico 098b9b3aa4 PromoteStackPointer: prevent DCE of init_local_sp
We need to prevent DCE from killing `revng_init_local_sp`, since certain
passes downstream might want to introduce new uses of it, and they might
be the first.

`SegregateStackAccesses` will take care of removing it by hand.
2023-02-21 16:48:35 +01:00
Alessandro Di Federico e9b9ba50d1 MakeModelGEP: ignore negative strides 2023-02-21 16:48:35 +01:00
Alessandro Di Federico c18dca0031 Adopt new approach for MetaAddress serialization 2023-02-21 16:48:35 +01:00
Giacomo Vercesi 2b4cfafe55 revng.api: Fix file upload/buffer reading
This commit fixes file output `revng.api` in two ways:
* The buffer's size is properly reported in `PipelineC.cpp`
* The function `deserialize_container` in `revng.api.manager` no longer
  appends a `\0` to `content`, while avoiding a redundant copy
2023-02-16 15:11:00 +01:00
Giacomo Vercesi 5c6274aff7 Yield/SVG: fix xmlns attribute value
The `xmlns` attribute outputted contained two sets of `""` (one
introducted by the format string and one from `Tag`) which would break
strict XML parsers
2023-02-16 15:09:31 +01:00
Djordje Todorovic 24a5705e12 Importer: Attach attributes when copying types 2023-02-16 11:07:52 +01:00
Massimo Fioravanti 230036d5b1 Introduce TrackingContainer
TrackingContainer is a wrapper around KeyedObjectContainers (notably,
SortedVector) intended to figure out which elements of the underlying
container have been accessed.
2023-02-16 10:58:02 +01:00
Alessandro Di Federico 2e329b2d0a Merge branch 'feature/no-error-list' 2023-02-09 14:15:01 +01:00
Massimo Fioravanti 9eb33bcf8e check-convention: fix detection of asserts
A typo prevented check conventions from detecting non-revng asserts in
the code, which are forbidden.
2023-02-09 13:44:30 +01:00
Massimo Fioravanti 95ec36eea3 Fix error messages capitalization 2023-02-09 13:44:22 +01:00
Massimo Fioravanti 68ae1c986c DiffErrors now use DiffLocations
DiffLocation now allows to pinpoint which change of a diff generated a
issue.
2023-02-09 13:43:51 +01:00
Giacomo Vercesi 6f3dc255cf revng.api: adopt rp_error
Change Python's API to handle the new `rp_error` and its two variations:
`DocumentError` and `SimpleError`.
2023-02-09 13:43:33 +01:00
Massimo Fioravanti 2521ef434a Rework PipelineC errors
PipelineC errors are now splitted in simple and document errors.
Error lists are gone.
2023-02-09 13:43:09 +01:00
Massimo Fioravanti 4dc2e92782 Introduce DocumentError
`DocumentError`s are the inteded way of propagating errors from the
pipeline to the frontend when a location is required to inform the user
of the error whereabouts.
2023-02-09 13:42:50 +01:00
Alessandro Di Federico 4d0eb7eecb Merge branch 'feature/hitman-vscode' 2023-02-09 12:14:18 +01:00
Pietro Fezzardi 7edfffbbf8 DuplicateReferences: fix for chains of IsRef ops
The previous implementation was iterating on the instructions in order.
This caused problems when we had two instructions, A and B, both tagged
IsRef, and B was using A and B had 2 or more uses.
In this case the pass was looking at A before looking at B, so A was not
duplicated because it only had one use (B).
Then B was analyzed and it had 2 uses so it was duplicated, causing the
number of uses of A to increase accordingly.

This commit fixes the problem iterating on the BasicBlocks in post
order, and on the instruction list in reverse order.

It also fixes MarkAssignments.cpp not to erroneously mark instructions
that are marked IsRef.
2023-02-08 18:12:53 +01:00
Pietro Fezzardi 66434db5f9 Don't use named metadata revng.segment_ref
Using a named metadata is simply wrong, because we need to have many of
these metadata alive at the same time with different values.
Using a named metadata has the unpleasant side effect of making all the
`SegmentRef` functions to refer to the same segment.
2023-02-07 18:03:34 +01:00
Kacper Kołodziej 5b94a5a649 HelpersToHeaders: skip unnecessary helpers 2023-02-07 17:43:05 +01:00
Giacomo Vercesi 0e9431737f YieldAssembly: fix jump addresses
Change the way the jump instructions are outputted in the assembly
output to be PC-relative. This fixes an issue where the addresses in the
output where shifted forward.
2023-02-07 16:54:35 +01:00
Giacomo Vercesi 275e3943f7 daemon: rework starlette startup code
Rework the startup code used to boot starlette, this allows removing the
use of all globals, moreover it allow dropping the ManagerMiddleware
class as it is no longer needed.
2023-02-07 16:54:35 +01:00
Giacomo Vercesi 31bb77237f typescript: add setElementByPath function
add the setElementByPath function which allows setting a value in a
tuple tree give a tuple tree path to apply it to
Also apply some small fixes to the `tuple_tree.ts` codebase
2023-02-07 16:54:35 +01:00
Giacomo Vercesi 8a780a58aa GraphQL: return binaries in b64
This change fixes the pipeline behavior when producing targets:
* produce and extract now return rp_buffer, which has a start pointer
  and size
* the python api `revng.api` will return on produce/extract either str
  or  bytes depending on the mime type of the container
* the GraphQL api will encode bytes in base64
2023-02-07 16:54:35 +01:00
Giacomo Vercesi 82c3962a3c Add GZip Middleware
Add the GZip Middleware to rev.ng daemon, allowing it to handle the
`Content-Encoding: gzip` header
2023-02-07 16:54:35 +01:00
Giacomo Vercesi 23b8ed8dbe revng.daemon: allow extra middlewares
Introduce the environment variable `STARLETTE_MIDDLEWARES` that
allows adding additional middlewares at startup to the startlette
server.
2023-02-07 16:54:35 +01:00
Giacomo Vercesi 88e972c57c revng fifo events: move handling to daemon
Move all the event handling logic to the `revng.daemon` logic, since
now fifo notifications also include the JWT token (if present) of the
request.
2023-02-07 16:54:35 +01:00
Giacomo Vercesi fc93198e25 revng daemon: Fix resolve_step_artifacts
Fixes the GraphQL handler for step's artifacts as it was creating the
wrong object for the 'container' property
2023-02-07 16:54:35 +01:00
Giacomo Vercesi 52ff853d00 revng daemon: Fix CORS allowed headers
Add an option to CORSMiddleware to allow any header to be provided when
checking for CORS
2023-02-07 16:54:35 +01:00
Giacomo Vercesi 6f475d1368 revng.api: Fix signature of Target.kind 2023-02-07 16:54:35 +01:00