From 9fcdcce2a7c3fc6a838cd7cb56ffdcb9a43a3bc5 Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 25 Mar 2010 21:14:28 +0100 Subject: [PATCH] * Some sorting of TODOs * Disable asm.x86.nasm assembly on non-intel syntax * rpathstrip after install (should fix debian issue) --- TODO | 31 ++++++++++++------------------- libr/Makefile | 2 ++ libr/asm/p/asm_x86_nasm.c | 35 ++++++++++++++++++++--------------- libr/debug/TODO | 14 ++++++++++++++ libr/rpathstrip.sh | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 34 deletions(-) create mode 100644 libr/debug/TODO create mode 100755 libr/rpathstrip.sh diff --git a/TODO b/TODO index f6c0b9e272..c9560e69db 100644 --- a/TODO +++ b/TODO @@ -7,8 +7,7 @@ <{include libr/TODO}> -* Breakpoints are ignored in some situations.. we must check - for them and toggle a .dbg variable to break +See libr/*/TODO FMI BUGS ==== @@ -16,36 +15,30 @@ BUGS * console grep * x@esp&&x@eip # BUG +* diff code analysis + - diff two programs + 1st level: + - check all functions EQUAL, DIFFERENT, REMOVED, ADDED + - check all symbols + - check all imports + - check all strings + 2nd level: + - basic block level diffing (output in graph mode) + * stack analysis * code analysis with r_parse -* Write manpages - -* ALL threads must be stopped when a breakpoint is handled.. - -- how to do this? +* Finish to write manpages * Move 'r_syscall_t' stuff into r_debug - Sync r_core -* regio not implemented - - floating point registers - - mmx/xmm - - drX control -* FileDescriptors - - df -- copy from !fd in r1 - -* Implement dump+restore as macros - (dump,) - * Implement process launcher wrapper - opens xterm and redirects stdin/stdout/stderr - Allows to change chroot - Allows to setup chroot - Define uid/gid -* BUG: - rasm2 -s att -a x86.nasm 'push 0x1e(%esp)' - * Added lib_handle stub in r_lib, so we can add plugin support to any library by using just a macro diff --git a/libr/Makefile b/libr/Makefile index 0a4e109999..c4e1bc6dc0 100644 --- a/libr/Makefile +++ b/libr/Makefile @@ -103,6 +103,8 @@ install: install-includes install-pkgconfig install-bins install-test-bins ${INSTALL_DATA} $$a ${PFX}/lib/radare2 ; done ${INSTALL_DATA} lang/p/radare.* ${PFX}/lib/radare2 echo "lang/p/radare.* ${PFX}/lib/radare2" + # strip rpath from ALL bins + ./rpathstrip.sh ${PFX} deinstall uninstall: # libraries diff --git a/libr/asm/p/asm_x86_nasm.c b/libr/asm/p/asm_x86_nasm.c index 1c5671b7fe..17cef3ec6f 100644 --- a/libr/asm/p/asm_x86_nasm.c +++ b/libr/asm/p/asm_x86_nasm.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2009 pancake */ +/* radare - LGPL - Copyright 2009-2010 pancake */ #include #include @@ -8,20 +8,25 @@ #include "fastcall_x86.h" #if 0 -static int disassemble(struct r_asm_t *a, struct r_asm_aop_t *aop, ut8 *buf, ut64 len) -{ +static int disassemble(struct r_asm_t *a, struct r_asm_aop_t *aop, ut8 *buf, ut64 len) { } #endif -static int assemble(struct r_asm_t *a, struct r_asm_aop_t *aop, const char *buf) { - int len = 0; +static int assemble(RAsm *a, RAsmAop *aop, const char *buf) { char cmd[R_ASM_BUFSIZE]; ut8 *out; - sprintf(cmd, "nasm /dev/stdin -o /dev/stdout <<__\nBITS %i\nORG 0x%llx\n%s\n__", a->bits, a->pc, buf); - out = (ut8 *)r_sys_cmd_str(cmd, "", &len); + int len = 0; + if (a->syntax != R_ASM_SYNTAX_INTEL) { + eprintf ("asm.x86.nasm does not support non-intel syntax\n"); + return -1; + } + snprintf (cmd, sizeof (cmd), + "nasm /dev/stdin -o /dev/stdout <<__\n" + "BITS %i\nORG 0x%llx\n%s\n__", a->bits, a->pc, buf); + out = (ut8 *)r_sys_cmd_str (cmd, "", &len); if (out) { - memcpy(aop->buf, out, len<=R_ASM_BUFSIZE?len:R_ASM_BUFSIZE); - free(out); + memcpy (aop->buf, out, len<=R_ASM_BUFSIZE?len:R_ASM_BUFSIZE); + free (out); } aop->inst_len = len; return len; @@ -36,7 +41,7 @@ struct r_asm_handle_t r_asm_plugin_x86_nasm = { .fini = NULL, .disassemble = NULL, /*&disassemble,*/ .assemble = &assemble, - .fastcall = fastcall, + .fastcall = &fastcall, }; #ifndef CORELIB @@ -50,11 +55,11 @@ struct r_lib_struct_t radare_plugin = { main() { struct r_asm_fastcall_t *f; //f = r_asm_plugin_x86_nasm.fastcall; - printf("fastcall=%p\n", *r_asm_plugin_x86_nasm.fastcall); - printf("fastcall=%p\n", fastcall); + printf ("fastcall=%p\n", *r_asm_plugin_x86_nasm.fastcall); + printf ("fastcall=%p\n", fastcall); f = fastcall;//r_asm_plugin_x86_nasm.fastcall; - printf("f=%p (%s)\n", f, f); - printf("f[0]=%p (%s)\n", f[0], f[0]); - printf("f[3].arg[1]=%s\n", f[3].arg[1]); + printf ("f=%p (%s)\n", f, f); + printf ("f[0]=%p (%s)\n", f[0], f[0]); + printf ("f[3].arg[1]=%s\n", f[3].arg[1]); } #endif diff --git a/libr/debug/TODO b/libr/debug/TODO new file mode 100644 index 0000000000..260575d0e7 --- /dev/null +++ b/libr/debug/TODO @@ -0,0 +1,14 @@ +Debugger TODO +============= +* Breakpoints are ignored in some situations.. we must check + for them and toggle a .dbg variable to break +* ALL threads must be stopped when a breakpoint is handled.. + -- how to do this? +* regio not implemented + - floating point registers + - mmx/xmm + - drX control +* FileDescriptors + - df -- copy from !fd in r1 +* Implement dump+restore as macros + (dump,) diff --git a/libr/rpathstrip.sh b/libr/rpathstrip.sh new file mode 100755 index 0000000000..9026ad2ef1 --- /dev/null +++ b/libr/rpathstrip.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# UGLY HACK to remove all rpaths and make r2 work without +# installation.. rpath should be removed at some point.. + +BIN=bin/t/rpathdel +BINS="rasm2 radare2 rabin2 radiff2 rahash2 rax2 rafind2 rasign2" + +if [ -z "$1" ]; then + echo "Usage: ./rpathstrip.sh /usr" + exit 0 +fi + +if [ ! -x "${BIN}" ]; then + echo "Not stripping rpaths" + exit 0 +fi +echo "Stripping rpath from installed binaries..." + +for a in ${BINS}; do + ${BIN} $1/bin/$a $1/bin/$a +done + +for a in ${LIBS}; do + ${BIN} $1/lib/$a $1/lib/$a +done + +for a in `cd $1/lib/radare2 ; ls`; do + ${BIN} $1/lib/radare2/$a $1/lib/radare2/$a +done + +for a in `cd $1/lib/radare2/test ; ls`; do + ${BIN} $1/lib/radare2/test/$a $1/lib/radare2/test/$a +done + +exit 0