Skip to content

Commit

Permalink
Merge branch 'code-inference-fixes' into 'main'
Browse files Browse the repository at this point in the history
configurable weights

Closes #546

See merge request rewriting/ddisasm!1148
  • Loading branch information
aeflores committed Mar 14, 2024
2 parents 9edfe9f + 5b71fb2 commit 8f90f23
Show file tree
Hide file tree
Showing 12 changed files with 560 additions and 286 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* Fix size access of LDR instruction in ARM64.
* Extend value_reg analysis to support memory loads using a register with
constant address.
* Refactor the code inference point system. Decouple heuristics from their weights.
Heuristic weights can now be modified by providing user hints.


# 1.8.0
Expand Down
16 changes: 16 additions & 0 deletions doc/source/GENERAL/5-AdvancedUsage.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,19 @@ disassembly.invalid 0x100 definitely_not_code
```
will add a fact `invalid(0x100,"definitely_not_code")` to the Datalog database of the disassembly pass.
The fields need to be separated by tabs '\t'.

You can consult the Datalog API reference https://grammatech.github.io/ddisasm/APIRef.html
for details on the internal Ddisasm predicates.

### Changing heuristic weights with hints

The code inference algorithm uses several heuristics to determine what is code and what is data.
Each heuristic has a weight associated to it, i.e. how many points a block candidate gets for a given
heuristic.

Users can modify the heuristic weights by providing hints with the `user_heuristic_weight` predicate.
For example, the following hint:
```
disassembly.user_heuristic_weight overlaps with relocation simple -4
```
changes the weight of the "overlaps with relocation" heuristic to -4.
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ set(DATALOG_BASE_SOURCES
datalog/boundary_value_analysis.dl
datalog/code_inference.dl
datalog/code_inference_postprocess.dl
datalog/code_inference_weights.dl
datalog/cfg.dl
datalog/data.dl
datalog/data_access_analysis.dl
Expand Down Expand Up @@ -309,6 +310,7 @@ if(DDISASM_ARM_32)
datalog/arch/arm_binaries.dl
datalog/arch/arm32_binaries.dl
datalog/arch/arm32_code_inference.dl
datalog/arch/arm32_code_inference_weights.dl
datalog/arch/arm32_jump_tables.dl
datalog/arch/arm32_symbolization.dl)

Expand Down
Loading

0 comments on commit 8f90f23

Please sign in to comment.