Commit Graph

2168 Commits

Author SHA1 Message Date
Khairul Azhar Kasmiran
d9057505dc
Set RPATH/RUNPATH on r2 libs too if local (#17639) 2020-09-15 09:16:14 +02:00
Riccardo Schirone
3e3efcc005 Test compilation with various capstone versions ##build
Do not use #include <capstone/..>

This ensures compatibility with both capstone v3 and capstone as
installed on most distributions, where the pkg-config file of capstone
already adds -I/usr/include/capstone (with that dir directly containing
the headers).
2020-09-09 15:39:33 +02:00
pancake
410db8175b
x86.as is only suposed to work on x86, add env var for custom use ##asm (#17610)
Co-authored-by: pancake <pancake@nopcode.org>
Co-authored-by: Riccardo Schirone <ret2libc@users.noreply.github.com>
2020-09-09 16:41:28 +08:00
pancake
74c4a36656
Fix 'call start' register confusion warning ##asm (#17573)
Co-authored-by: pancake <pancake@nopcode.org>
2020-09-03 14:45:09 +08:00
Aswin C
f656ccc0ea
Added instruction descriptions for RISC-V ##asm (#17526) 2020-08-27 12:12:52 +08:00
b7f4c7545e
Append missing loongson 2e/2f entries in mips-dis.c and mybfd.h (#17400) 2020-08-14 13:18:05 +08:00
Dennis Goodlett
18c052c266
Fix #17414 heap overflow hackyArmAnal (#17425)
* Fix #17414 heap overflow hackyArmAnal

Co-authored-by: Dennis Goodlett <dennis@hurricanelabs.com>
2020-08-10 10:23:09 +02:00
Anton Kochkov
a94718304c
Do not use 0b... integer constants (#17421)
The form of 0b01101 appeared only in GCC 4.3.
It wasn't defined in the C standard and was only
an extension.
2020-08-08 18:10:11 +08:00
phakeobj
4c207712bd
Add hack for ARMv8 BTI instruction disassembly ##anal (#17371)
Co-authored-by: phakeobj <phakeobj@users.noreply.github.com>
2020-07-31 18:08:59 +08:00
phakeobj
1dbe43d83d
Fix #17135 - Support Memory Tagging Extension instructions ##anal (#17279)
Co-authored-by: phakeobj <phakeobj@users.noreply.github.com>
2020-07-23 16:15:12 +08:00
pancake
d441baad62
Fix latest COVs, remove dead code and unnecessary global variables (#17231)
Co-authored-by: pancake <pancake@nopcode.org>
2020-07-22 19:37:31 +08:00
Riccardo Schirone
2d160f2509
Avoid sdb double headers (#17249) ##build
* Avoid duplication of SDB headers in libr/include

SDB is an external project and as such it should live in shlr. However,
for simplicity in dealing with the include flags, the SDB headers were
copied in libr/include as well. This patch just keeps the SDB files
confined in shlr/sdb and make sure various r_* libs use the headers from
there.

* Fix pkgconfig file generation
2020-07-21 10:28:43 +02:00
Riccardo Schirone
a933ba8beb
Check length before disassembling cr16 instructions ##asm (#17290) 2020-07-16 20:48:20 +08:00
Riccardo Schirone
594b940b7c
Fixes some of the issues in Travis (#17267)
* Do not check with r_return_ if the convention is present

Let's just assume the NULL default in such a case, so that architectures
for which we don't have a defined calling convention can still be
processed somehow by the analysis code. It won't be precise, but it's
better than nothing.

Also add a warning message so users are aware when the calling
convention is not defined.

* Fix oob-read when # is at the end of the cmd string

* Do not set TMPDIR when the new value is the empty string

When TMPDIR is set to empty value, clang+ld behaves in weird ways and
you cannot compile files from within the r2 shell (e.g. when using #!c
or #!cpipe)

* Use meson and add -lasan to pkgconfig files when sanitizer are used
2020-07-16 20:47:30 +08:00
karliss
35e824bc55
Fix OOB access in z80 disasm for "OP [ixy+nn]" instructions. (#17268) 2020-07-14 11:58:16 +03:00
pancake
f061b49c14
Fix all the covs (memleaks) reported the 15th of this month (#17163) 2020-06-29 09:40:35 +02:00
Sylvain Pelissier
521db221f4
Improve analysis of compressed instructions and update instruction format (#17115) 2020-06-22 10:12:50 +02:00
Jerome-PS
aeca50166d
Adding support for BA2 ELF binaries ##bin (#17063)
* Adding support for BA2 CPU

* Code clean up

* Moving support for BA2 CPU to radare2-extras

Co-authored-by: Jerome-PS <Jerome-PS>
2020-06-16 10:10:01 +02:00
pancake
bd9a604a87
Check for return values in about ~50 method calls (#17025) 2020-06-15 11:24:43 +02:00
pancake
cea53c7112
Fix ~300 warnings in the pyc disasembler (#17071)
Co-authored-by: pancake <pancake@nopcode.org>
2020-06-15 17:16:04 +08:00
Aswin
b24f4f02d0
Update arm.sdb.txt: Added instruction descriptions for ARM (#17070) 2020-06-14 21:11:40 +02:00
pancake
160fc95e66
Use (void) instead of () in function signatures (#17026) ##refactoring
* Use (void) instead of () in function signatures
* Add test to avoid further contributions to commit the same mistake
2020-06-14 16:08:32 +02:00
pancake
84ecf9fff2
Fix all the coverities detected last month (#17060)
* Fix all the coverities detected last month

* Fix one more cov

* Fix build

* refix build

Co-authored-by: pancake <pancake@nopcode.org>
2020-06-14 13:21:57 +02:00
Riccardo Schirone
70e3d3bc56
Fix compiler warnings (#17046) 2020-06-12 10:26:55 +02:00
Anton Kochkov
ffe743ef39
Fix #4056 - rename DEPS to R2DEPS ##build (#17020)
* Rename DEPS to R2DEPS
* Cleanup of sys/build.sh
2020-06-12 10:49:28 +08:00
pancake
9978bbd7c5
Implement assembler endbr32 and endbr64 instructions for x86-32/64 (#17035) ##asm
Co-authored-by: pancake <pancake@nopcode.org>
2020-06-10 19:15:46 +08:00
condret
ae883f0cd3 Cleaning up again 2020-06-10 02:24:03 +02:00
condret
6fe90763f5 Some cleanup 2020-06-10 02:24:03 +02:00
condret
c5a2a6562e fix #16995, #16994 and some other stuff 2020-06-10 02:24:03 +02:00
Giovanni
d2e6b41e53
Fix pre c99 loop issue and useless negative check (#16957)
Co-authored-by: Giovanni Dante Grazioli <giovanni.dantegrazioli@nbs-system.com>
2020-05-27 12:44:21 +02:00
Sean Maher
bb2d205ff2
Implement Wasm SIMD instruction disassembly (#16928) 2020-05-22 13:58:56 +02:00
FXTi
07dd91c973
FIX (#16839) 2020-05-17 14:23:35 +02:00
FXTi
8de388dc52
Fix Pyc issues from Infer and Coverity (#16828)
* Fix issues from infer and coverity
* Fix memory leaking by human eyes
2020-05-16 12:00:11 +08:00
FXTi
1ffdedcd07
Add Python bytecode plugins (#16771) 2020-05-13 10:37:09 +08:00
atodekangae
b18529696c Fix assembling of xchg so that it roundtrips 2020-04-29 00:13:25 +02:00
atodekangae
60fbd0b83a Fix assembling of xchg and the tests for it 2020-04-29 00:13:25 +02:00
atodekangae
e40e51d2ce Fix assembling of bswap r8(d)-r15(d) 2020-04-29 00:13:25 +02:00
Liumeo
7ffb7cf77a
Do not redefine assert in dis.c (#16694) 2020-04-28 19:35:29 +02:00
atodekangae
f1e113ca8f
Fix assembling of pop r8-r15 (#16710) 2020-04-24 18:40:09 +02:00
Anton Kochkov
38e6e39317
Move inferior GNU Hexagon plugin to extras (#16661) ##asm 2020-04-24 11:38:30 +02:00
Khairul Azhar Kasmiran
123aa79117
x86_64: Support mov r64, 0xffffffffffffffff (#16630) ##asm 2020-04-23 19:30:35 +02:00
pancake
a3407a535b
Cleanups for RAsm, rasm2 related to brainfuck hacks 2020-04-20 16:02:08 +02:00
Khairul Azhar Kasmiran
4afa4296ea
x86_32/64: Don't assemble overlarge MOV imm32 (#16619) 2020-04-17 22:36:58 +08:00
Liumeo
b5d5e00f66
Fix LGTM alert - remove strlen (#16615) 2020-04-17 08:49:45 +08:00
Liumeo
2570a7b001
Add header guard (#16605) 2020-04-16 18:41:31 +02:00
Khairul Azhar Kasmiran
538563149b
x86_64: Fix MOV r32, -imm32 encoding (#16609) ##asm 2020-04-16 16:30:32 +02:00
Khairul Azhar Kasmiran
a275bad0db
x86_64: Fix REX.B for MOV r64-extended, imm32/64 (#16602) 2020-04-16 13:23:02 +08:00
Liumeo
b9786ac7e3
Add header guards in the include files (#16595) 2020-04-15 12:20:02 +08:00
Khairul Kasmiran
7b4bee8cff x86_64: Add some tests and remove some unused MOV C7 code 2020-04-14 23:48:47 +02:00
Khairul Azhar Kasmiran
a43831ba96 Fix #16433 - Use MOV opcode B8+ for MOV r64, <0x80000000 to 0xffffffff> #16572 ##asm
Detailed description

I've confirmed #16433 (comment) (including the nasm rax -> eax bug) and thus this pr
makes the x86_64 assembler use the MOV B8+ encoding (MOV r64, imm64) when the immediate
is between 0x80000000 and 0xffffffff for both:

Consistency with GNU assembler.  It actually does seem to be the expected encoding.
This does mean that mov eax, 0xffffffff and mov rax, 0xffffffff will have very different semantics.
2020-04-13 21:23:39 +02:00
Disconnect3d
09cc1b670a
Fix off by one errors in asm_bf (#16570)
The `strncmp` calls with `"in"` and `"out"` string literals seems to have wrong size argument passed. This PR fixes it.
2020-04-13 19:53:22 +02:00
Khairul Azhar Kasmiran
c4a093d45e
x86_64: Use MOV opcode C7 for MOV r64, -<1 to 0x80000000> (#16551) ##asm 2020-04-12 22:47:12 +02:00
curly
f9d78db7e2
Tricore basic analysis plugin with reg profile (#16522) ##arch 2020-04-12 22:42:58 +02:00
Alexis Ehret
ef07476e38
Fix various lgtm warning (#16497)
* Wrong type of arguments to formatting function root/shlr/mpc/mpc.c
* Overflow in uncontrolled allocation size ./libr/socket/run.c
* Multiplication result converted to larger type ./libr/core/cmd_print.c
* Multiplication result converted to larger type ./libr/bin/p/bin_dyldcache.c
* Multiplication result converted to larger type ./libr/core/linux_heap_glibc.c
* Multiplication result converted to larger type ./libr/core/visual.c
* Comparison of narrow type with wide type in loop condition ./libr/core/p/core_java.c
* Fix various warning -Wall ./libr/core/p/core_java.c
* Multiplication result converted to larger type ./libr/bin/format/mach0/mach0.c
* Multiplication result converted to larger type ./libr/util/print.c
* Multiplication result converted to larger type ./libr/asm/asm.c
* Fix small warning python
* Fix type error and declaration inside loop
* Reset mpc
* replace size_t
* Fix space missing, type and format
2020-04-12 20:45:24 +02:00
Khairul Azhar Kasmiran
9227c6790f
Fix #16433 - Support movabs for x86_64's MOV r64, imm64 (#16527) 2020-04-11 23:34:44 +08:00
pancake
067bf11e98
Fix #16109 - Add R_SYS_ARCH for s390x ##ports (#16471) 2020-04-10 08:09:41 +02:00
radare
3f77b9a76b
Avoid duplicated module filenames to fix static.sh ##build (#16403) 2020-04-02 14:30:27 +02:00
radare
bc38b17a62
Remove r_str_rmch and simplify r_str_replace_char* ##util (#16258) 2020-03-19 17:54:28 +01:00
Tigre000
4c684f1971
Fix arm64 branch assemble (#16205) ##asm 2020-03-19 00:21:48 +01:00
Florian Märkl
0b5e78e923
Make size arg of r_file_slurp() size_t (#16221) 2020-03-15 23:34:38 +01:00
Khairul Azhar Kasmiran
2c8d5982cd
Convert preinc/predec in 3rd part of for statement to postinc/postdec (#16187) 2020-03-12 18:40:46 +01:00
Rishi Bhatt
f2aaa72fa2
Support asm.cpu for Tricore architecture (#16161) ##asm 2020-03-10 14:10:57 +01:00
radare
72093ac706
Fix #16138 - Do not preincrement when it's not necessary (#16151) 2020-03-05 19:06:59 +01:00
radare
e37a2e1b9c
Fix UAF in om= (#16149) 2020-03-05 18:07:03 +01:00
Khairul Kasmiran
78e21373be Revert "ONE_STREAM_HACK & scr.onestream: Force expected ONE_STREAM order if necessary (#15535)"
This reverts commit 39b40cdedd.
2020-02-17 00:00:46 +01:00
Khairulmizam Samsudin
0de6f6481d Add asm x86 neg 2020-02-10 08:09:17 +01:00
Manuel Prinz
273133da7d
Determine Gameboy hardware registers in disassembly (#15909) ##asm
* Return address for unknown Gameboy hardware registers
2020-02-07 09:41:30 +01:00
Hye Sung Jung
757c23d5db Fix spelling errors (#15904) 2020-01-27 07:43:47 +01:00
Khairulmizam Samsudin
8f752d435e Arm64 assembler mov immediate word fix (#15884) ##asm 2020-01-23 11:41:44 -05:00
Khairulmizam Samsudin
d937bebf67 Add cbnz and cbz instruction for arm64 assembler (#15871)
* Add cbz and cbnz instructions
* Added cbnz and cbz test case
2020-01-21 14:59:41 -05:00
radare
551a0986d6
'push rip' is not a valid instruction ##asm (#15804) 2020-01-14 14:36:45 +01:00
Florian Märkl
de59bada55 Fix warnings in or1k_disas.c 2019-12-16 00:30:45 +01:00
GustavoLCR
07b5e062f2 Fix #15545 - Fix NULL derefs after r_file_slurp() fails 2019-12-15 23:38:38 +01:00
Paul I
9a4578a915 Replace some strstr() calls with strchr() 2019-12-15 23:37:27 +01:00
Anton Kochkov
e11b2a9145
Some Coverity defect fixes (#15626) 2019-12-13 11:25:19 -06:00
Francesco Tamagni
9fd379faff Rename or1k insns global (#15613)
As in certain build configurations it conflicts with the Capstone’s symbol of the same name, raising errors in the linking phase.
2019-12-11 18:56:14 +01:00
Khairul Azhar Kasmiran
a82297adc1 Fix signed integer overflow in r_asm_massemble (#15551) 2019-12-08 08:08:29 +01:00
Florian Märkl
021ad4d59b Fix an int Overflow in r_asm_massemble() for #15543 2019-12-06 19:32:29 +01:00
pancake
204b7317be Blindfix for #15543 - aka CVE-2019-19590 2019-12-05 17:43:57 +01:00
Khairul Azhar Kasmiran
39b40cdedd
ONE_STREAM_HACK & scr.onestream: Force expected ONE_STREAM order if necessary (#15535) 2019-12-02 23:09:38 +08:00
GustavoLCR
ebaf8b603e Fix some warnings on Windows (#15532) 2019-11-30 00:49:16 +01:00
Kamil Lorenc
e13281829c Add support for or1k (OpenRISC) disasm+analysis (#15515) ##arch 2019-11-29 11:35:16 +01:00
Florian Märkl
521ac7c28f Fix a Double Free in tms320/c55x+ (#15505) 2019-11-26 16:30:56 +01:00
MartinJM
6bc9e58311 Fix for #15459 - Also set the first operant to the right value on a mov from pointer with offset ##asm 2019-11-14 22:57:52 +01:00
F3real
032a1eb0c0 Fix x86 lahf instruction 2019-11-14 22:56:07 +01:00
condret
31d6b5764a Fill op->mnemonic in anal-gb 2019-11-03 07:23:27 +01:00
Riccardo Schirone
05df48a96c r_8051_disas should not be exported (#15347) 2019-10-24 13:14:05 +02:00
Florian Märkl
aad2a2c79e Link sdb fully into r_util in meson (#15338) ##build 2019-10-23 15:52:19 +02:00
pancake
76bc3b0282 Fix macOS build 2019-10-23 12:15:21 +02:00
hmht
3a0a477867 Update 8051 plugin (#15321) ##anal
* handle 8051 ANAL_OP DISASM

The 8051 assembler has been R_APId, #included in the local scope, and
called to fill op->mnemonic, which stops a bunch of warnings from
appearing whenever a bunch of disassembly appears on the screen.

The disassembler is called because of comments in r_anal.h: op->mnemonic
should contain the entire disassembly, not just the mnemonic.
Here's hoping the mnemonics and arguments will get split eventually.

* typdef some RAnal enums

In trying to make my analysis push out more info, it's difficult to
understand what all these ints mean, while ACTUALLY they should be
filled with enum values. By using the enum names, that's made clear
immediately.

r2's style is typedef over `enum name`, so that's what I did.

the typedef-instead-of-int I added here isn't consistently propagated,
and has caused warnings about unhandled cases-in-switch, at least some
of which should just get a default: case added, but I'd rather leave it
to the domain experts, or my future self when I become that domain
expert.

* refactor 8051 optype switch into table

it's pretty much static data with very meagre duplication, putting it in
a switch-case is unwieldy.

* add cycle info to 8051 opcode analysis

* add more basic 8051 anal info

op->cond, eob, nopcode, family, id

they seem mostly useless, but it's not much work to add, so...

* use ANAL_OP_MASK_VAL

* fixup! handle 8051 ANAL_OP DISASM

* fixup! use ANAL_OP_MASK_VAL

* Revert "use ANAL_OP_MASK_VAL"

:)

Clearly I was using MASK_VAL incorrectly, the only hint to its use was:

> // It fills RAnalop->dst/src info

so even though it's named "VAL", it might not actually need
to fill RAnalop->val...

Nor ptr, and definitely not jump and fail, which means we don't have use
for it yet! Not until I actually implement ->dst/src
2019-10-22 23:07:29 +02:00
Fritz Reese
f4b0ec9623 Fix #15302 [rasm2/armass] Correctly propagate errors from thumb_assemble (#15303) ##asm 2019-10-19 01:48:14 +02:00
hmht
48ca0e7ace Add additional [indirect] access syntax for 8051 (#15272) ##asm
8051 natively uses an '@' prefix for indirect access, which is
a bit awkward is r2, so it should also support the bracket syntax:

xrl a, @r0
xrl a, [r0]

Additionally, I refactored the argument tokenization so that it's all done
up-front, making everything easier to work with, saving about 800 LOC.
2019-10-14 12:45:26 +02:00
condret
77e73c16f7 add 8bit register dereferencing for 2 operand instructions in mcs96 disassembler 2019-10-13 20:28:17 +02:00
Khairul Kasmiran
b5506916ed Fix #define alignment 2019-10-12 19:38:57 +08:00
condret
152ab3e94d fix mcs96 instruction length 2019-10-12 11:44:36 +02:00
GustavoLCR
9ed199d64e
Fix OOB read in 8051 assembler 2019-10-11 15:22:52 -03:00
GustavoLCR
42938ada9f
Fix heap-buffer-overflow in 8051 assembler 2019-10-11 14:37:53 -03:00
radare
681fbb0431
Some small cleanup/deprecations on asm/anal (#15248) 2019-10-11 14:25:44 +02:00
hmht
9db9050454 Fix 8051 dptr read (#15247) 2019-10-11 10:46:28 +02:00
radare
3dd2525a2f
Fix #15235 - push [mem] not handled in /r ##anal 2019-10-10 16:15:01 +02:00