Include directives are groups by library, the groups should be sorted
from the most general (i.e., the STL) to the most specific (the local
includes).
This commit ensures that Boost includes are before LLVM includes.
This commit introduces a check in `check-conventions.sh` to prevent
committing code denoted by a `// WIP` comment, that are supposed to be
used to remind the developer something has to be changed before
submitting a pull request.
For a long time we had an issue on ARM: the linker would use as the
first page 0x10000. However, on many distros, that matches the first
page that can be mapped (see `/proc/sys/vm/mmap_min_addr`). Therefore,
this shouldn't be a problem, except the fact that the translated program
also needs the preceeding page for the (outer) ELF header.
We used to suggest users to run:
echo 4096 | sudo tee /proc/sys/vm/mmap_min_addr
Now in our tests, we force the text segment page to be at 0x20000,
therefore, this will no longer be necessary.
The symbol handling has been extended to register whether a symbol
represents a function or not. This information is then used to register,
during the global data harvesting phase, all the function symbols and
explicitly mark them through the "FunctionSymbol" `JTReason`.
We use this information during the CFEP harvesting phase to integrate
the information produced by the function boundaries detection with
potential unidentified CFEPs.
This option can be enabled with the `--use-debug-symbols`, which
supersedes `--use-sections`.
From version 0.25 pyelftools changed the API for ENUM_P_TYPE.
This commit wraps the import in a try-except block to handle older and
newer versions gracefully.
This is a very large commit importing the reviewed (and heavily
simplified) stack analysis and the new ABI analysis, which provides
information on the calling convention of each function and so on.
For an overview of the new analyses please consult OVERVIEW.md.
This commit fixes a bug triggered by the fact that the constructor of
the `FilePortion` class was not initializing fields featuring a "native"
type (which are therefore not automatically zero-initialized).
In particular, this bug was triggered when dealing with a dynamic binary
lacking the sections for dynamic relocations.
`StreamWrapper` is a class that wraps a stream of any type. It has a
`flush` method, that, when called with a `std::stringstream` copies all
of its content in the wrapped stream.
The main reason for having `StreamWrapper` is being able to have a
`dumpInternal` method in a `.cpp` file while preserving a
stream-agnostic `dump` method in the header.
`Twine`s are very cool but very subtle objects. You basically have to
use them as `const Twine &` arguments only. In fact, a Twine keeps a
reference to objects whose lifetime corresponds to the current
statament. Therefore, a `Twine` can easily end up holding a reference to
invalid objects.
This commit fixes a bug in function isolation (which would show up only
if optimizations are enabled) due to a misusage of
`Twine`. Additionally, it reduces its usage to safe places in
`statistics.h`. Finally, we added an assertion in `check-conventions.sh`
to ensure that no variables of type `Twine` are ever declared.
This commit simply reduces the length of lines in CMake by splitting the
statements over multiple lines. This is particularly useful when listing
the translation units composing a program/library. In fact, it makes
merge much easier.
`enum`s throw their entries into the parent scope. `enum class` can work
around this issue, however, `enum class` cannot have methods. Since we
often need to have `getName` and `fromName` functions for the enums, we
now create a namespace for each enum that contain a number of helper
functions.
Doxygen doc used to look for source files in the source root directory
only. We now use `git ls-files` to figure out which files need to be
part of the documentation.
The `CounterMap` class allows to increment a counter associated to an
arbitrary key. This is useful for printing out statistics, e.g., per
`Function` or `BasicBlock`.
`.clang-format` is the configuration file for the `clang-format` tool,
which can help us to enforce a consistent coding style.
`check-conventions.sh` is a a simple bash script that checks (using
mostly `git grep`) if, after running `clang-format`, there are some
undesired situations such as lines ending with "(" or "<".
This script should produce no output before a merge request is
merged. However, currently this is not the case, therefore the script
should be used mostly for new code (in particular, files) only.
A set of assertion-related functions has been introduced:
* `revng_abort(message)`: aborts, in release builds too.
* `revng_check(what, message)`: asserts `what`, in release builds
too. Also emits a `__builtin_assume`, that can lead to additional
optimizations in clang.
* `revng_unreahcable(message)`: identical to `revng_abort`, but in
release builds emits `__built_unreachable`.
* `revng_assert(what, message)`: asserts in debug builds, otherwise
emits `sizeof(what)` (to suppress unused variable warnings) and
`__builtin_assume`.
The adoption of these function has the following benefits:
* Nice stack traces.
* The developer can choose to enforce an `assert` (or an `unreachable`)
at release-time too by using `check`/`abort`.
* Most warnings about unused variables in release mode should be gone.
* When using clang, the `assert`s become `assume`s, which might enable
additional optimizations (with no run-time costs).
* The `assert(Condition && "Reason")` trick is no longer needed, we now
have a proper argument.
Equality comparisons used to be ignored more often than required due to
the fact that they give no hint on the signedness of the tracked value.
This commits removes some assertions and improves the handling of OSRs
without a known signedness. In particular, now, inequalities can be
solved even in absence of signedness information, as long as the result
that you would get with a signed OSR and an unsigned OSR matches (i.e.,
the signedness doesn't matter).
We used to have a special handling of unsigned comparisons, since we
assumed that each side of the comparison had to be greater than or equal
to zero. This commit further widens the cases in which this is
useful. Specifically, if both the comparison we're dealing with and the
greater-than-or-equal-to-zero comparison don't have an upper bound, we
flip one of the two in a way that ensure that they represent a closed
interval. Then, if the flipped comparison is the former, we reflip the
final result.
If a conditional branch propagates a constraint on a value that is
exactly the opposite with respect to its current constraint, we simply
ignore it, since simply flipping the condition (and the destination
basic blocks) would do the same.
In future, we should propagate a contradiction on the appropriate
branch.
We used to ignore the `.gnu.hash` section, however it turns out to be
fundamental in case the ELF we're working on *defines* one or more
symbols. This has not been a problem so far since we usually work with
the main executable only, which, usually, doesn't define any dynamic
symbol. However, for example, `ls` "defines" a `getoptind` symbol (more
accurately, it clones it from libc).
To handle this situation, we replace the `.gnu.hash` with a minimal
`.hash` section. Basically, the `.hash` section should contain an hash
table. However, currently, we just create an hash table with a single
entry, which immediately triggers scanning the chain of entries
colliding in the (only) entry.
The `FunctionCallIdentification` pass now has an API to get the
fallthrough basic block of a function call basic block and to check
whether a certain basic block/address is the fallthrough of a function
call.
This commit introduces a `dump` method for `OSR` and `BoundedValue` for
easier debugging within gdb. It also introduces `debug_function`, a
definition that wraps attributes to ensure the function is emitted even
if unused and emitted as a standalone function that can be called from
gdb.
`BoundsIterator` had an issue in case there was the need to iterat over
bounds reaching the upper bound of an integer: the increment would
generate an overflow that would go undetected and, therefore, lead to an
infinite loop.