mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-02 18:27:18 +00:00
Merge
This commit is contained in:
commit
f62871b98c
1
TODO
1
TODO
@ -5,6 +5,7 @@
|
||||
|
||||
To wipe:
|
||||
========
|
||||
* check iowrite
|
||||
- Move the content of libr/*/TODO here
|
||||
- linestyle?? for disassembly lines
|
||||
- remove libr/vm and libr/db
|
||||
|
@ -5,6 +5,8 @@ STATIC_OBJ+=${OBJ_X86_SIMPLE}
|
||||
TARGET_X86_SIMPLE=anal_x86_simple.${EXT_SO}
|
||||
|
||||
ALL_TARGETS+=${TARGET_X86_SIMPLE}
|
||||
LIBS_X86_SIMPLE=r_anal r_reg r_lib r_syscall r_diff
|
||||
MYLIBS=$(subst r_,-L../../,$(LIBS_X86_SIMPLE))
|
||||
|
||||
${TARGET_X86_SIMPLE}: ${OBJ_X86_SIMPLE}
|
||||
${CC} -L../../reg -lr_reg -L.. -lr_anal ${LDFLAGS} ${CFLAGS} -o anal_x86_simple.${EXT_SO} ${OBJ_X86_SIMPLE}
|
||||
${CC} ${MYLIBS} ${LDFLAGS} ${CFLAGS} -o anal_x86_simple.${EXT_SO} ${OBJ_X86_SIMPLE}
|
||||
|
@ -17,6 +17,7 @@ static struct state _state;
|
||||
#include <r_types.h>
|
||||
|
||||
static inline struct state *get_state(void) {
|
||||
memcpy (&_state, sizeof (struct state), 0);
|
||||
return &_state;
|
||||
}
|
||||
|
||||
@ -438,18 +439,16 @@ static int decode_known(struct state *s, struct directive *d) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void csr_decode(struct state *s, struct directive *d)
|
||||
{
|
||||
static void csr_decode(struct state *s, struct directive *d) {
|
||||
int prefix = s->s_prefix;
|
||||
if (!decode_fixed(s, d))
|
||||
if (!decode_known(s, d))
|
||||
decode_unknown(s, d);
|
||||
if (!decode_fixed (s, d))
|
||||
if (!decode_known (s, d))
|
||||
decode_unknown (s, d);
|
||||
if (s->s_prefix == prefix)
|
||||
s->s_prefix_val = s->s_prefix = 0;
|
||||
}
|
||||
|
||||
static int read_bin(struct state *s, struct directive *d)
|
||||
{
|
||||
static int read_bin(struct state *s, struct directive *d) {
|
||||
memcpy(&d->d_inst, s->s_buf, sizeof(d->d_inst));
|
||||
d->d_off = s->s_off++;
|
||||
return 1;
|
||||
@ -565,8 +564,7 @@ static void own(struct state *s)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int arch_csr_disasm(char *str, unsigned char *buf, ut64 seek)
|
||||
{
|
||||
static int arch_csr_disasm(char *str, unsigned char *buf, ut64 seek) {
|
||||
struct state *s = get_state();
|
||||
struct directive *d;
|
||||
memset(s, 0, sizeof(*s));
|
||||
|
@ -221,7 +221,7 @@ static void Memadr(int defseg,const char *descr,slong offset,int dsize) {
|
||||
// Disassemble memory/register from the ModRM/SIB bytes and, if available, dump
|
||||
// address and contents of memory.
|
||||
static void DecodeMR(int type) {
|
||||
int j,memonly,inmemory,seg;
|
||||
int j,memonly,inmemory,seg = -1;
|
||||
int c,sib;
|
||||
ulong dsize,regsize,addr;
|
||||
char s[TEXTLEN];
|
||||
@ -448,7 +448,8 @@ static void DecodeMR(int type) {
|
||||
strcat(s,"*8");
|
||||
};
|
||||
};
|
||||
Memadr(seg,s,addr,dsize);
|
||||
if (seg!=-1)
|
||||
Memadr(seg,s,addr,dsize);
|
||||
};
|
||||
}
|
||||
// Last possibility: 32-bit address without SIB byte.
|
||||
|
@ -17,7 +17,7 @@ ut64 Elf_(r_bin_elf_resize_section)(struct Elf_(r_bin_elf_obj_t) *bin, const cha
|
||||
Elf_(Shdr) *shdr = bin->shdr, *shdrp;
|
||||
const char *strtab = bin->strtab;
|
||||
ut8 *buf;
|
||||
ut64 off, got_offset, got_addr = 0, rsz_offset, delta = 0;
|
||||
ut64 off, got_offset = 0, got_addr = 0, rsz_offset = 0, delta = 0;
|
||||
ut64 rsz_osize = 0, rsz_size = size, rest_size = 0;
|
||||
int i, j, done = 0;
|
||||
|
||||
@ -171,35 +171,36 @@ ut64 Elf_(r_bin_elf_resize_section)(struct Elf_(r_bin_elf_obj_t) *bin, const cha
|
||||
/* XXX Endianness? */
|
||||
int Elf_(r_bin_elf_del_rpath)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
||||
Elf_(Dyn) *dyn = NULL;
|
||||
ut64 stroff;
|
||||
ut64 stroff = 0LL;
|
||||
int ndyn, i, j;
|
||||
|
||||
for (i = 0; i < bin->ehdr.e_phnum; i++)
|
||||
if (bin->phdr[i].p_type == PT_DYNAMIC) {
|
||||
if (!(dyn = malloc (bin->phdr[i].p_filesz))) {
|
||||
perror("malloc (dyn)");
|
||||
perror ("malloc (dyn)");
|
||||
return R_FALSE;
|
||||
}
|
||||
if (r_buf_read_at (bin->b, bin->phdr[i].p_offset, (ut8*)dyn, bin->phdr[i].p_filesz) == -1) {
|
||||
eprintf("Error: read (dyn)\n");
|
||||
eprintf ("Error: read (dyn)\n");
|
||||
free (dyn);
|
||||
return R_FALSE;
|
||||
}
|
||||
ndyn = (int)(bin->phdr[i].p_filesz / sizeof(Elf_(Dyn)));
|
||||
for (j = 0; j < ndyn; j++)
|
||||
if (dyn[j].d_tag == DT_STRTAB) {
|
||||
stroff = (ut64)(dyn[j].d_un.d_ptr - bin->baddr);
|
||||
break;
|
||||
}
|
||||
for (j = 0; j < ndyn; j++)
|
||||
if (dyn[j].d_tag == DT_RPATH || dyn[j].d_tag == DT_RUNPATH) {
|
||||
if (r_buf_write_at (bin->b, stroff + dyn[j].d_un.d_val,
|
||||
(ut8*)"", 1) == -1) {
|
||||
eprintf("Error: write (rpath)\n");
|
||||
free (dyn);
|
||||
return R_FALSE;
|
||||
if ((ndyn = (int)(bin->phdr[i].p_filesz / sizeof(Elf_(Dyn)))) > 0) {
|
||||
for (j = 0; j < ndyn; j++)
|
||||
if (dyn[j].d_tag == DT_STRTAB) {
|
||||
stroff = (ut64)(dyn[j].d_un.d_ptr - bin->baddr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (j = 0; j < ndyn; j++)
|
||||
if (dyn[j].d_tag == DT_RPATH || dyn[j].d_tag == DT_RUNPATH) {
|
||||
if (r_buf_write_at (bin->b, stroff + dyn[j].d_un.d_val,
|
||||
(ut8*)"", 1) == -1) {
|
||||
eprintf ("Error: write (rpath)\n");
|
||||
free (dyn);
|
||||
return R_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
free (dyn);
|
||||
break;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
/* radare - LGPL - Copyright 2009-2010 pancake<nopcode.org> */
|
||||
/* radare - LGPL - Copyright 2009-2011 pancake<nopcode.org> */
|
||||
|
||||
#include <r_debug.h>
|
||||
#include <r_lib.h>
|
||||
#include "libgdbwrap/include/gdbwrapper.h"
|
||||
|
||||
/* TODO: The IO stuff must be communicated with the r_dbg */
|
||||
@ -64,6 +63,7 @@ static int r_debug_gdb_detach(int pid) {
|
||||
|
||||
struct r_debug_plugin_t r_dbg_plugin_gdb = {
|
||||
.name = "gdb",
|
||||
// XXX this must be a bitmask
|
||||
.archs = { "x86", 0 }, //"x86-64", "arm", "powerpc", 0 },
|
||||
.step = &r_debug_gdb_step,
|
||||
.cont = &r_debug_gdb_continue,
|
||||
|
@ -7,11 +7,11 @@
|
||||
#include <r_lib.h>
|
||||
#include <signal.h>
|
||||
|
||||
#if DEBUGGER
|
||||
static int r_debug_native_continue(int pid, int tid, int sig);
|
||||
static int r_debug_native_reg_read(RDebug *dbg, int type, ut8 *buf, int size);
|
||||
static int r_debug_native_reg_write(int pid, int tid, int type, const ut8* buf, int size);
|
||||
|
||||
#define DEBUGGER 1
|
||||
#define MAXBT 128
|
||||
|
||||
#if __WINDOWS__
|
||||
@ -115,6 +115,10 @@ typedef unsigned long mips64_regs_t [4096];
|
||||
#define DEBUGGER 0
|
||||
#endif // ARCH
|
||||
|
||||
#endif /* IF DEBUGGER */
|
||||
|
||||
|
||||
/* begin of debugger code */
|
||||
#if DEBUGGER
|
||||
|
||||
#if __APPLE__
|
||||
|
@ -1,6 +1,6 @@
|
||||
OBJ=parse.o
|
||||
BIN=parse
|
||||
BINDEPS=r_util r_lib r_parse r_flags r_cons
|
||||
BINDEPS=r_util r_lib r_parse r_flags r_cons r_anal
|
||||
LIBS+=${DL_LIBS}
|
||||
|
||||
include ../../rules.mk
|
||||
|
@ -4,7 +4,7 @@ all: hex fmt
|
||||
|
||||
BIN=hex
|
||||
OBJ=hex.o
|
||||
BINDEPS=r_cons r_line r_print r_util
|
||||
BINDEPS=r_cons r_line r_print r_util r_anal r_asm
|
||||
|
||||
fmt${EXT_EXE}: fmt.o
|
||||
${CC} -I../../include fmt.o -L../../util -lr_util ${LDFLAGS} -o fmt${EXT_EXE}
|
||||
|
@ -52,12 +52,11 @@ R_API int r_reg_set_value(RReg *reg, RRegItem *item, ut64 value) {
|
||||
|
||||
if (!item)
|
||||
return R_FALSE;
|
||||
|
||||
switch (item->size) {
|
||||
case 64: v64 = (ut64)value; src = (ut8*)&v64; break;
|
||||
case 32: v32 = (ut32)value; src = (ut8*)&v32; break;
|
||||
case 16: v16 = (ut16)value; src = (ut8*)&v16; break;
|
||||
case 8: v8 = (ut8)value; src = (ut8*)&v8; break;
|
||||
case 8: v8 = (ut8)value; src = (ut8*)&v8; break;
|
||||
case 1:
|
||||
if (value) {
|
||||
ut8 * buf = reg->regset[item->type].arena->bytes + (item->offset/8);
|
||||
@ -70,10 +69,10 @@ R_API int r_reg_set_value(RReg *reg, RRegItem *item, ut64 value) {
|
||||
ut8 mask = 0xff^(1<<bit);
|
||||
buf[0] = (buf[0] & mask) | 0;
|
||||
}
|
||||
break;
|
||||
return R_TRUE;
|
||||
default:
|
||||
eprintf ("r_reg_set_value: Bit size %d not supported\n", item->size);
|
||||
break;
|
||||
return R_FALSE;
|
||||
}
|
||||
r_mem_copybits (reg->regset[item->type].arena->bytes+
|
||||
BITS2BYTES (item->offset), src, item->size);
|
||||
|
Loading…
Reference in New Issue
Block a user