Commit Graph

2410 Commits

Author SHA1 Message Date
Pietro Fezzardi 8665cfd4d1 Add opaque function to LLVM test helpers
This commits adds an opaque function that can be called by simple LLVM
IR snippets used in unit tests.
2023-04-06 14:11:25 +02:00
Alessandro Di Federico 2159dbbdc7 Merge branch 'feature/cstring-literals' 2023-04-04 11:03:21 +02:00
Kacper Kołodziej bbebdd44b4 Prefer String.empty() case first 2023-04-04 09:30:09 +02:00
Kacper Kołodziej 17b0ecd78a Compare to nullptr instead of implicit cast
Prefer explicit comparing to nullptr instead of implicit casting pointer
to bool.
2023-04-04 09:30:09 +02:00
Kacper Kołodziej e7bb7d09df Rename getStrByAddress to getStringByAddress
We don't use abbreviations in names.
2023-04-04 09:30:09 +02:00
Pietro Fezzardi 8801fc3b33 Support empty strings in getUniqueString
This commit works around a quirk of
`llvm::ConstantDataArray::getString`, which returns a
`llvm::ConstantAggregateZero` for empty strings.

This quirk caused assertions in the previous implementation when passing
an empty `String` to `getUniqueString`.
2023-04-04 09:30:09 +02:00
Pietro Fezzardi 91af14007f Assert non-empty namespace in getUniqueString
Using an empty namespace causes the creation of a named metadata with an
empty string as name.
`llvm::verifyModule` does not check for that, so the `Module` still
verifies, but the on-disk serialization generated by `AsmPrinter.cpp`
prints `"empty name"` instead of the metadata name, and if the
serialized `Module` is then reparsed it parses succesfully but it does
not verify anymore.
2023-04-04 09:30:09 +02:00
Pietro Fezzardi ec17b36801 Fix attributes of build_PlainMetaAddress function
These allow it to be DCE'd and CSE'd if possible directly by LLVM
instead of requiring us to handle it esplicitly as a special case.
2023-04-04 09:30:09 +02:00
Pietro Fezzardi 4c2602e956 RawBinaryView: add getStrByAddress method
This method is similar to `getByAddress`, but it returns an
`llvm::StringRef`.

It is intended for those users that need to manipulate the bytes as
strings. In those cases, the `llvm::ArrayRef<uint8_t>` returned by
`getByAddress` is not suitable, because it triggers warnings due to
`uint8_t` not being the same as `char`.
2023-04-04 09:30:09 +02:00
Kacper Kołodziej 1b8801c9dc Add RawBinaryView::isReadOnly method
isReadOnly returns true if segment which contains region defined with
 MetaAddress and size is not writable.
2023-04-04 09:30:08 +02:00
Kacper Kołodziej d281d1fa05 Add --binary argument to llvm_pipeline.py 2023-04-04 09:30:08 +02:00
Giacomo Vercesi f7c796553b ContainerSet: fix typo
Fix a typo in the code of ContainerSet.intersect that would lead to an
incorrect intersection.
2023-03-31 15:50:46 +02:00
Alessandro Di Federico 94676ffde8 Merge branch 'feature/analyses-list' 2023-03-23 11:33:31 +01:00
Giacomo Vercesi 2e96e09f63 Drop analyze-all
Drop all the uses of analyzeAll and swap its use with the invocation of
the appropriate analysesList
2023-03-22 17:50:02 +01:00
Giacomo Vercesi af237074f3 Implement AnalysesList in Python API & GraphQL
Implement the new functionality of AnalysesList on the python's side of
rev.ng and the GraphQL schema both in static and autogenerated form
2023-03-22 17:31:46 +01:00
Giacomo Vercesi 23286dc58f GraphQL: expose analysis options
Add an additional parameter that allows specifying options for analyses
as a serialized json string
2023-03-22 17:31:46 +01:00
Giacomo Vercesi 1f097bb46a revng.api: Fix leftover snake_case in as_dict
This commit fixes the name of the fields returned by the `as_dict`
function that were left in snake_case when the field in the schema was
camelCase
2023-03-22 17:31:46 +01:00
Giacomo Vercesi a926ca8fcb revng: make cmd tools analysesList-aware
Add the possibility to use analyses lists on tools where the use of
analyses names is allowed
2023-03-22 17:31:46 +01:00
Massimo Fioravanti 0373732b69 Add auto-analysis list
Introduces a default analysis list indede to be run first on binaries.
2023-03-22 17:31:46 +01:00
Massimo Fioravanti 312e2e8d53 Add analyses lists
Introduces the possibility of specifiying lists of analyses as way to
give them coherent names.
2023-03-22 17:31:46 +01:00
Alessandro Di Federico b866e9010e ELFImporter: fix setting gp_mips canonical value
We used to set the canonical value of the MIPS gp register even in
absence of PLT, leading to a crash (specifically on archlinux librt.so).
2023-03-22 14:22:24 +01:00
Djordje Todorovic 956160e667 TypeCopier: Avoid copying the types twice 2023-03-22 11:38:12 +01:00
Alessandro Di Federico 2fdfaef77e Merge branch 'feature/fix-rename' 2023-03-20 16:38:11 +01:00
Giacomo Vercesi c7d13fd176 PipelineC: fix model verification clause
In the previous implementation of Model.verify an llvm::Error was
returned. Some call sites retained the logic associated with it. Fix
these with the correct logic.
Also fix an instance of `verify` that was missing an assert.
2023-03-20 16:20:06 +01:00
Giacomo Vercesi 3b94dfae4b PipelineC: rework rp_error data type
Drop the use of unique_ptr within the rp_error data type and instead use
std::monostate. Also fix the functions to allow the use of `nullptr` as
the error parameter
2023-03-20 16:08:04 +01:00
Alessandro Di Federico 92dd38c603 TypeCopier: copy PrimitiveTypes only when needed 2023-03-16 15:39:55 +01:00
Alessandro Di Federico d24a8ff120 Merge branch 'feature/stack-argument-alignment' 2023-03-15 14:07:47 +01:00
Ivan Krysak 9475eefe76 ABI-testing: add unit tests for the alignment 2023-03-15 10:19:03 +01:00
Ivan Krysak 64856306c4 BinaryImporter: rework command line interface 2023-03-15 10:19:03 +01:00
Ivan Krysak 35956f46fe DwarfImporter: leave a note about static functions 2023-03-15 10:19:03 +01:00
Ivan Krysak 19e292f097 abi::FunctionType: standardize std integer usage
This reevaluates the places where `std::size_t` should be replaced by
`std::uint64_t` in the conversions, it also appends `std::` prefixes to
them where it's possible in preparation to the eventual `import std`
transition.
2023-03-15 10:19:03 +01:00
Ivan Krysak 7c360eb8d1 PDBImporter: preserve x64 vector and clr ABIs 2023-03-15 10:19:03 +01:00
Ivan Krysak 34b532c754 BinaryImporter: always promote original name 2023-03-15 10:19:03 +01:00
Ivan Krysak 08b3764b23 BinaryImporter: prevent overlap in segment struct 2023-03-15 10:19:03 +01:00
Ivan Krysak 1f439cbb8c ABI-testing: extend to support unusual alignment
Because it's often hard to predict the specific location of an argument when
non-natural alignment is concerned, this adds an extra check allowing
the cases to pass if they would be well-formed if only some pesky
"extra" bytes were to disappear.
2023-03-15 10:19:03 +01:00
Ivan Krysak 750b6361a8 ABI-testing: add SPTARV support 2023-03-15 10:19:03 +01:00
Ivan Krysak d65ed50e0b ABI-testing: allow explicit abi overrides
Since dwarf sometimes misdetects abi pretty badly, to maintain
the usefulness of the test, it's beneficial to sometimes discard
the "detected" ABI by overriding it by the known value.

This also add a check ensuring that all the functions presents in
the artifact are also present in the binary.
2023-03-15 10:19:03 +01:00
Ivan Krysak a7be2cd11b ABI-testing: improve robustness against padding
Some cases of irregular padding were causing issues when verifying
arguments which varanted a bit of the rework of the main verification
loop.
2023-03-15 10:19:03 +01:00
Ivan Krysak e1ebe8ea35 ABI-testing: introduce CABI-FT correction script 2023-03-15 10:19:03 +01:00
Ivan Krysak a360b11426 ABI: fix issues with regparm abi definitions 2023-03-15 10:19:03 +01:00
Ivan Krysak 1f27e938bf ABI: rework non-position based distribution
The original non-position based distribution (`considerRegisters`)
algorithm had a whole lot of problems preventing effective padding
support because it was written with only registers in mind.

As such, it was easier to rewrite the whole logic from scratch over
trying to fix it incrementally.
2023-03-15 10:19:03 +01:00
Ivan Krysak e84c76019a ABI: introduce an additional definition option
The new option is `NoRegisterArgumentsCanComeAfterStackOnes`
If it's set to `true`, then no register argument can follow any stack
argument under the said abi, otherwise such "shuffling" of arguments
is allowed.
2023-03-15 10:19:03 +01:00
Ivan Krysak b8b1a716ed ABI: let NoOrDead painlessly decay to No 2023-03-15 10:19:03 +01:00
Ivan Krysak 550b286a9e ABI: stop treating stack pointer as callee saved 2023-03-15 10:19:03 +01:00
Ivan Krysak 15f8999fce ABI-testing: simplify compatibility checker
The complicated error handling logic turned out to be more of
a nuisance than a useful debugging tool. This commit removes it
in favour of `revng_abort`'ing or `revng_check`'ing to make sure
the actual state is consistent with the expectations.

It also adds namespace to `std::size_t` mentions.
2023-03-15 10:19:03 +01:00
Ivan Krysak 2dfe65f65c ABI: purge unnamed types when analyses are done 2023-03-15 10:19:03 +01:00
Ivan Krysak 17c128c59b Make ABI depend on ModelPasses
Before now the dependency was the other way around
2023-03-15 10:19:03 +01:00
Ivan Krysak 4d21a88777 Model: remove an obsolete function conversion pass 2023-03-15 10:19:03 +01:00
Ivan Krysak f068bcb34f ABI-testing: switch to the new analyses 2023-03-15 10:19:03 +01:00
Ivan Krysak 158272dee5 ABI: add an analysis for ToCABI conversion 2023-03-15 10:19:03 +01:00