Commit graph

597 commits

Author SHA1 Message Date
Paul
52656941fe r_core_print_disasm_json fix (#5479)
* r_core_print_disasm_json fix
2016-08-10 21:10:00 +02:00
Álvaro Felipe Melchor
dc5673ec3a Fix regression with the arm/thumb changes (#5464)
Now we build a list of ranges (RAnalRange) based on anal hints to handle the
bits in a better way in the case of arm/thumb

Now instead of asm.bits that rules the whole binary we can define ranges with
anal hints
2016-08-10 18:49:44 +02:00
@bezjaje
4e71ff36fe Honor endiannes and size too in reference values in disasm (#5469) 2016-08-08 23:40:56 +02:00
pancake
e8464e6d75 Honor endian in reference values in disasm 2016-08-08 11:35:03 +02:00
Álvaro Felipe Melchor
32335f7635 fix regression 2016-08-07 19:16:02 +02:00
Álvaro Felipe Melchor
0bc983027f improve arm/thumb in elf file format and disasm 2016-08-07 17:38:34 +02:00
Ahmed Mohamed Abd El-MAwgood
4668bc5ea3 Adding nonull (#5441) 2016-08-05 13:35:44 +02:00
pancake
d179c06af3 Support wide strings in rafind2 -ZS 2016-08-03 01:17:27 +02:00
Ahmed Mohamed Abd El-MAwgood
2dbb3d8fc6 Calling convention profiles in SDB (#5358) 2016-07-27 13:50:14 +02:00
pancake
0f8a5c8635 Fixes and enhancements for the previous commits 2016-07-05 23:25:16 +02:00
Ahmed Mohamed Abd El-MAwgood
85dcb19dae fixing type link consumes no bytes (#5288)
implementing initial api for types
Adding types profiles for x86 and x86_64 architectures
2016-07-05 22:44:53 +02:00
pancake
8532e0c6da Initial implementation of Vd1, the bit editor 2016-07-05 05:25:45 +02:00
Ahmed Mohamed Abd El-MAwgood
b31dd80724 Args/vars the last commit (#5245)
renaming afa, afv and afe to afvb afvr, and afvs respectively
making arguments analysis obeys e anal.vars
improving the json format for args/vars
fixing varsub to use the new comands for x86 and arm
fixing var commenting commands to use the new commands var configuration
2016-07-01 16:15:29 +02:00
pancake
98e90dd3cf Implement RSyscall.IO in disasm loop for X86 and AVR 2016-06-29 17:02:43 +02:00
Boris
bf6f243498 fix disassembling 'backwards' (#5228)
(e.g. pdj -1) producing wrong output, same as #5105
2016-06-28 23:21:46 +02:00
Jeffrey Crowell
c145740030 replace r_cons_printf("%s\n",p) r_cons_println(p)
move from 10% of code in vfprintf to just 6% \o/ for simple tests of r2
-c "aaa" -q /bin/ls
2016-06-26 00:52:03 -04:00
dx
fe57aefe67 Some memleak fixes in 'agj' (#5213) 2016-06-25 19:43:05 +02:00
pancake
90d42c0418 Refactor pia/pda and implement pdaj and pda= 2016-06-25 03:36:49 +02:00
pancake
550a91a17e Add asm.leahints to make @defragger happy 2016-06-20 09:46:03 +02:00
pancake
3bbb4d098b Refix CDIV deoptimization 2016-06-17 12:37:18 +02:00
pancake
ac2a80a1ef Fix bugs in CDIV implementation 2016-06-16 23:48:01 +02:00
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
702394caf9 Fix string flags realignment in disasm 2016-06-14 01:52:46 +02:00
radare
60ac486de1 Merge pull request #5117 from radare/arm-fixes
ARM fixes
2016-06-13 17:26:16 +02:00
pancake
e935aca270 Set esil->address before calling esil.parse 2016-06-13 15:05:48 +02:00
Ahmed Mohamed Abd El-MAwgood
0027246ec4 Fixing arguments docs 2016-06-13 13:09:46 +02:00
pancake
889ff52f37 Bring back the previous disasm changes 2016-06-12 23:42:40 +02:00
pancake
b829244c19 Fixes for thumb/arm string references and endian refptr 2016-06-12 23:42:37 +02:00
Ahmed Mohamed Abd El-MAwgood
13d8e65426 Enhancing comments for vars/aegs (#5127)
Adding locality properity to variable and argument comments

the old implementation made use of the standard r_meta functions to create comments using the frame offset as the address. this caused problems because more than one function might have variable at the same offset (with respect to each ones stackframe). so they will overwride each others comments.

adding `base64:` feature

prevening CC from processing var/args comment (in wrong manner)
2016-06-12 23:39:40 +02:00
Ahmed Mohamed Abd El-MAwgood
2d76ac0383 Implementing comments on arguments and vars (#5115) 2016-06-10 18:08:12 +02:00
pancake
11fde024c0 Fix asm.emu issue 2016-06-10 16:31:37 +02:00
pancake
3ffffd367f Only show fcn bit mode if different than current one 2016-06-10 10:57:43 +02:00
Álvaro Felipe Melchor
f018c2e727 Fix #5106 2016-06-09 18:17:51 +02:00
pancake
8340b342c4 Fix crash in last commit 2016-06-08 23:33:31 +02:00
Karol Harasim
df8fba3364 Get rid of global ESIL vars in disasm.c (#5102) 2016-06-08 21:16:00 +02:00
Karol Harasim
c1eb8253c2 Add support for 'pf [size]D' (#5063) 2016-06-06 10:36:09 +02:00
Ahmed Mohamed Abd El-MAwgood
7f48af3332 re construction argument/var commands (#5082)
afa for base pointer arguments/vars
afe for stack pointet arguments/vaes
afv for registers
fixing the J and \0 suffix
using the right register indexer
fixng the negative offsets of afa
fixing the afa afe afv views of pdf
fixing errors in aa
fixing the stack bases arg/var
fixing the varsub
fixing afa*
fixing afat
making afx- space neutral
enabling register renaming at varsub
updating the built-in help
adding r_reg as dependency for r_parse
2016-06-06 00:33:42 +02:00
pancake
d3394d5a7a Fix latest 28 COVs 2016-06-02 03:19:31 +02:00
pancake
88b71663c0 Fix more trailing spaces in dwarf and comments 2016-05-31 23:37:17 +02:00
pancake
f915412293 Fix some trailing spaces in asm.dwarf 2016-05-31 22:13:54 +02:00
Karol Harasim
c34181af02 Disasm refactorings. (#5043) 2016-05-30 12:35:39 +02:00
oblique
f8836c19b5 Fix glitch in disasm (#5031) 2016-05-30 04:22:20 +02:00
oblique
238cf897b8 Fix ptr comment colorization (#5032) 2016-05-30 04:20:04 +02:00
pancake
4de809061a Add MJMP optype, pxt command and enhance anal.jmptbl for x86-64 (wip) 2016-05-30 04:18:48 +02:00
pancake
71537eedf0 LEA instructions get hotkeys in visual disasm too 2016-05-30 02:12:17 +02:00
pancake
16d0396b8f Fix /A, add MJMP optype, and op.reg for UJMP 2016-05-30 00:38:35 +02:00
@bezjaje
dcac88091b Fixed typo in setting "gp" value in disasm (#5017) 2016-05-27 13:24:42 +02:00
pancake
18016c4ce7 Fix some warnings introduced recently 2016-05-25 00:44:41 +02:00
Sven Steinbauer
547f8bbc5c Infer fixes Round 2 (#4993) 2016-05-24 22:22:15 +02:00
zlowram
60b62560f1 Added anal hints to specify type base on disasm 2016-05-21 19:47:49 +02:00