Commit graph

10197 commits

Author SHA1 Message Date
monosource
cea1c14750 Typo fix "afss-" -> "afvs-" (#5261) 2016-07-01 19:46:01 +02:00
Joshua J. Drake
70ef08de79 Address feedback from PR #5198 (#5260) 2016-07-01 17:41:13 +02:00
Joshua J. Drake
d380a83d23 Invert some logic to avoid nested brace hell (#5198) 2016-07-01 16:15:42 +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
9864ef8841 Lowercase all registers to match RReg rules in AVR 2016-07-01 15:22:23 +02:00
pancake
4c21937caa Reuse 6502 regsize hack for AVR 2016-07-01 15:22:10 +02:00
pancake
77eb8656a4 Initial import of the bin.avr plugin for atmega8 chips 2016-07-01 15:08:13 +02:00
pancake
9447bfa9b9 Fix analysis and add ESIL for avr's rjmp 2016-07-01 15:07:52 +02:00
pancake
a2a032833e Show file size if not matching in radiff2 2016-07-01 14:08:25 +02:00
pancake
8361f2ea83 Honor RIO in radiff's slurp - thanks @brainstorm for the tip 2016-07-01 14:02:46 +02:00
def
6fba927804 Use UT32_MAX as a magic value 2016-07-01 13:07:21 +02:00
Pavel Borzenkov
fe9c419fa5 libr/debug: fix native debugger on Linux (#5259)
Linux kernel checks for unknown flags passed via the last argument to
waitpid() and fails waitpid() with EINVAL if it encounters one:

From kernel/exit.c:sys_wait4()

	if (options & ~(WNOHANG|WUNTRACED|WCONTINUED|
			__WNOTHREAD|__WCLONE|__WALL))
		return -EINVAL;

This makes it impossible to use debugger on Linux.

WAIT_ANY macro is actually supposed to be used as PID argument to wait
for all children without specifying particular PID.

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
2016-07-01 11:13:57 +02:00
Jeffrey Crowell
365547ef82 libr/core/yank.c fix memleak 2016-07-01 01:00:06 -04:00
Jeffrey Crowell
73bddffbf0 /libr/bin/format/pe/pe.c fix off by one in strcpy 2016-07-01 00:57:38 -04:00
Jeffrey Crowell
d9fc1ce9fc fix random color switch statement 2016-07-01 00:56:35 -04:00
Álvaro Felipe Melchor
c3139b096d fix mem leak 2016-07-01 00:17:24 +02:00
def
c671b1c02c Fix collisions in ht.c 2016-07-01 00:17:20 +02:00
Álvaro Felipe Melchor
0e4e39db79 fix somes coverities 2016-06-30 23:38:41 +02:00
Roman Valls Guimera
4ebae2ee63 Add output ports for AVR Atmel8A. Thanks @radare and @oddcoder 2016-06-30 23:26:28 +02:00
Álvaro Felipe Melchor
4396598081 Fix oob read reported by revskill on mk68 code 2016-06-30 23:15:25 +02:00
Álvaro Felipe Melchor
d69a502eb5 fix indentation m68k_disasm 2016-06-30 23:01:24 +02:00
Álvaro Felipe Melchor
1652fccab4 Fix crash due to ht.c implementation 2016-06-30 22:01:25 +02:00
Anton Kochkov
f983244e92 Do not trust input for cmd length 2016-06-30 22:24:38 +03:00
Anton Kochkov
33ec5b9865 Fix coverities
CID 1357120
CID 1357121
CID 1357112
CID 1357099
2016-06-30 22:11:09 +03:00
Anton Kochkov
22e4a1d74c Fix Android build - 2nd try 2016-06-30 21:26:36 +03:00
Anton Kochkov
35f8178632 Fix Android build 2016-06-30 21:17:31 +03:00
pancake
98e90dd3cf Implement RSyscall.IO in disasm loop for X86 and AVR 2016-06-29 17:02:43 +02:00
pancake
c3bfbcd66d Fix anal.arm.cs crash for 32bit 2016-06-29 14:24:22 +02:00
pancake
ad85da85ff Fix code indentation in libr_cons 2016-06-29 12:33:31 +02:00
pancake
6479943c46 More boolification and code cleanup -70LOC 2016-06-29 11:35:16 +02:00
pancake
a05003fd5c Code cleanup -20LOC and get pagesize from target task in io.mach 2016-06-29 10:54:27 +02:00
Álvaro Felipe Melchor
4b08d38cb1 more mem leak fixes 2016-06-29 10:11:25 +02:00
Jeffrey Crowell
5317508cdb fix build 2016-06-28 23:54:57 -04:00
pancake
682a255f1d Fix #4665 - Add more core.num.value updates after write ops 2016-06-29 00:52:29 +02:00
pancake
59524ac8c4 Fix #4665 - Add wxs and fix crash in dbg println 2016-06-29 00:41:46 +02:00
Álvaro Felipe Melchor
3d2e922dc9 Fix oob in elf parser 2016-06-29 00:03:36 +02:00
Álvaro Felipe Melchor
dcf5c45963 Fix #5229 - 31e973c21f0d27b959d0b97d7b23216c by revskills 2016-06-28 23:57:00 +02:00
Álvaro Felipe Melchor
95db0cee52 Fix oob 52961b39cfb9782c336c8a8247a6317f by revskills 2016-06-28 23:50:41 +02:00
pancake
1660237a24 Fix #5230 - Fix oob read in mach0.objc parser 2016-06-28 23:46:09 +02:00
pancake
f4e493166b Fix #5224 - Fix UAF in RBinObject.mem 2016-06-28 23:44:18 +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
Álvaro Felipe Melchor
3cedcc1c4b Trying to fix memleaks (#5218)
* Trying to fix memleaks
* fix null dereference in r_anal_var_list
2016-06-28 23:14:16 +02:00
Álvaro Felipe Melchor
5de44950cd Fix get_bits in mach0 2016-06-27 23:07:20 +02:00
Álvaro Felipe Melchor
283c8ab2bc updated warning message in dwarf 2016-06-27 16:40:24 +02:00
pancake
fe644e60ff Fix crash in r2 -a arm -b32 -c'wa str r0' 2016-06-27 15:58:43 +02:00
Álvaro Felipe Melchor
d978b2cde4 fix oob in version elf 2016-06-27 12:17:25 +02:00
Álvaro Felipe Melchor
97b6bdbc40 Fix null dereference introduced before 2016-06-26 23:44:14 +02:00
Álvaro Felipe Melchor
4b497540a1 try to fix oob 2016-06-26 23:21:41 +02:00
Álvaro Felipe Melchor
a18bd79724 fix regression version info 2016-06-26 23:07:47 +02:00
Álvaro Felipe Melchor
76522930b0 Fix oob in store_versioninfo_gnu_verneed 2016-06-26 22:34:07 +02:00
Álvaro Felipe Melchor
5a582d3a13 Fix oob in debug_info pe.c 2016-06-26 22:29:43 +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
Jeffrey Crowell
10b9fc1db0 rm unneeded calls to r_cons_printf 2016-06-26 00:17:16 -04:00
Jeffrey Crowell
40af6b6065 fix macro for r_cons_println 2016-06-26 00:17:16 -04:00
pancake
dd6a168f82 Fix ood on OSX and clear raised on close 2016-06-26 04:51:44 +02:00
pancake
ee6be75b6e Fix bin/d installation and w32dist 2016-06-26 04:44:59 +02:00
pancake
b53a99aca2 Mark some x86-specific code only for x86 2016-06-26 03:56:08 +02:00
pancake
1a4177fed5 Fix exit in =! after o- a debugged process 2016-06-26 02:00:53 +02:00
pancake
b676e0acb3 Fix #5217 - Add anal.vars variable 2016-06-26 01:52:53 +02:00
pancake
9eef523bf9 Fix previous commit 2016-06-26 01:34:42 +02:00
pancake
564f63d9c3 Fix oobread in elf parser for 004e_00000000652b6080_000000000b3b7000.inp 2016-06-25 20:43:23 +02:00
condret
1aa3b6bf75 fix #4420, fix #4423 and refix #4422 (#5215) 2016-06-25 20:37:02 +02:00
pancake
badad8ffef Fix oobread in PE with 004e_00007fff4a3d9a9e_000000000b47b000.inp 2016-06-25 20:36:25 +02:00
Jeffrey Crowell
8f205587ba kill r_cons_puts add r_cons_print/r_cons_println 2016-06-25 13:49:58 -04:00
dx
fe57aefe67 Some memleak fixes in 'agj' (#5213) 2016-06-25 19:43:05 +02:00
condret
2b0124100a fix #4432 (#5212) 2016-06-25 19:17:12 +02:00
pancake
dcc02e87c5 More if DEBUGGER for linux 2016-06-25 18:48:26 +02:00
pancake
e3f7749f56 Aim to fix the sdb_version race condition issue 2016-06-25 18:26:34 +02:00
Jeffrey Crowell
7436b51095 add r_reg_32_to_64 for @condret
closes #5206
2016-06-25 00:03:44 -04:00
pancake
30deb7e3f2 Fix 004e_00007ffd2a9dc86.. from gamozo 2016-06-25 04:44:19 +02:00
pancake
4f785d398f Fix --disable-debugger on OSX 2016-06-25 04:26:07 +02:00
pancake
6ace96c3a5 Fix #5160 - make afbj great again 2016-06-25 04:17:31 +02:00
pancake
7e4cb2749e Fix #5002 - @o is a new modifier to temporary switch to another fd 2016-06-25 03:43:32 +02:00
pancake
b9e9d7fe4c Fix #4936 - Verify call destination in aac 2016-06-25 03:37:01 +02:00
pancake
baca25dc73 Fix #5200 - __WALL is a linuxism, better use WAIT_ANY 2016-06-25 03:36:58 +02:00
condret
b8f26d248b fix #4422 (#5203) 2016-06-25 03:36:53 +02:00
pancake
90d42c0418 Refactor pia/pda and implement pdaj and pda= 2016-06-25 03:36:49 +02:00
pancake
c351c3d767 Fix oobread in dwarf die values 2016-06-24 19:35:34 +00:00
pancake
7dab05df70 Fix oobread in dwarf decls 2016-06-24 19:35:34 +00:00
Jeffrey Crowell
36650442f5 fix heap oob-read in dwarf parser
https://gist.github.com/4352a2f4a239a96b90e7b23bb22e8ef1
for repro file
2016-06-24 14:58:47 +00:00
Sven Steinbauer
2c086751b9 Add fsincos instruction [fix #5204] (#5205) 2016-06-24 15:08:52 +02:00
pancake
311a339473 Fix memleak in spawn swift-demangler 2016-06-23 17:46:37 +02:00
pancake
a55bcd628f Fix two swift demangler crashes and add tests 2016-06-23 17:11:17 +02:00
Joshua J. Drake
99678d2fe0 Fix return consistency and clarify variable naming (#5199) 2016-06-23 10:40:14 +02:00
Álvaro Felipe Melchor
efd4ece4c2 fix warning comparing unsigned int >= 0 2016-06-22 23:54:21 +02:00
Álvaro Felipe Melchor
d65889d15d add name to section when is empty 2016-06-22 23:51:33 +02:00
Álvaro Felipe Melchor
42e507ebfa comment out hackaround for huge number of sections 2016-06-22 23:51:31 +02:00
Álvaro Felipe Melchor
8e6b857cdf more work in PE loader 2016-06-22 23:51:27 +02:00
pancake
e4eb7e5ee9 Workaround for enum vs type swig hack 2016-06-22 19:43:19 +02:00
pancake
feff5b59e4 Do not use %p for ut64 values 2016-06-22 19:20:59 +02:00
Sven Steinbauer
995c952c5d Fix #5097 : mov instruction with rex regs
sil, dil, spl, and bpl, registers now supported
2016-06-22 13:04:23 +02:00
Sven Steinbauer
db76ef6497 Add bt instruction [fix #1277] (#5194) 2016-06-22 12:31:08 +02:00
pancake
aaf3ff314c Fix #5138 - crash in swift demangler 2016-06-22 11:08:51 +02:00
Joshua J. Drake
722c62827b Major rework to the native debugger (esp on Linux) (#5185)
The major contribution here is completely re-worked breakpoint hit/recoil
handling. This work fixes #4907 and lays the ground work for future native
debugger improvements (multi-threading, etc).

* Give a human friendly type to enums
* Change many wait functions to return RDebugReasonType
* Better return checking (from r_debug_reg_sync, r_bp_restore)
* Optimized register synchronization
* Lots of comments and whitespace changes
* Improved inferior death detection

Handle EXIT_PID events differently than DEAD process events

* Move breakpoint/recoil handling to wait/cont/step

Rather than handing breakpoint related things inside cmd_debug.c, do that
inside the r_debug API functions. This seems like the most logical place for it
to live since it should apply to just about any platform/architecture.  This
also centralizes calling into "cmd.bp" handling via the CoreBind callback.

* Track how the caller wishes to continue

It turns out that handling break point recoils is very complicated. The ptrace
API on Linux returns SIGTRAP for just about every type of operation (not just
breakpoints getting hit). Add the "recoil_mode" flag to indicate whether we are
single-stepping or continuing and whether or not we are inside the recoil.

* Proper handling for swstep=true

Since r_debug_step_soft calls r_debug_continue, it's already hitting the recoil
case there. Move the recoil handling from r_debug_step to r_debug_step_hard
only.

For the swstep=true case, special handling is required inside r_debug_recoil.
By resetting all of the breakpoints except the one we just hit, we ensure we
can step the original instruction and hit the new swstep breakpoint. Add a new
bp function called r_bp_restore_except to do this.

To make matters worse, we cannot use a BreakpointItem pointer because that
leads to a use-after-free condition. Instead, we the breakpoint address
instead.

Now breakpoints should work regardless of the swtep setting.

* Always call the recoil before continuing

Some callers of r_debug_continue might not have ever inserted any breakpoints
before. If we don't restore breakpoints before each call to the underlying
continue we won't hit them.

* Hide software step breakpoint events from the user

When a breakpoint even happens due to a software-step, hide it from the user.
They aren't really breakpoints as far as they are concerned.

* Improve process exit handling on Linux

There are three types of process exiting events on Linux:

1. PTRACE_EVENT_EXIT occurs just before a process exits. It's not possible to
prevent it from exiting, but it can be used to inspect the pre-exit state.
2. The process can exit for a variety of reasons and we can notice when we call
waitpid(2).
3. The process could die randomly on us :-/

On Windows, h->wait will return R_DEBUG_REASON_EXIT_PID, but it's more likely
on Linux to find out the process is already dead.

* Check more bits within waitpid status

We can often make a decision about what happened strictly by looking at the
status returned from waitpid. In other cases, we need to call
r_debug_handle_signals.

If we reach the end of this function without knowing what happened, consider it
an error.
2016-06-22 10:34:45 +02:00
Sylvain Pelissier
50aed82b66 Add lfence, mfence and sfence to x86.nz (#5193) 2016-06-22 10:29:26 +02:00
pancake
bc02cdb4b1 Fix regression in afl/afi 2016-06-22 10:29:16 +02:00
pancake
f9482bcae7 Add console.html 2016-06-22 03:19:10 +02:00
pancake
bb00b4e91d Fix Android build, update Capstone and use Android's Studio NDK if available 2016-06-22 02:27:32 +02:00
Álvaro Felipe Melchor
8b957f8512 fix two uaf in anal.c 2016-06-21 23:32:40 +02:00
Álvaro Felipe Melchor
db28a0b20d fix hang in version info ELF 2016-06-21 16:42:34 +02:00
pancake
ab5f7bb9ee Update depgraph.pl 2016-06-21 13:16:00 +02:00
Álvaro Felipe Melchor
c5b6c78637 fix oob in dex 2016-06-21 12:44:43 +02:00
pancake
136d1d722d Fix #5184 - Remove useless warning message in r_debug_set_arch 2016-06-20 23:42:56 +02:00
danielps
1b21628964 V810: Fix floating-point instructions (#5186) 2016-06-20 23:39:01 +02:00
pancake
55e0804d1d Fix some null-terminated strings issues in the procfs parsing 2016-06-20 18:22:25 +02:00
Maijin
b3236816d9 Fix #5169 Update syscall table for iOS-32 2016-06-20 17:28:36 +02:00
Maijin
bc4ae90206 Fix #5169 Update syscall table for iOS 2016-06-20 17:27:32 +02:00
Joshua J. Drake
b03c1e2b3e Improve dkp and drp
Distinguish between "dXX" and "dXXYY" or "dXX?". Treat the latter two the same.
This provides the least surprise to the user when they mistype something.

Improve default handling in arp/drp

* Adds a new command "drp." for showing the register profile size.
* Provides better help for drpXXX commands.
* Provides help in the default case (eg. drpz)
* Fixes indentation
* Provides correct help strings for arp vs. drp

Improve default handling for "dko"

* Rework "dko" handling to simplify
* Use r_core_cmd_help
* Show help when things like "dkox" are used
* Prevent allocation/free when not necessary
2016-06-20 15:28:40 +02:00
Joshua J. Drake
16c27891a0 Switch to r_sys_perror for errors and fix two typos 2016-06-20 15:24:19 +02:00
Ahmed Mohamed Abd El-MAwgood
3bac42eda7 Improving variables on ARM (16, 32, 64) (#5146)
removing argument detection extension used in af now args are seperately detected by afCa
aa = af + afCa
using aliases as well as real registers
rewritten varsub
Fixing some of Arm esil and optimizing them for arg/var detection
2016-06-20 15:22:09 +02:00
pancake
0429420ee4 Fix the r_io regression thing 2016-06-20 11:08:21 +02:00
pancake
414aef609f Refix the ELF phdr max size issue 2016-06-10 11:00:40 +02:00
pancake
8c435e1a22 Fix doublefree issue 2016-06-10 10:58:10 +02:00
pancake
550a91a17e Add asm.leahints to make @defragger happy 2016-06-20 09:46:03 +02:00
pancake
2a29662dbd More r_io cleanup 2016-06-20 09:30:29 +02:00
pancake
ddeb71b83b Fix regression in r_io_seek 2016-06-20 09:22:34 +02:00
pancake
e3bcc9e7a2 More refactorings, reindent and cleanup on r_io 2016-06-20 09:12:44 +02:00
pancake
ab1c8e313e Fix for io.default 2016-06-20 01:27:23 +02:00
pancake
4caafc964d Refactor r_io, while fixing some bugs and use more RList 2016-06-20 00:29:41 +02:00
pancake
81c977c979 Refactor r2 -iL and add oL (load plugins before r2 -L) 2016-06-19 23:32:58 +02:00
Álvaro Felipe Melchor
564803d5c2 express db breakpoints as dbm due to ASLR 2016-06-19 14:04:23 +02:00
Maijin
1117f5e19c Fix #3874 2016-06-19 12:30:30 +02:00
pancake
59f63e5f8d Handle Windows's noreturn call to ExitProcess 2016-06-19 12:26:58 +02:00
Jeffrey Crowell
769bcf98f6 add RBitmap to the rapi (#5176) 2016-06-19 11:10:59 +02:00
Jeffrey Crowell
387c2ce479 fix SIGFPE when queue is created with size <=0 2016-06-18 21:33:00 -04:00
Álvaro Felipe Melchor
93105250ab Handle bad PE files 2016-06-19 00:19:03 +02:00
pancake
43781f390a Code cleanup 2016-06-18 01:15:52 +02:00
ekse
60220bc525 Check that a required argument was passed for a couple of commands. (#5166) 2016-06-17 23:17:24 +02:00
pancake
e2ab783250 Fix for regression in thumb/arm detection 2016-06-17 23:05:13 +02:00
pancake
016f5ec8ed Fix arm on thumb bins issue 2016-06-17 19:38:37 +02:00
pancake
3b0b7db100 Fix another oobread caused by callconv 2016-06-17 18:42:50 +02:00
pancake
bfa8eb740a Optimize callconv and fix two bugs related to op_pos 2016-06-17 18:38:25 +02:00
pancake
a46689b1b4 Fix oobread in ELF with 70d23ff5faa2716094f1fd1f081f9281678455dd 2016-06-17 17:16:41 +02:00
pancake
fb3be2c58f Do not nullify RAnalOp after fini() 2016-06-17 15:52:57 +02:00
monosource
dc61e8c511 Change afbr description (#5163)
`afbr`'s description isn't worded properly. It doesn't actually print addresses of `ret` instructions, but of instructions which cause the flow of the program to leave the function body, like `call`, `jmp`, `hlt` etc.
2016-06-17 14:26:46 +02:00
pancake
1629dd2b64 Remove two unused fields in RAnalOp and some deadcode 2016-06-17 14:26:24 +02:00
pancake
281d79da58 Remove some DEAD code and a copypaste error in coredump 2016-06-17 12:53:21 +02:00
pancake
3bbb4d098b Refix CDIV deoptimization 2016-06-17 12:37:18 +02:00
pancake
f96f00d62d Fix #5158 - Merge r_db into r_util 2016-06-17 12:19:16 +02:00
Joshua J. Drake
0431a0efdf Properly handle forks on Linux 2.5.46+ (#5153)
Linux 2.5.46 made changes to the ptrace(2) API to inform a tracer when various
events occur. These are known as PTRACE_EVENTs. Start handling PTRACE_EVENTs
by:

 * Handling PTRACE_EVENT_FORK and PTRACE_EVENT_EXIT
 * For _FORK, stores the newly created pid in dbg->forked_pid
 * Add the "dpc" command to select the most recently forked child process.
 * Add the "dpc*" command to show the recently forked process' pid.

Additional minor changes to white space are included.

NOTE: This partially addresses #3549. It does handleLinux before 2.5.46.
2016-06-17 04:20:18 +02:00
Joshua J. Drake
9f570114c7 Add "clone" to the "dcf" command (#5161)
Previously, "dcf" didn't not consider that "clone" may be used to create child
processes. Look for that and also update the text shown to the user.
2016-06-17 04:19:31 +02:00
pancake
43472476c5 Fix w32 build 2016-06-17 03:35:11 +02:00
pancake
911fef209a Implement afbr and * sub-variants to list return addresses of current function 2016-06-17 02:50:01 +02:00
Joshua J. Drake
9c21df9272 Minor cleanups to process handling (#5152)
* Fixed 'dpk' handling (signal wasn't being groked)
* Mostly comments added
* Some eprintfs added
2016-06-17 01:59:10 +02:00
Joshua J. Drake
e76cd01564 Fix io_w32dbg build (#5159) 2016-06-17 01:43:16 +02:00
pancake
ac2a80a1ef Fix bugs in CDIV implementation 2016-06-16 23:48:01 +02:00
pancake
66e783965f Fix build and oobreads in =!pid 2016-06-16 23:42:11 +02:00
Joshua J. Drake
691dd0a5c5 Make "dbt" output aligned to columns based on dbg->bits (#5151)
* Make "dbt" output aligned to columns based on dbg->bits
* Add spaces between sizeof and paren
2016-06-16 22:57:44 +02:00
Joshua J. Drake
2b9edf8dc4 Fixes #5154: Stop including source-file whitespace (#5155) 2016-06-16 22:57:10 +02:00
Joshua J. Drake
e97e011426 Have r_debug_select change IO pids too (#5145) 2016-06-16 22:56:21 +02:00
pancake
5186afdbe4 Only attach io.pid when its different 2016-06-16 22:56:02 +02:00
pancake
4e67a31087 Fix some more =!pid cmd parsing issues 2016-06-16 22:53:16 +02:00
pancake
565c97f8f5 Fix =!pid for io.w32dbg 2016-06-16 22:53:10 +02:00
Joshua J. Drake
fb820f9c8e Fixes #4875: Refactor process listing (#5144)
* Fixes #4875: Refactor process listing
* Move procfs-based process listing into linux_debug.c, guarded by __linux__
* Provide a warning and eprintf a TODO on the remaining platforms.
* Break reusable parts into linux_get_proc_pid and call it as needed.
* Add/remove comments for clarity
* Address feedback and re-enable non-Linux
2016-06-16 22:39:11 +02:00
Lev Aronsky
db8414d186 Fixed order of arguments in ESIL representation of MUL. 2016-06-16 22:33:16 +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
48e5f8fc7e Fix ELF crash (null deref when missing shdr 2016-06-16 22:18:10 +02:00
Joshua J. Drake
176054c006 Fix ELF section size validation (#5148) 2016-06-16 16:43:04 +02:00
Joshua J. Drake
285cd3b32f Minor tweaks to breakpoint handling
* Fix "dbm" help string
* Save <module>+<offset> as the name when using dbm
* Fix allocation patterns for "module"
* Remove commented out code
* White space fixes
2016-06-16 12:36:17 +02:00
pancake
d3cae9d5a9 Show classname for static methods in DEX 2016-06-16 12:30:38 +02:00
pancake
b843aaf054 Fix imports and enhance parsing virtual methods in DEX 2016-06-16 05:04:00 +02:00
pancake
1111c00ea2 Better names for virtual Dalvik methods 2016-06-16 02:42:54 +02:00
pancake
b50a06f57c Load virtual methods from Dex files 2016-06-16 02:33:59 +02:00
pancake
5c14841299 Support op->family and some op->cycle for anal.arm64 2016-06-16 01:43:41 +02:00
Jeffrey Crowell
2f6d778aef cleanup usages of r_str_newf to meet style guide 2016-06-15 19:42:03 +00:00
Sven Steinbauer
d45101eebe Add offset support to add instruction (#5137)
support syntax for

add eax, [ecx]
add ecx, [eba +/- 3]
2016-06-15 15:33:14 +02:00
pancake
794c60bf18 Fix #5138 - huge load times for fuzzed versioninfo ELFs 2016-06-15 15:30:51 +02:00
pancake
0e9e80c578 Fix #5138 - crash in elf parser 2016-06-15 15:13:41 +02:00
pancake
84aa6782f1 Add trailing newline in afbj 2016-06-15 13:41:45 +02:00
Riccardo Schirone
04190287c1 core: fix uber confusing indentation in cmd_anal "afl" command 2016-06-15 11:15:42 +02:00
pancake
1bdcb740dc Fix regressions introduced in last commit 2016-06-15 00:23:44 +02:00
pancake
e032a48cbe Fix latest 26 COVs 2016-06-14 23:47:58 +02:00
Álvaro Felipe Melchor
7fa01a72ed add breakpoints into project file 2016-06-14 23:34:42 +02:00
pancake
2582e5fd0e Fix #5134 - rahash2 -K entropy was randomized by uninitalized values 2016-06-14 20:29:49 +02:00
robbje
a772452d27 Cgs (#5126)
* refactor function listing code

* adhere to style guide

* use tabs instead of spaces

* recover default behaviour for afi commands

* work in commentary and fix the two regression tests I broke

* some more cosmetic changes

* shorten function names
2016-06-14 17:54:17 +02:00
pancake
f5cb1db49b Fix identifying classes#.dex as DEX (not a BIOS) 2016-06-14 17:00:42 +02:00
pancake
6bd3f5199b Fix #4980 - Fix apk:// and implement ipa:// 2016-06-14 14:36:15 +02:00
pancake
e4af7f9b23 Fixes for ELF/Thumb detection handling 2016-06-14 14:36:03 +02:00
pancake
ecef139c99 Fix io.ptrace.write on ARM 2016-06-10 05:27:21 +02:00
pancake
1bb7efd76c Some more COV checks in socket.run 2016-06-14 04:00:30 +02:00
pancake
21a01d08fe Fix warnings in debug.linux.coredump 2016-06-10 04:20:28 +02:00
pancake
e9f14cb4a0 Fix 4b85cff331 util.calc regression 2016-06-14 03:22:43 +02:00
pancake
8d9e4a7836 Fix double close in thread-list and non-null terminated string in debug.linux.core 2016-06-14 03:10:47 +02:00
pancake
7ff42b590f Fix build and bring back java memleak to avoid crash 2016-06-14 02:54:27 +02:00
pancake
69e7b3df28 Fix UAF in bin.psxexe 2016-06-14 02:44:52 +02:00
pancake
59f94c63aa Fix some critical COVs in RBin 2016-06-14 02:42:24 +02:00
pancake
69d62e85c3 Fix deadcode in rbuf 2016-06-14 02:30:22 +02:00
pancake
46433dbf53 Fix some COVs in util/file 2016-06-14 02:22:14 +02:00
pancake
4b85cff331 Fix buffer overflow in r_num_math 2016-06-14 02:19:20 +02:00
pancake
010c2c68ab Fix all COVs in r_io 2016-06-14 02:14:52 +02:00
pancake
702394caf9 Fix string flags realignment in disasm 2016-06-14 01:52:46 +02:00
pancake
f8b5a6602a Boolify anal.xrefs/projects 2016-06-14 01:40:46 +02:00
pancake
56af25e5b5 Update r_core_sysenv_end 2016-06-14 01:33:46 +02:00
pancake
eda7899adc Various enhancements to aae 2016-06-14 01:30:40 +02:00
pancake
ed06c5bcb6 Fix arm64 analysis issue 2016-06-14 00:13:04 +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
c883c0354f Simplify some arm esil expressions 2016-06-13 11:57:21 +02:00
pancake
3861032686 LDR PC is considered UJMP 2016-06-13 11:31:08 +02:00
pancake
8a82e5cae6 Implement 'cbz' in armass-thumb 2016-06-13 11:12:20 +02:00
pancake
3d9bea75ab Fixing some ARM regressions 2016-06-13 10:13:28 +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
Lukas Dresel
8f6c4716e0 Fixed 64bit enum support for structures where size was calculated incorrectly (#5122)
* Implemented 8 byte enumeration format size

Bug found with
po elf64
pf [4]? (elf_shdr)h

Notice how the name of the next section overlaps in address with the previous
section's entsize

* Adjusted coding style
2016-06-12 23:40:58 +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
pancake
3081b3b5d6 Fix ? floating point values 2016-06-12 22:50:20 +02:00
Maijin
f3ee978361 Fix typo Cr -> Cv
@oddcoder
2016-06-11 12:55:09 +02:00
megabug
534cc69a79 Fix trimbits (#5120) 2016-06-11 12:09:39 +02:00
Ahmed Mohamed Abd El-MAwgood
b7c4d1eeb0 enabling Commenting using both index as well as name (#5118) 2016-06-11 11:07:58 +02:00
Jeffrey Crowell
7c3fb53a5e fix disassembling 'backwards'
(e.g. pd -5) producing wrong output

fixes #5105
2016-06-11 10:59:42 +02:00
Ahmed Mohamed Abd El-MAwgood
2d76ac0383 Implementing comments on arguments and vars (#5115) 2016-06-10 18:08:12 +02:00
Sven Steinbauer
deebcc5f46 Add check for 64bit overflow (#5116) 2016-06-10 17:02:51 +02:00
pancake
11fde024c0 Fix asm.emu issue 2016-06-10 16:31:37 +02:00
pancake
d1b5737a59 Add anal.vinfunr 2016-06-10 15:31:38 +02:00
pancake
b25c520428 Do not realign non-code ARM symbols (strings and such) 2016-06-10 12:18:32 +02:00
pancake
3ffffd367f Only show fcn bit mode if different than current one 2016-06-10 10:57:43 +02:00
Jeffrey Crowell
412f81590c note a caveat in r_str_ichr 2016-06-10 03:11:26 +00:00
Jeffrey Crowell
ef59d3aa7f make a note of TODO in str.c 2016-06-10 02:17:31 +00:00
Jeffrey Crowell
3e8a0cc693 replace usage of killed r_str_trim 2016-06-10 01:12:07 +00:00
Jeffrey Crowell
50417301a9 fix description of r_str_word_set0 2016-06-09 23:47:41 +00:00
Jeffrey Crowell
32037244ce kill r_str_trim 2016-06-09 23:43:46 +00:00
Jeffrey Crowell
4cd58acaca comment more string functions, kill some duplicated functions. 2016-06-09 23:43:46 +00:00
HummyPkg
b9aea669d3 Background web server does not honour port parameter 2016-06-09 23:43:42 +02:00
pancake
c65edef137 Always store fcn->bits info on analyze 2016-06-09 23:34:55 +02:00
pancake
91e6b11b11 Add another noreturn function for uclibc 2016-06-09 23:34:52 +02:00
Jeffrey Crowell
ed47ce4fb3 add missing ; in debug_native.c 2016-06-09 21:16:02 +00:00
leberus
6b1a46be23 Add: Generate Coredump - added support for threads and x86 (#5104)
* Add: Generate Coredump - added support for threads and x86

* Fix: debug_native.c allow coredump for i386 too
2016-06-09 22:23:39 +02:00
Joshua J. Drake
a4b21680d8 Re-work r_debug_native_map_get to fix issues (#5108)
* Fixes #4972
* Check more return values
* Improve error reporting
* Minor formatting fixes
2016-06-09 22:12:16 +02:00
pancake
2ca927caea Add anal.vinfun for aav (only grab values outside function boundaries) 2016-06-09 21:52:25 +02:00
Jeffrey Crowell
1b1578e25e fix accidental commit that broke hex2int 2016-06-09 18:40:52 +00:00
Jeffrey Crowell
98d258339a more r_util comments 2016-06-09 18:16:47 +00:00
Jeffrey Crowell
b4c39b5b35 begin adding some documentation to r_str functions
r_util needs some documentation if it is to be unit tested.
2016-06-09 17:42:27 +00:00
Álvaro Felipe Melchor
f018c2e727 Fix #5106 2016-06-09 18:17:51 +02:00
Jeffrey Crowell
4d5630ed30 make r_str_replace_char_once actually do only once 2016-06-09 00:11:59 -04: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
Jeffrey Crowell
a25ef5b3bb remove duplicate char counting functions in r_util 2016-06-08 16:40:44 +00:00
Ahmed Mohamed Abd El-MAwgood
000c602348 FIX #5096 (#5101) 2016-06-08 18:13:36 +02:00
reenz0h
832abcca8c pX command removal (#5099)
pX command is a left off from some old docs. Removing it from help message 'p?'
2016-06-08 12:43:07 +02:00
pancake
dba2fe70f0 Fix w32 build 2016-06-08 11:59:19 +02:00
pancake
10bbfc7d22 Trim strbits by block 2016-06-08 11:51:52 +02:00
pancake
6e68c8de6b Use /m as default webui on all platforms 2016-06-08 09:32:54 +02:00
Jeffrey Crowell
a1bdabf787 fix offbyone in r_str_bits64
manifested in odd numbers having leading 1
2016-06-08 01:48:43 -04:00
Jeffrey Crowell
0e688df308 style fixup for str.c r_util.h 2016-06-08 01:39:07 -04:00
Jeffrey Crowell
f92b37956a fix eval command truncating binary to 8 bits
closes #4975

add new function r_str_bits64 to convert any number to a 64bit binary
value.
2016-06-08 01:31:55 -04:00
pancake
8b78da200e Implement 'ecoj' command to list themes in JSON format 2016-06-07 23:19:42 +02:00
pancake
95af521700 Fix #5087 - properly reload project files 2016-06-07 22:38:29 +02:00
monosource
15f22752b4 Add _R to document pxA (#5095) 2016-06-07 14:00:48 +02:00
Sven Steinbauer
00e964e9b6 Add support to mov for negative immediates (#5090)
mov eax, -3
2016-06-07 12:23:44 +02:00
Sven Steinbauer
6e4a1b55b1 Error if moving 64bit val to 32bit reg (#5088)
mov eax, 0x1122334455667788 now errors if trying to assemble with -b64.
2016-06-07 11:01:35 +02:00
pancake
24aec5be8c Fix all latest COVs 2016-06-07 10:03:04 +02:00
pancake
0845add4cf Implement relocs for ELF-powerpc 2016-06-07 00:12:45 +02:00
pancake
e8b8831b83 Fix elf-ppc endian bit 2016-06-06 23:18:21 +02:00
Álvaro Felipe Melchor
ecb0734988 Fix #5069 2016-06-06 22:58:07 +02:00
pancake
eb9feef231 Fixes for powerpc endian in mach0 and other issues 2016-06-06 22:57:22 +02:00
Álvaro Felipe Melchor
649748a8f2 Fix #5074 2016-06-06 22:40:34 +02:00
pancake
6b3fea1344 Fix #5068 - stack overflow in bin.xbe 2016-06-06 17:42:56 +02:00
pancake
608b79d2b4 Finally fix the build on osx-ppc 2016-06-06 17:30:07 +02:00
pancake
4f51606b6d More osx-ppc build fixes.. 2016-06-06 16:55:15 +02:00
pancake
5903bc0d10 Fix #5083 - null deref in armass 2016-06-06 16:53:56 +02:00
pancake
bd5e22c17e Some more osx-ppc fixes 2016-06-06 16:20:03 +02:00
pancake
c04b32e6aa Fix GCC warning in anal.gb 2016-06-06 16:06:57 +02:00
pancake
b53d065504 Update sdb and cleanup r2pipe-w32 2016-06-06 14:40:58 +02:00
Karol Harasim
c1eb8253c2 Add support for 'pf [size]D' (#5063) 2016-06-06 10:36:09 +02:00
pancake
12d8fbca15 Fix crash in aoe 2016-06-06 10:16:26 +02:00
chinmaydd
68a7fb5ebd Adds initial support for aoe and aor 2016-06-06 09:49:48 +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
oblique
f06e11b6f4 Fix warnings (#5078)
* Fix gcc warnings

* Fix strtoull return
2016-06-06 00:33:11 +02:00
Jack Baker
d3b85151ba Change inline asm constraints to "r" (#5065) (#5073) 2016-06-04 20:32:11 +02:00
oblique
5b13a92c50 behelit theme: Better color for swi (#5080) 2016-06-04 16:51:59 +02:00
pancake
fc058e7501 Honor escapechars in rarun2 setenv 2016-06-04 10:04:14 +02:00
dx
58c5a333c0 Fix a few anal leaks (#5076)
Mostly sdb_get() calls turned into sdb_const_get(), but there are
others.
2016-06-03 15:33:08 +02:00
pancake
2702c3f346 Initial regload support for linux-x32/64 coredumps 2016-06-02 14:16:57 +02:00
Anton Kochkov
24c0dfc961 Do not include coredump.h for non x86 2016-06-02 08:07:12 +03:00
Anton Kochkov
c7f1f7a87b Add missing header for linux coredump 2016-06-02 07:55:31 +03:00
Anton Kochkov
68ef35f635 Uniform name RUndos -> RIOUndos (for bindings) 2016-06-02 07:34:06 +03:00
pancake
d3394d5a7a Fix latest 28 COVs 2016-06-02 03:19:31 +02:00
pancake
03294af32b Fix null deref in libr_asm and add lang-python r2pm pkg 2016-06-02 02:45:38 +02:00
pancake
95b2e511f5 Fix some warnings 2016-06-01 12:23:10 +02:00
Rene Laemmert
2740e74e49 added cursor to undo seek history (#5054)
* added cursor to undo seek history

* cleanup the mentioned parts
2016-06-01 12:16:00 +02:00
Sven Steinbauer
63dd8590d7 Refactor mov assembly for nz (#5057)
* reg offset code consolidated to single location and simplified
* Refactor `getreg` for `arg` and `arg2` to use `r0` and `r1` throughout
        `mov` case

Should clean it up a little.
2016-06-01 12:15:33 +02:00
pancake
7ab3bbb91c Fix some trailing spaces in pf 2016-06-01 12:13:09 +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
d190e0d3c3 Add description for Xtensa instructions 2016-05-31 21:48:18 +02:00
pancake
2bd189255e Remove trailing spaces in px 2016-05-31 21:23:55 +02:00
Karol Harasim
b226545595 Fix use before initialization. (#5052) 2016-05-31 17:17:31 +02:00
pancake
2138ca700c Fix #5019 - registers are now accessible by index 2016-05-31 14:11:09 +02:00
Karol Harasim
cdd4f70814 Add support for pch (2 byte C dump mode) (#5047) 2016-05-31 13:35:31 +02:00
Álvaro Felipe Melchor
fa15260d21 some refactoring in pe format code (#5039) 2016-05-31 12:16:57 +02:00
Karol Harasim
92018cc381 Add ah. command to show hints in current offset. Fix ah? too. (#5045) 2016-05-31 11:50:35 +02:00
oblique
be4b061eda r_str_ansi_crop: Reset color on new line (#5048)
Fixes #5036
2016-05-31 11:50:12 +02:00
pancake
27ae76a7dc Show licenses in rlang plug listing 2016-05-31 10:39:34 +02:00
pancake
176a735927 Add cmdf callback and license in RLang 2016-05-31 02:32:30 +02:00
Álvaro Felipe Melchor
8939958569 Fix #5040
oob read in init_dynamic_section elf format code
2016-05-30 21:51:18 +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
pancake
e458901033 Fix jmptbl regression 2016-05-30 15:30:55 +02:00
pancake
cd776862ef Fix some trailing spaces in pc 2016-05-30 13:19:03 +02:00
Karol Harasim
c34181af02 Disasm refactorings. (#5043) 2016-05-30 12:35:39 +02:00