Commit Graph

267 Commits

Author SHA1 Message Date
Alessandro Di Federico b74f09cad4 support.c: introduce unknownPC plus fixes
`unknownPC` is an extern function we expect to be linked to the output
which is called when we have to crash due to an unexpected jump target.

* Remove unused references to register variables, now only need the
  stack pointer
* Fix bug in how the auxiliary values were pushed on the stack.
* Push 0 HW_CAPs
* Implement some glib's functions
2016-04-14 16:10:13 +02:00
Alessandro Di Federico c8274af360 Let tests run from _start 2016-01-30 11:15:50 +01:00
Alessandro Di Federico 32b756510f Prepare stack for the translated program
* 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
2016-01-30 11:15:04 +01:00
Alessandro Di Federico 71f919675e Speedup compilation by using llc -O0 2016-01-30 10:57:15 +01:00
Alessandro Di Federico 0cffa717ed Use puts and itoa instead of printf in tests 2016-01-12 18:01:14 +01:00
Alessandro Di Federico ea61c896fb Introduce dependencies among tests 2016-01-12 18:00:51 +01:00
Alessandro Di Federico d510fea8c7 Simplify command line usage exploiting ELF info
* 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
2016-01-09 13:37:03 +01:00
Alessandro Di Federico 51ca34634b global.c: a new test for access to global data 2016-01-07 14:17:39 +01:00
Alessandro Di Federico 8ca9156be3 Add a simple test for the getuid syscall 2016-01-04 21:47:34 +01:00
Alessandro Di Federico f36bc6b42f Introduce tests for floaing point operations 2015-12-04 23:45:50 +01:00
Alessandro Di Federico 1d4e3169eb Add support for indirect jumps and function calls
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.
2015-11-15 12:06:17 +01:00
Alessandro Di Federico e2efe161e0 Add support for MIPS
First time all tests pass!
2015-11-10 09:22:58 +01:00
Alessandro Di Federico 94864e49b5 Introduce support for virtual addresses
* 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
2015-11-10 00:05:21 +01:00
Alessandro Di Federico 91a01937cf Let support.c know about the target architecture 2015-11-07 15:02:12 +01:00
Alessandro Di Federico f6ae68516d Use llc from the given LLVM installation 2015-11-07 15:01:34 +01:00
Alessandro Di Federico 15cfbee422 Make reference to QEMU install path and dlopen an absolute path 2015-10-27 11:56:08 +01:00
Alessandro Di Federico 9cf82f36d8 Introduce testing framework
* Import single-function calculator
* Create a puppet CMake project for cross-compiling
* Create a CMake manager for the tests
2015-10-27 09:13:14 +01:00