diff --git a/libr/asm/asm.c b/libr/asm/asm.c index 54552ee90a..176facdf7c 100644 --- a/libr/asm/asm.c +++ b/libr/asm/asm.c @@ -380,7 +380,8 @@ R_API RAsmCode* r_asm_mdisassemble(RAsm *a, const ut8 *buf, int len) { ret = r_asm_disassemble (a, &op, buf+idx, len-idx); if (ret<1) { eprintf ("disassemble error at offset %"PFMT64d"\n", idx); - return acode; +ret = 1; +// return acode; } if (a->ofilter) r_parse_parse (a->ofilter, op.buf_asm, op.buf_asm); diff --git a/libr/bin/format/elf/elf.c b/libr/bin/format/elf/elf.c index a7225ab421..9d856dd139 100644 --- a/libr/bin/format/elf/elf.c +++ b/libr/bin/format/elf/elf.c @@ -1038,6 +1038,15 @@ struct r_bin_elf_symbol_t* Elf_(r_bin_elf_get_symbols)(struct Elf_(r_bin_elf_obj Elf_(Shdr) *strtab_section; Elf_(Sym) *sym; char *strtab; + Elf_(Shdr)* section_text = NULL; + ut64 section_text_offset = 0LL; + + if (bin->ehdr.e_type== ET_REL) { + section_text = Elf_(r_bin_elf_get_section_by_name)(bin, ".text"); + if (section_text) { + section_text_offset = section_text->sh_offset; + } + } if (!bin || !bin->shdr || bin->ehdr.e_shnum == 0 || bin->ehdr.e_shnum == 0xffff) return NULL; @@ -1049,6 +1058,7 @@ struct r_bin_elf_symbol_t* Elf_(r_bin_elf_get_symbols)(struct Elf_(r_bin_elf_obj data_offset = 0; } shdr_size = bin->ehdr.e_shnum * sizeof (Elf_(Shdr)); + for (i = 0; i < bin->ehdr.e_shnum; i++) { #define BUGGY 0 #if BUGGY @@ -1136,6 +1146,8 @@ if ( } #endif ret[ret_ctr].offset = (toffset >= bin->baddr ? toffset -= bin->baddr : toffset); + if (section_text) + ret[ret_ctr].offset += section_text_offset; ret[ret_ctr].size = tsize; if (sym[k].st_name > strtab_section->sh_size) { eprintf ("Warning: index out of strtab range\n"); diff --git a/libr/core/bin.c b/libr/core/bin.c index ca5c7d2aef..656ccf0230 100644 --- a/libr/core/bin.c +++ b/libr/core/bin.c @@ -492,7 +492,6 @@ static int bin_pdb (RCore *core, int mode) { static int bin_main (RCore *r, int mode, ut64 baddr, int va) { RBinAddr *binmain = r_bin_get_sym (r->bin, R_BIN_SYM_MAIN); if (!binmain) return R_FALSE; - baddr = 0LL; // This is broken, just to make t.formats/elf/main happy if ((mode & R_CORE_BIN_SIMPLE) || mode & R_CORE_BIN_JSON) { r_cons_printf ("%"PFMT64d, va? (baddr+binmain->vaddr):binmain->paddr); diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index 2a6f9292a7..cc02b140ae 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -1177,9 +1177,9 @@ static int cmd_print(void *data, const char *input) { r_core_block_size (core, obsz); break; case 'a': //pa - if (input[1]=='e') { + if (input[1]=='e') { // "pae" if (input[2]=='?') { - r_cons_printf("|Usage: pae [hex] assemble esil from hexpairs\n"); + r_cons_printf ("|Usage: pae [hex] assemble esil from hexpairs\n"); } else { int ret, bufsz; RAnalOp aop = {0}; @@ -1194,9 +1194,9 @@ static int cmd_print(void *data, const char *input) { } r_anal_op_fini (&aop); } - } else if (input[1]=='d') { + } else if (input[1]=='d') { // "pad" if (input[2]=='?') { - r_cons_printf("|Usage: pad [asm] disasm\n"); + r_cons_printf ("|Usage: pad [asm] disasm\n"); } else { RAsmCode *c; r_asm_set_pc (core->assembler, core->offset); diff --git a/libr/include/r_bin.h b/libr/include/r_bin.h index b794c8edfe..82a0be970b 100644 --- a/libr/include/r_bin.h +++ b/libr/include/r_bin.h @@ -134,7 +134,6 @@ typedef struct r_bin_object_t { } RBinObject; // XXX: this is a copy of RBinObject -// TODO: rename RBinFile to RBinFile typedef struct r_bin_file_t { char *file; int fd; diff --git a/libr/io/p/io_ptrace.c b/libr/io/p/io_ptrace.c index d810a70333..66246994e1 100644 --- a/libr/io/p/io_ptrace.c +++ b/libr/io/p/io_ptrace.c @@ -190,7 +190,7 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) { open_pidmem (riop); pidpath = r_sys_pid_to_path (pid); // sleep 1s to get proper path (racy) - r_sys_sleep (1); + //r_sys_sleep (1); desc = r_io_desc_new (&r_io_plugin_ptrace, pid, pidpath, rw | R_IO_EXEC, mode, riop); free (pidpath); diff --git a/libr/util/hex.c b/libr/util/hex.c index 0cd0cb3e20..d64859651c 100644 --- a/libr/util/hex.c +++ b/libr/util/hex.c @@ -112,11 +112,16 @@ R_API int r_hex_str2bin(const char *in, ut8 *out) { int len = 0, j = 0; const char *ptr; ut8 c = 0, d = 0; + int outbuf = 0; if (!in || !*in) return 0; if (!memcmp (in, "0x", 2)) in += 2; + if (!out) { + outbuf = 1; + out = malloc (strlen (in)); + } for (ptr = in; ; ptr++) { /* comments */ if (*ptr=='#') { @@ -176,16 +181,20 @@ R_API int r_hex_str2bin(const char *in, ut8 *out) { } if (r_hex_to_byte (&c, ptr[0])) { //eprintf("binstr: Invalid hexa string at %d ('0x%02x') (%s).\n", (int)(ptr-in), ptr[0], in); - return len; + goto beach; } c |= d; if (j++ == 0) c <<= 4; } // has nibbles. requires a mask +beach: if (j) { out[len] = c; len = -len; } + if (outbuf) { + free (out); + } return (int)len; }