Commit Graph

19 Commits

Author SHA1 Message Date
Alessandro Di Federico c069700bc5 Keep the CFG simple: do not jump to the dispatcher
Every time we don't know where an indirect jump can go, we used to emit
a jump to the dispatcher, however this complicates our analyses, in
particular the computed dominator tree provides less useful information
than it could.

This commit transforms all the jumps to the dispatcher into jumps to a
"anypc" basic block which during analysis just contains an unreachable
instruction, but during finalization this instruction is replaced with a
jump to the dispatcher. A similar (temporary) situation is for the
"unexpectepc" case.

This commit also makes the `visit(Sucessors|Predecessors)` functions
more idiomatic by employing a trait for black lists.
2016-12-04 00:28:56 +01:00
Alessandro Di Federico d01ee1f437 Copyright notices, license and credits 2016-09-21 01:45:26 +02:00
Alessandro Di Federico 5af920a69d Enforce 80 columns 2016-09-17 15:33:57 +02:00
Alessandro Di Federico cc87ad607d Introduce NoreturnAnalysis
This commit introduces the `noreturn` analysis, whose aim is to detect
all the basic blocks the are doomed to lead to a `noreturn` syscall such
as `execve` or `exit`.

* Implement `NoreturnAnalysis`.
* Include and initialize in the `Architecture` data structure all the
  necessary information to detect `noreturn` syscalls. Specifically, the
  name of the QEMU helper for syscalls, the name of the register holding
  the syscall number and the syscall numbers representing `noreturn`
  syscalls.
* `ReachingDefinitionsPass`: make reaching definitions available both in
  reaching definitions mode and reached loads mode. This part needs
  further cleanup. We also might be willing to implement this with a
  `Boost.Bimap`.
* Use `SET` to collect information useful for the
  `NoreturnAnalysis`. Also restructure how the `OperationsStack` works
  to be more streamlined and keep track of multiple information about
  the instruction currently being tracked.
2016-09-17 15:33:57 +02:00
Alessandro Di Federico f168621aa7 If OSRA provides no useful information, use SET 2016-09-17 15:33:56 +02:00
Alessandro Di Federico f51c0c2771 Ignore undef values in SET 2016-09-17 15:33:56 +02:00
Alessandro Di Federico 46fe86225b Free memory after analyses
* Clear all the data that's not part of the analysis results at the end
  of the `runOnFunction` method
* Clear all the data that's part of the analysis results when the
  `PassManager` tells us so (`Pass::releaseMemory`)
* Do not use the `clear()` method, since it doesn't release memory
* Add some debugging information
2016-09-17 15:33:56 +02:00
Alessandro Di Federico 65baa9fec0 Let SET always try to register the jump target
This patch removes the `JumpTargetManager::isInterestingPC` function
which used to prevent to register a jump target if it already
was. However this also prevents from marking that jump target as seen by
SET.
2016-09-17 15:33:55 +02:00
Alessandro Di Federico 27b4e46525 Draft tracking of reasons for registering JTs 2016-09-17 15:33:54 +02:00
Alessandro Di Federico 1d87dced75 Drop the concept of "reliable" jump target 2016-09-17 15:33:54 +02:00
Alessandro Di Federico ce5aa5507d Remove argument from OSRAPass::identifyOperands
Remove an useless argument from `OSRAPass::identifyOperands` and apply
some whitespace changes.
2016-08-20 03:10:49 +02:00
Alessandro Di Federico 850fbf1bbe OSRA: represent constants as BV constraint
Constant OSR are now represented through an OSR such as
[0 + 1 * x with x = (*, c, c)]. Since equality doesn't hold any
signedness information we introduce a new signedness type (available
only in `BoundedValue`), `AnySignedness`, which is similar to
`UnknownSignedness` but does not trigger `isUninitialized() == true`.

In `BVMap` we also introduce the concept of "forced" constraint, i.e. a
constraint that is fixed, cannot be changed or update. Constant stores
will produce this type of constraints.
2016-08-20 03:10:49 +02:00
Alessandro Di Federico 4d4127b1d0 SET: cast to correct type while materializing 2016-08-20 03:10:48 +02:00
Alessandro Di Federico 45dc6b3197 SET: track possible destinations of jumps
* `handleInstructionWithOSRA`: isolate usage of OSRA and increase its
  priority in SET.
* Let SET expose, for each store to the PC (i.e. a jump), the
  (approximate or exact) list of destination it can have.
* Extend the OperationsStack to explicitly track all the possible values
  that can be assumed by the instruction currently being analyzed. Note
  that before this patch we were only tracking possible jump targets by
  feeding them to JTM. The tracked values can be approximate or not,
  depending on the situation, and OperationsStack keeps track of this.
* Clean up some leftovers from the isolation of `SET` from `SETPass`.
2016-08-20 03:10:47 +02:00
Alessandro Di Federico 041ea8726d Introduce predecessors and successors 2016-08-20 03:10:47 +02:00
Alessandro Di Federico 89697ff34e Reorganize SET
* Isolate the SET algorithm from the SETPass
* Isolate the processing of an instruction in a function to be able to
  use returns to easily signal if we were able to handle the instruction
  or if we gave up
* Add some documentation
2016-08-20 03:10:47 +02:00
Alessandro Di Federico e986148e41 Prevent leak of cloned Instructions
SET needs to create clones of instructions, which are not inserted in
any basic block, therefore we have to manually handle their
lifetime. This patch delegates this role to the `OperationsStack`: when
an element is being popped from the stack the OS checks if it belongs to
a basic block and if it doesn't, it deletes it.
2016-08-20 03:10:46 +02:00
Alessandro Di Federico dbb462a9a5 Fix issues in release builds
Mainly fixes due to the absence of asserts.
2016-08-20 03:10:46 +02:00
Alessandro Di Federico 57721ff851 Isolate SET
* Rename `JumpTargetsFromConstantsPass` to `SET`
* Move `SET` to set.{cpp,h}
* Remove some useless includes
2016-08-20 03:10:45 +02:00