This commit performs the changes necessary in order to integrate with
revng-qa, the new project for cross-project quality assurance.
Basically, the source code of all the tests has been moved in revng-qa,
which will take care of producing "artifacts" (i.e., compiled programs),
using the appropriate cross-compilers.
revng will then consume them and produce new artifacts to be consumed by
other tools down the pipeline.
The directory structure of the tests has been reworked to reflect
`revng-qa`. A large amount of boilerplate code has been dropped.
Note that certain actions, that used to be carried out during testing,
are now part of the regular build process. Specifically, lifting the
tests is performed at build time, so that they can be installed.
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 check to see if a compiler supports the `no-pie` flag was done only
for the main C compiler, and not for the cross-compilers used for
creating the executables for the different supported architectures.
This commit introduces the aforementioned missing checks.
In addition instead of hard-coding the flags to check in the CMakeLists
file we have a list that we pass each time we instantiate a project for
the cross-compilers, and we check for the availability of all the flags.
In order to do this we need to apply a sort of serialization and
deserialization to avoid the "unpack" of the list passed as argument to
the external project (that is implemented as a `;` separated string).
Also implemented a fix suggested in the merge request for a line that
mistakenly added the `TEST_CFLAGS` variable to the `NO_PIE` variable.
So far we only had end-to-end functionality testing. This commit
introduces a new part of the testsuite which allows to verify quickly if
the results that a certain analysis should give are changed or not. This
is vital to be able to make larger changes.
So far the test suite is composed by the most difficult case we support
(the uClibc ARM memset) and the typical lowering of switch statements
for ARM, MIPS and x86-64.
I'm so happy now.
So far the only tests we had were end to end tests to assess the
functionality of simple programs and, in particular, certain helper
functions. In the perspective of being able to test individual features,
and in particular check that we have no regressions in our analyses, we
isolated these end to end tests in the Runtime directory. We kept in the
root test directory the mechanism to compile a binary for a certain
architecture so that all the test types can use it.
This commit removes all the ELF-specific code from the `CodeGenerator`
class by creating a new class, `BinaryFile` which contains all the
information about the program that might be needed in an image format
independent way. However, `BinaryFile` has some fields which are
specific to ELF, we might want to address this when additional file
formats are supported.
A key benefit of isolating this code is that we can anticipate the
parsing of the input file, so that we have its architecture available
earlier than when `CodeGenerator` is instantiated, therefore we can drop
the `--architecture` parameter.
* Use "$ORIGIN/../lib/" as RPATH when linking the installed binary
* Install also support material such as "support.c"
* Import the `translate` script for easy end-to-end translation
* Disable PIE if enabled by default
* Link librt.so to compiled binaries (sometimes the QEMU runtime needs
it)
* Replace `strtonum` with `int` in `awk` script
* Specify the compiler, not the triple
* Create 3 constant global variables (`phdr_address`, `e_phentsize` and
`e_phnum`) in the IR which will be used to populate the auxiliary
vectors at run-time.
* Update compile options for `support.c` to ignore useless warnings and
enable debug information
* Implement in `support.c` some functions required by QEMU run-time and
other cleanups to make it compatible with programs translated from
`_start`, not `root`
* Implement in `support.c` the `prepare_stack` function, which
initializes the base of the stack with environment variables,
arguments and auxiliary vectors
* Improve syscall support
* s/`importGlobalData`/`parseELF`/
* Save the entry point specified in the ELF header, which will be used
if the user doesn't provide an address.
* Let parse `parseELF` take care of informing libtinycode about what
has to be mmap'd and where.
* Remove some support scripts used during testing, now no longer
necessary.
* Various cleanups
The main aim of these changes is to support `ret` instructions (that are
indirect jumps), so that function calls can now work properly.
* Emit a dummy call to a `@newPC` function to record where a new
instruction in the original assembly started, what is its PC and its
size. The `Size` parameter for these function call is initially zero,
and it's updated later when a new instruction is met or the current
basic block is terminated. All these calls, before the final emission
of the IR are removed `InstructionTranslator::removeNewPCMarkers`.
* Transform translateMoveToPC into an LLVM pass
(`TranslateDirectBranchesPass`).
* Implement `getNextPC`, which returns the next program counter by
looking for a call to `@newpc` in the current basic block, and,
recursively, in all the basic blocks dominating the current one. This
function is used to force exploration of the basic block coming after
a direct jump, which is paritcularly useful in case of a function call.
* Introduce `translateIndirectJumps`, which translates all the leftover
writes to the PC, i.e. all the indirect ones, by diverting execution
to a large switch statement mapping addresses in the original program
to the corresponding basic blocks in the translated program.
* Introduce `function_call`, a simple test for function calls.
* Other minor changes and whitespace fixes.
* mmap on the PTC side before doing any translation
* Update usages of virtual addresses
* Refactor options to have --load-at and --entry
* Update tests according to the changes