Skip to content
Snippets Groups Projects
  1. Sep 21, 2018
    • Alessandro Di Federico's avatar
      Apply `clang-format` globally · 047ae0d4
      Alessandro Di Federico authored
      This commit applies our `clang-format` rules globally. From now on, all
      commits should respect our configuration file.
      
      Pretty large change.
      047ae0d4
    • Alessandro Di Federico's avatar
      Reorder Boost includes · 960286f4
      Alessandro Di Federico authored
      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.
      960286f4
    • Alessandro Di Federico's avatar
      Add braces around `else` · 31e5d1c9
      Alessandro Di Federico authored
      Sometimes the true-branch of an `if` statement was using braces but the
      false-branch was not. This commit fixes this.
      31e5d1c9
    • Alessandro Di Federico's avatar
      Force the text segment at 0x20000 on ARM · 5513ae60
      Alessandro Di Federico authored
      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.
      5513ae60
  2. Sep 20, 2018
    • Andrea Gussoni's avatar
      Register and add among JT reasons `FunctionSymbol` · 500d77f4
      Andrea Gussoni authored
      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`.
      500d77f4
  3. Sep 19, 2018
  4. Sep 18, 2018
    • Alessandro Di Federico's avatar
      Rewrite the stack and introduce the ABI analyses · 7fe00c08
      Alessandro Di Federico authored
      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.
      7fe00c08
  5. Aug 31, 2018
  6. Aug 18, 2018
    • Alessandro Di Federico's avatar
      Introduce new assertion framework · a0f4e0bb
      Alessandro Di Federico authored
      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.
      a0f4e0bb
  7. May 31, 2018
  8. May 30, 2018
    • Alessandro Di Federico's avatar
      Introduce statistics · 0dc77e10
      Alessandro Di Federico authored
      This class introduces the `RunningStatistics` class, which allows to
      compute the mean and standard deviation of a set of numbers. These
      values are computed incrementally and can be associated to a name. The
      values computed by `RunningStatistics` can be dumped upon regular
      program termination, `SIGABRT` and `SIGINT`. In practice they are
      printed at the end of the program execution, even in case of asserts and
      `Ctrl + C`. Moreover, `SIGUSR1` is used to trigger printing the
      statistics without crashing the program.
      0dc77e10
    • Alessandro Di Federico's avatar
      Introduce `ClassSentinel` · 8c148607
      Alessandro Di Federico authored
      Sometimes, dealing with move-semantics in C++ can be challenging. To
      mitigate this problem, this commit introduces `ClassSentinel`, a simple
      class that can be added as a member of a class and that will allow the
      user to easily monitor if an instance of a class is used after being
      moved in an unwanted way. To do so, simply call the
      `ClassSentinel::check` method on the class member.
      
      `ClassSentinel` performs similar (but less reliable) checks on usage of
      destroyed objects.
      
      `ClassSentinel` can also (optionally, though the `SENTINEL_STACKTRACES`
      macro) collect stack traces of the points where the object was moved or
      destroyed.
      
      This commit also includes some basic testing for the class.
      8c148607
    • Alessandro Di Federico's avatar
      Various minor cleanups · e407fc11
      Alessandro Di Federico authored
      e407fc11
    • Alessandro Di Federico's avatar
      Force CMake to link libraries using full path · 4eaa6f76
      Alessandro Di Federico authored
      If CMake detects `libhello` correctly and it is present in the system
      paths, it passes it to the linker as `-lhello`. However, sometimes, in
      particular when linking Boost, the compiler detects a different version.
      
      Forcing the CMake policy `CMP0060` to the new approach solves the
      problem, since CMake now always uses the full path of the required
      library, even if it's already available in the system paths.
      4eaa6f76
  9. May 29, 2018
    • Alessandro Di Federico's avatar
      Introduce support for dynamic binaries · 61cfbdfc
      Alessandro Di Federico authored
      This commit introduces support for dynamic programs. The current
      implementation translate the main binary and uses native libraries. This
      works only if the target architecture is the same as the source
      one. Currently we only handle x86-64.
      
      * The `ExternalJumpsHandler` class has been introduced. It basically
        takes care of extending the dispatcher handling the case in which the
        program counter is an address outside the range of executable
        addresses of the input program. In this case, a `setjmp` is perfomed,
        the CPU state is serialized to physical registers and jump to the
        value of the program counter is performed.
      
        Once the target code will try to return to the translated program, a
        segmentation fault will be triggered, a `longjmp` is performed and the
        CPU state is deserialized so that the execution can resume (from the
        dispatcher).
      
      * `early-linked.c` has been introduced. Its purposes is to provide
        declarations of variables and functions defined in `support.c`. In the
        past, we had to manually create these definitions, a cumbersome and
        error prone we now avoid by letting `clang` compile `early-linked.c`
        and then linking it in.
      
      * The old `support.h` is now known as `commonconstants.h`. `support.h`
        now contains declarations that have to be consumed by
        `early-linked.c`.
      
      * Each architecture now provides additional information:
      
        1. Which registers are part of the ABI and have to be preserved. If
           necessary the QEMU name can be provided. For each register it's
           also possible to provide their position within the `mcontext_t`
           structure, provided by the signal handler.
        2. Three assembly snippets, one to write a register, one to read it
           and one perform an indirect jump.
      
        Some of this information is also exposed in the output module as
        metadata.
      
      * `support.c` now installs a SIGSEGV signal handler. Since pages that
        were originally executable are no longer executable, jumping there
        (typically, from a library) will trigger a SIGSEGV that we will
        handle. This allows us to properly deserialize the CPU state and
        resume execution of the translate code.
      
      * Now also a dynamic version of each test program is translated and
        tested.
      
      * The `merge-dynamic.py` script has been introduced: it takes case of
        rewriting the translated binary so to tell the linker to performe both
        the relocations of the translate program and the relocations of the
        original program. It does so by rewriting a large portion of the
        sections employed by the dynamic linker such as `.dynamic`, `.dynsym`
        and so on.
      
      * The `compile-time-constants.py` script has been introduced: it a
        user-specified compiler on a source file producing an object
        file. This object file is inspected and the value of global read-only
        variables is produced in a CSV.
      61cfbdfc
    • Alessandro Di Federico's avatar
      Introduce `printf` test using `%f` · 9c2bb85f
      Alessandro Di Federico authored
      This test will be useful to test that calls to external libraries using
      float arguments work as appropriate.
      9c2bb85f
    • Alessandro Di Federico's avatar
      0bd4204e
  10. Apr 22, 2018
    • Andrea Gussoni's avatar
      Introduce the Function Isolation Pass · cf42e497
      Andrea Gussoni authored
      This commit introduces the Function Isolation Pass. We use the
      information provided by the Function Boundaries Detection Pass to
      organize the code that `revamb` places inside the `root` function in
      different LLVM functions. To do this we obviously need to introduce some
      changes and tricks to handle the execution of the translated program.
      
      The main idea is to have two different realms (one where the isolated
      functions live, one in which we have basically the old root function).
      We start the execution from the realm of the *non isolated* functions,
      and we transfer, as soon as possible, the execution to the *isolated
      functions* realm. We then have a fallback mechanism to restore the
      execution in the right place in the *non isolated* functions realm, and
      so on.
      
      The largest change, besides the re-organization of the code in different
      functions, is the use of the exception handling mechanism provided by
      the LLVM framework in order to be able to manage the switch between the
      two realms.
      
      We also introduce the `support.h` header file, which contains a couple
      of definitions used by `support.c` and that need to be shared with some
      of the components involved in the translation process. We have defined
      some helper functions, directly in C, that we use both for handling the
      exception mechanism and for giving extra debug informations when an
      exception is raised.
      
      The `revamb-dump` utility now supports the `-i` option to specify the
      path were to save the new LLVM module.
      
      The `translate` utility now supports the `-i` option that produces a
      binary in which the function isolation has been applied.
      
      We also introduced some tests that apply the function isolation pass to
      the `Runtime/` tests already present. In this way we can verify that the
      translation and the following function isolation preserve the behavior
      of the program.
      
      When serializing the new LLVM module we regenerate the metadata used for
      debug purposes, and for doing this, since we not longer have only the
      `root` function, we have changed some details in the `DebugHelper` class
      in order to be able to emit the metadata for all the functions of our
      interest in a single shot.
      cf42e497
  11. Jan 28, 2018
  12. Jan 17, 2018
    • Andrea Gussoni's avatar
      Add checks for `no-pie` flag for cross-compilers · 0735acd2
      Andrea Gussoni authored
      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.
      0735acd2
  13. Oct 28, 2017
  14. Aug 28, 2017
    • Pietro Fezzardi's avatar
      Add `-no-pie` to compiler flags · 55eb769a
      Pietro Fezzardi authored
      Add this flag to the flags used for Runtime tests and to the flags used
      in the translate script.
      
      Recent GCC versions (`gcc-7` and later) enable PIE by default, and
      `-fno-pie` apparently is not enough to disable it.
      55eb769a
  15. Aug 12, 2017
  16. Mar 31, 2017
    • Alessandro Di Federico's avatar
      Detect `try`/`catch` landing pads · d8f13c79
      Alessandro Di Federico authored
      Landing pads are basically the `catch` blocks in C++ `try`/`catch`
      statements. So far we were missing them since they are encoded in a
      particular way in a way similar to DWARF debugging information in the
      `.eh_frame` and, more specifically, in the `.gcc_except_table` sections
      of ELF programs.
      
      This commit parses these sections so that the basic blocks associated to
      landing pads are correctly identified. Personality functions are
      detected too. A test is also introduced to assess the effectiveness of
      our code.
      d8f13c79
  17. Mar 29, 2017
  18. Dec 08, 2016
    • Alessandro Di Federico's avatar
      c4221f1a
    • Alessandro Di Federico's avatar
      Introduce tests for the analyses · f6b61384
      Alessandro Di Federico authored
      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.
      f6b61384
  19. Dec 03, 2016
    • Alessandro Di Federico's avatar
      Improve testsuite · a7f10979
      Alessandro Di Federico authored
      * Add a label for runtime and analysis tests
      * Add support for per-test custom compile flags
      a7f10979
    • Alessandro Di Federico's avatar
      Reorganize testsuite · f67f7aef
      Alessandro Di Federico authored
      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.
      f67f7aef
    • Alessandro Di Federico's avatar
    • Alessandro Di Federico's avatar
      Isolate ELF code and remove architecture parameter · 83ea2caa
      Alessandro Di Federico authored
      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.
      83ea2caa
  20. Sep 22, 2016
    • Alessandro Di Federico's avatar
      Improve installation · d4871549
      Alessandro Di Federico authored
      * 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
      d4871549
    • Alessandro Di Federico's avatar
      Make revamb portable · 59c871af
      Alessandro Di Federico authored
      Add different search paths for QEMU components, in paritcular relative
      to the program's path.
      Also, install the revamb.
      59c871af
  21. Sep 20, 2016
Loading