Hi,
The latest thing I've been breaking is the x86.nasm plugin. On
Ubuntu, "rasm2 nop" was giving the following error:
Error running 'nasm'
Cannot assemble 'nop'
invalid
It turns out that the way nasm and the plugin use here-documents works
with bash, but not with dash (the Ubuntu default) or busybox.
I looked at the alternative method inside #ifdef __APPLE__ , and found
that, with a slight change, it works fine on linux too. So I think it
makes more sense just to use that method for both. (Though neither
worked for Windows with mingw32 - perhaps that should default to
x86.olly?)
Patch attached. The change to libr/include/r_anal.h was necessary to
prevent a compile error when I tested on an old OSX box.
Glyn
diff -r b7a178edb96b libr/asm/p/asm_x86_nasm.c
--- a/libr/asm/p/asm_x86_nasm.c Sat Mar 12 15:04:48 2011 +0100
+++ b/libr/asm/p/asm_x86_nasm.c Sun Mar 13 13:45:38 2011 +0000
@@ -6,11 +6,9 @@
#include <r_asm.h>
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
-#if __APPLE__
char path_r_nasm[] = "/tmp/r_nasm-XXXXXX";
int fd_r_nasm;
char asm_buf[R_ASM_BUFSIZE];
-#endif
char cmd[R_ASM_BUFSIZE];
ut8 *out;
int len = 0;
@@ -18,23 +16,15 @@
eprintf ("asm.x86.nasm does not support non-intel syntax\n");
return -1;
}
-#if __APPLE__
fd_r_nasm = mkstemp (path_r_nasm);
- snprintf (asm_buf, sizeof (asm_buf),
- "BITS %i\nORG 0x%"PFMT64x"\n%s\n__", a->bits, a->pc,
buf);
- write (fd_r_nasm, asm_buf, sizeof (asm_buf));
+ len = snprintf (asm_buf, sizeof (asm_buf),
+ "BITS %i\nORG 0x%"PFMT64x"\n%s\n", a->bits, a->pc, buf);
+ write (fd_r_nasm, asm_buf, len);
close (fd_r_nasm);
snprintf (cmd, sizeof (cmd), "nasm %s -o /dev/stdout 2>/dev/null\n",
path_r_nasm);
-#else
- snprintf (cmd, sizeof (cmd),
- "nasm /dev/stdin -o /dev/stdout 2>/dev/null <<__\n"
- "BITS %i\nORG 0x%"PFMT64x"\n%s\n__", a->bits, a->pc,
buf);
-#endif
out = (ut8 *)r_sys_cmd_str (cmd, "", &len);
-#if __APPLE__
unlink (path_r_nasm);
-#endif
if (out && memcmp (out, "/dev/stdin:", len>11?11:len)) {
memcpy (op->buf, out, len<=R_ASM_BUFSIZE?len:R_ASM_BUFSIZE);
} else {
diff -r b7a178edb96b libr/include/r_anal.h
--- a/libr/include/r_anal.h Sat Mar 12 15:04:48 2011 +0100
+++ b/libr/include/r_anal.h Sun Mar 13 13:45:38 2011 +0000
@@ -331,7 +331,7 @@
R_ANAL_REF_TYPE_CODE = 'c', // code ref
R_ANAL_REF_TYPE_CALL = 'C', // code ref (call)
R_ANAL_REF_TYPE_DATA = 'd' // mem ref
-} RAnalRefType;
+};
typedef struct r_anal_ref_t {
int type;
_______________________________________________
radare mailing list
[email protected]
http://lists.nopcode.org/listinfo.cgi/radare-nopcode.org