602 Commits

Author SHA1 Message Date
UsusDei
5e7c93fc37 Add asm.hints and handle CDOV deoptimization
CDIV deoptimization
===================

This patch implements hints in the disassembler that
aim to assist the user in reading compiler-optimized divisions
by analysing the involved magic number.

Background
==========

Since integer divisions are usually very expensive on most architectures,
compilers try very hard to substitute them with cheaper operations.

One of the more advanced substitutions is described in the book __Hacker's Delight__,
chapter 10.
An actual implementation of the described algorithm in LLVM can be found in the
functions: `TargetLowering::BuildSDIV()` and `APInt::magic()`.

The optimization approximately transforms e.g.

```asm
xor edx, edx
idiv 39
```

into

```asm
mov eax, edi
mov edx, 0xd20d20d3
imul edx
lea eax, [rdx + rdi]
sar edi, 0x1f
sar eax, 5
sub eax, edi
```

Reading the optimized version and __seeing__ the constant 39 seems difficult.
Therefore I try to provide a small hint to the user.

Limitations
===========

* The current implementation only takes the magic number into account,
  therefore it may result in false positives.

* Due to the nature of the optimization, the given hint may be off by a power of two.
  Fixing this would require to analyse the following shift instructions.

* The hint is only shown in the line containing the magic number.
  The user still has to know which of the following instructions belong to the optimization.

TODO
====

* Implement the corresponding analysis for unsigned integers

* Implement the corresponding analysis for 64-bit integers.

* Improve the heuristic by also looking at the next few instructions.
  ( I don't really know how to iterate over the instructions in the disassember
  in a non-deprecated way. Maybe someone can drop me a hint? )

* Implement an exact analysis using the actual dataflow in radeco and use it
  to revert the optimization. ( I suppose this is outside the scope of radare )
2016-06-16 22:22:58 +02:00
pancake
d1b5737a59 Add anal.vinfunr 2016-06-10 15:31:38 +02:00
pancake
2ca927caea Add anal.vinfun for aav (only grab values outside function boundaries) 2016-06-09 21:52:25 +02:00
pancake
6e68c8de6b Use /m as default webui on all platforms 2016-06-08 09:32:54 +02:00
pancake
c64eeaa266 Initial implementation of asm.assembler to select different assembler plugin than the disasm 2016-05-30 18:53:32 +02:00
Sven Steinbauer
547f8bbc5c Infer fixes Round 2 (#4993) 2016-05-24 22:22:15 +02:00
pancake
c967514443 Add support for quiet and json listing of rasm2 -L and e asm.arch=? 2016-05-19 00:38:33 +02:00
pancake
a2fb171a37 Add R2PM_WWWROOT, update www-t and add http.homeroot r2 var 2016-05-16 00:59:29 +02:00
pancake
65ffbb12ce Fix wwwroot for android 2016-05-14 16:27:58 +02:00
rene
695d9a0d04 added shortcuts for every node in graph view
fixes mentioned in the pr
fixed the Vp issue mentioned in the pr
fixes the mentioned parts
changed reallocation size

Signed-off-by: Riccardo Schirone <sirmy15@gmail.com>
2016-05-12 23:49:30 +02:00
Sven Steinbauer
97a8fe9657 Make graphviz config options clearer 2016-05-10 22:12:50 +02:00
pancake
735ec47da4 Fix #4816 - load libraries if bin.libs=true (wip) 2016-05-09 17:24:12 +02:00
pancake
91a052f971 Fix #4817 - Deprecate file.analyze 2016-05-09 11:33:17 +02:00
Damien Zammit
af0a865d9f WIP - Totally remove host endianness dependence
- Adds endian aware functions
- Removes references to host endian
- Uses binary detected endianness else tries LE and restricts by RAsmPlugin
- Fixes gdb debugger endianness when debugging BE qemu gdbserver

Signed-off-by: Damien Zammit <damien@zamaudio.com>
2016-05-04 23:42:17 +10:00
Sven Steinbauer
9d68cf74f8 Colour current graphviz nodes and make colors configurable
Colours current node in Graphviz output (`ag` command) 'lightblue'.

Add `graph.gv.current` option to config with default to `false`

* White space fixes

Spaces before parens

* Make GV colour configurable

Using existing colours from the palette. Changes boxes from
`lightgray` to `gray` and allows settings for traced boxes, box colour,
and current box colour.
2016-05-04 00:50:33 +02:00
pancake
bbc3e4e24e Fix aggi;V, agc* and add proper callgraph support in V 2016-05-04 00:11:28 +02:00
pancake
08310a99cd Add io.0xff to define the value to fill unallocated area 2016-05-03 23:09:00 +02:00
pancake
6261fe32fb bugfixes + testsuite for the Internal Swift demangler 2016-05-03 04:31:36 +02:00
Andrey Torsunov
ae52382312 Rename bin.dwarf to bin.dbginfo. Issue #4688. (#4707) 2016-04-25 15:07:18 +02:00
andrey.torsunov
de1dac3f60 Add config option dbg.exitkills for issue #4670 2016-04-22 16:13:32 +02:00
pancake
93fcd7e722 Initial implementation of the anal.pushret (push+ret->jmp) option 2016-04-14 14:32:10 +02:00
pancake
4476720aa8 Fix regprofile regression 2016-04-08 13:36:15 +02:00
pancake
3ccdfbd6e8 Add asm.(symbol|section).col and honor meta in reflines 2016-04-08 02:56:42 +02:00
pancake
7bfa3f42cf Add graph.gv variables to set custom graphviz styles 2016-03-31 02:25:54 +02:00
pancake
fe0c38e372 Add asm.symbol to show flag/fcns in disasm 2016-03-29 02:03:17 +02:00
pancake
9d54015029 Handle referer in http server for CSFR protection 2016-03-28 23:38:45 +02:00
pancake
365162d4a8 Run file.analyze only when file contains entrypoint 2016-03-27 14:05:43 +02:00
pancake
ac96249a99 Set anal.autoname by default for now 2016-03-22 02:00:42 +01:00
pancake
218ffda4f2 Do not autoname functions by default. Add e anal.autoname 2016-03-22 01:39:43 +01:00
pancake
e4e9b01728 Add anal.strings false by default and enhance string detection 2016-03-14 09:42:54 +01:00
Maijin
daafa94407 Enable demangle by default fix #4266 2016-03-12 18:01:12 +01:00
pancake
9c05579ade Add ecn and use it from VR with scr.randpal 2016-03-06 12:35:07 +01:00
pancake
ec3ee44ae0 Implement asm.flgoff and asm.spacy + minor optimization 2016-03-04 00:33:24 +01:00
pancake
517f7fa23e Handle Vi in Vppc - aka change reg values with cursor 2016-02-25 11:35:59 +01:00
pancake
100df3bb32 Better MIPS32BE ELF relocs, add Rx regs in mips.cs and add scr.wheelnkey, nN defaults to flag now 2016-02-21 01:56:50 +01:00
pancake
1a89cac78f Initial support for search.overlap 2016-02-12 11:37:48 -06:00
pancake
37d4b269b5 Use io.va in debugger mode to disable io.isValidAddress and fix analysis 2016-02-03 12:53:35 +01:00
pancake
bcb065e5dd Fix #4031 and #4030 - asm.jmphints independent from asm.comments 2016-01-27 02:25:25 +01:00
pancake
32dbac517f Several bug fixes for gdb-arm and thumb remote debugger 2016-01-26 23:36:02 +01:00
Álvaro Felipe Melchor
c372743315 xnu: get rid of ptrace even for attach and detach
some rework in order to handle mach message as mach_exc_server and alike does
api change in plugin debug, now the function detach receive a pointer to RDebug
trying to deallocate port when are not needed any more
2016-01-23 22:50:28 +01:00
condret
ccab168cb5 fix a memleak and implement esil.stacksize for @crowell 2016-01-19 23:36:21 +00:00
pancake
3b4fc2cf9a Fix #3950 - Implement asm.emustr 2016-01-15 00:17:28 +01:00
pancake
8839fad03e Fix scr.fix_{columns|rows} 2016-01-14 23:41:14 +01:00
pancake
5ed63681b4 Fix #3921 - do not show dupped instructions with asm.nodup 2016-01-10 22:31:20 +01:00
akrasuski1
c33af2d540 Added real telescoping.
Right now, the telescoping works only one level deep: something points to something. This commit adds recursive telescoping, similar to gdp-peda's.
Sample screenshot: http://i.imgur.com/JsThuTD.png.

Uses hex.depth which is 5 by default
2016-01-09 03:15:09 +01:00
zlowram
abc5575dfc Fixes for #3899 and #3902
- If lines.from is 0, sl 1 seeks to baddr
- Added sll command to show total number of lines and removed the other
messages
2016-01-03 03:11:16 +01:00
Álvaro Felipe Melchor
c939ba7da9 Fix #3852 & changes in midflags 2015-12-31 02:10:18 +01:00
zlowram
db8fbcc68b Added config variable to set absolute or relative lines 2015-12-28 16:44:26 +01:00
zlowram
91611e8cbb Implemented slc subcommand and slc? help. prl now uses lines cache if
available.
2015-12-24 13:18:09 +01:00
pancake
6de6f35b30 Fixes for sl and lines.* eval vars 2015-12-22 02:33:09 +01:00