mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-01 11:11:56 +00:00
* Add RBinInfo->has_va
- Used to autoforce io.va after loading the bin - Fixes loading kernel modules and object files * Fix loading strings on a object file without io.va * Add install-rev.sh script
This commit is contained in:
parent
be843f0cda
commit
6de942e05d
@ -36,7 +36,8 @@ static void get_strings_range(RBinArch *arch, RList *list, int min, ut64 from, u
|
|||||||
}
|
}
|
||||||
str[matches] = '\0';
|
str[matches] = '\0';
|
||||||
ptr->offset = i-matches;
|
ptr->offset = i-matches;
|
||||||
ptr->rva = ptr->offset-from+scnrva;
|
if (scnrva) ptr->rva = ptr->offset-from+scnrva;
|
||||||
|
else ptr->rva = ptr->offset;
|
||||||
ptr->size = matches+1;
|
ptr->size = matches+1;
|
||||||
ptr->ordinal = ctr;
|
ptr->ordinal = ctr;
|
||||||
// copying so many bytes here..
|
// copying so many bytes here..
|
||||||
@ -449,6 +450,7 @@ R_API RBinObj *r_bin_get_object(RBin *bin, int flags) {
|
|||||||
for (i=0; i<R_BIN_SYM_LAST; i++)
|
for (i=0; i<R_BIN_SYM_LAST; i++)
|
||||||
obj->binsym[i] = r_bin_get_sym (bin, i);
|
obj->binsym[i] = r_bin_get_sym (bin, i);
|
||||||
obj->baddr = r_bin_get_baddr (bin);
|
obj->baddr = r_bin_get_baddr (bin);
|
||||||
|
obj->info = r_bin_get_info (bin);
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -394,16 +394,10 @@ char* Elf_(r_bin_elf_get_data_encoding)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char* Elf_(r_bin_elf_get_type)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
int Elf_(r_bin_elf_has_va)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
||||||
ut32 e_type = (ut32)bin->ehdr.e_type; // cast to avoid warn in iphone-gcc, must be ut16
|
ut32 e_type = (ut32)bin->ehdr.e_type; // cast to avoid warn in iphone-gcc, must be ut16
|
||||||
if (e_type == ET_REL)
|
//if (bin->ehdr.e_phnum == 0)
|
||||||
return strdup ("elf-object");
|
return (e_type == ET_REL)? 0: 1;
|
||||||
return strdup ("elf");
|
|
||||||
#if ANOTHERCHK
|
|
||||||
if (bin->ehdr.e_phnum == 0)
|
|
||||||
return strdup ("elf-object");
|
|
||||||
return strdup ("elf");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: do not strdup here
|
// TODO: do not strdup here
|
||||||
|
@ -80,7 +80,7 @@ struct Elf_(r_bin_elf_obj_t) {
|
|||||||
struct r_buf_t* b;
|
struct r_buf_t* b;
|
||||||
};
|
};
|
||||||
|
|
||||||
char* Elf_(r_bin_elf_get_type)(struct Elf_(r_bin_elf_obj_t) *bin);
|
int Elf_(r_bin_elf_has_va)(struct Elf_(r_bin_elf_obj_t) *bin);
|
||||||
ut64 Elf_(r_bin_elf_get_baddr)(struct Elf_(r_bin_elf_obj_t) *bin);
|
ut64 Elf_(r_bin_elf_get_baddr)(struct Elf_(r_bin_elf_obj_t) *bin);
|
||||||
ut64 Elf_(r_bin_elf_get_entry_offset)(struct Elf_(r_bin_elf_obj_t) *bin);
|
ut64 Elf_(r_bin_elf_get_entry_offset)(struct Elf_(r_bin_elf_obj_t) *bin);
|
||||||
ut64 Elf_(r_bin_elf_get_main_offset)(struct Elf_(r_bin_elf_obj_t) *bin);
|
ut64 Elf_(r_bin_elf_get_main_offset)(struct Elf_(r_bin_elf_obj_t) *bin);
|
||||||
|
@ -35,6 +35,7 @@ static RBinInfo * info(RBinArch *arch) {
|
|||||||
strncpy (ret->file, arch->file, R_BIN_SIZEOF_STRINGS);
|
strncpy (ret->file, arch->file, R_BIN_SIZEOF_STRINGS);
|
||||||
strncpy (ret->rpath, "NONE", R_BIN_SIZEOF_STRINGS);
|
strncpy (ret->rpath, "NONE", R_BIN_SIZEOF_STRINGS);
|
||||||
strncpy (ret->type, "DEX CLASS", R_BIN_SIZEOF_STRINGS);
|
strncpy (ret->type, "DEX CLASS", R_BIN_SIZEOF_STRINGS);
|
||||||
|
ret->has_va = R_FALSE;
|
||||||
version = r_bin_dex_get_version (arch->bin_obj);
|
version = r_bin_dex_get_version (arch->bin_obj);
|
||||||
strncpy (ret->bclass, version, R_BIN_SIZEOF_STRINGS);
|
strncpy (ret->bclass, version, R_BIN_SIZEOF_STRINGS);
|
||||||
free (version);
|
free (version);
|
||||||
|
@ -240,11 +240,10 @@ static RBinInfo* info(RBinArch *arch) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
strncpy (ret->arch, str, R_BIN_SIZEOF_STRINGS);
|
strncpy (ret->arch, str, R_BIN_SIZEOF_STRINGS);
|
||||||
free (str);
|
free (str);
|
||||||
str = Elf_(r_bin_elf_get_type) (arch->bin_obj);
|
strncpy (ret->rclass, "elf", R_BIN_SIZEOF_STRINGS);
|
||||||
strncpy (ret->rclass, str, R_BIN_SIZEOF_STRINGS);
|
|
||||||
free (str);
|
|
||||||
ret->bits = Elf_(r_bin_elf_get_bits) (arch->bin_obj);
|
ret->bits = Elf_(r_bin_elf_get_bits) (arch->bin_obj);
|
||||||
ret->big_endian=Elf_(r_bin_elf_is_big_endian) (arch->bin_obj);
|
ret->big_endian = Elf_(r_bin_elf_is_big_endian) (arch->bin_obj);
|
||||||
|
ret->has_va = Elf_(r_bin_elf_has_va) (arch->bin_obj);
|
||||||
ret->dbg_info = 0;
|
ret->dbg_info = 0;
|
||||||
if (!Elf_(r_bin_elf_get_stripped) (arch->bin_obj))
|
if (!Elf_(r_bin_elf_get_stripped) (arch->bin_obj))
|
||||||
ret->dbg_info |= 0x04 | 0x08 | 0x10;
|
ret->dbg_info |= 0x04 | 0x08 | 0x10;
|
||||||
@ -296,8 +295,8 @@ static RBuffer* create(RBin* bin, const ut8 *code, int codelen, const ut8 *data,
|
|||||||
ut32 baddr;
|
ut32 baddr;
|
||||||
int is_arm = !strcmp (bin->curarch.info->arch, "arm");
|
int is_arm = !strcmp (bin->curarch.info->arch, "arm");
|
||||||
RBuffer *buf = r_buf_new ();
|
RBuffer *buf = r_buf_new ();
|
||||||
if (is_arm)
|
// XXX: hardcoded
|
||||||
baddr = 0x40000;
|
if (is_arm) baddr = 0x40000;
|
||||||
else baddr = 0x8048000;
|
else baddr = 0x8048000;
|
||||||
|
|
||||||
#define B(x,y) r_buf_append_bytes(buf,(const ut8*)x,y)
|
#define B(x,y) r_buf_append_bytes(buf,(const ut8*)x,y)
|
||||||
|
@ -69,6 +69,7 @@ static RBinInfo* info(RBinArch *arch) {
|
|||||||
p = fsname (arch);
|
p = fsname (arch);
|
||||||
strncpy (ret->arch, p, sizeof (ret->arch)-1);
|
strncpy (ret->arch, p, sizeof (ret->arch)-1);
|
||||||
free (p);
|
free (p);
|
||||||
|
ret->has_va = 0;
|
||||||
ret->bits = 32;
|
ret->bits = 32;
|
||||||
ret->big_endian = 0;
|
ret->big_endian = 0;
|
||||||
ret->dbg_info = 0;
|
ret->dbg_info = 0;
|
||||||
|
@ -119,6 +119,7 @@ static RBinInfo* info(RBinArch *arch) {
|
|||||||
version = r_bin_java_get_version (arch->bin_obj);
|
version = r_bin_java_get_version (arch->bin_obj);
|
||||||
strncpy (ret->bclass, version, R_BIN_SIZEOF_STRINGS-1);
|
strncpy (ret->bclass, version, R_BIN_SIZEOF_STRINGS-1);
|
||||||
free (version);
|
free (version);
|
||||||
|
ret->has_va = 0;
|
||||||
strncpy (ret->rclass, "class", R_BIN_SIZEOF_STRINGS-1);
|
strncpy (ret->rclass, "class", R_BIN_SIZEOF_STRINGS-1);
|
||||||
strncpy (ret->os, "any", R_BIN_SIZEOF_STRINGS-1);
|
strncpy (ret->os, "any", R_BIN_SIZEOF_STRINGS-1);
|
||||||
strncpy (ret->subsystem, "any", R_BIN_SIZEOF_STRINGS-1);
|
strncpy (ret->subsystem, "any", R_BIN_SIZEOF_STRINGS-1);
|
||||||
|
@ -157,7 +157,7 @@ static RBinInfo* info(RBinArch *arch) {
|
|||||||
strncpy (ret->bclass, str, R_BIN_SIZEOF_STRINGS);
|
strncpy (ret->bclass, str, R_BIN_SIZEOF_STRINGS);
|
||||||
free (str);
|
free (str);
|
||||||
}
|
}
|
||||||
strncpy(ret->rclass, "mach0", R_BIN_SIZEOF_STRINGS);
|
strncpy (ret->rclass, "mach0", R_BIN_SIZEOF_STRINGS);
|
||||||
/* TODO get os*/
|
/* TODO get os*/
|
||||||
strncpy (ret->os, "darwin", R_BIN_SIZEOF_STRINGS);
|
strncpy (ret->os, "darwin", R_BIN_SIZEOF_STRINGS);
|
||||||
strncpy (ret->subsystem, "darwin", R_BIN_SIZEOF_STRINGS);
|
strncpy (ret->subsystem, "darwin", R_BIN_SIZEOF_STRINGS);
|
||||||
@ -177,6 +177,7 @@ static RBinInfo* info(RBinArch *arch) {
|
|||||||
ret->big_endian = MACH0_(r_bin_mach0_is_big_endian) (arch->bin_obj);
|
ret->big_endian = MACH0_(r_bin_mach0_is_big_endian) (arch->bin_obj);
|
||||||
/* TODO detailed debug info */
|
/* TODO detailed debug info */
|
||||||
ret->dbg_info = 0;
|
ret->dbg_info = 0;
|
||||||
|
ret->has_va = R_TRUE;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* radare - LGPL - Copyright 2009-2010 nibble<.ds@gmail.com> */
|
/* radare - LGPL - Copyright 2009-2011 nibble<.ds@gmail.com> */
|
||||||
|
|
||||||
#include <r_types.h>
|
#include <r_types.h>
|
||||||
#include <r_bin.h>
|
#include <r_bin.h>
|
||||||
|
@ -154,6 +154,7 @@ static RBinInfo* info(RBinArch *arch) {
|
|||||||
strncpy (ret->subsystem, "plan9", R_BIN_SIZEOF_STRINGS);
|
strncpy (ret->subsystem, "plan9", R_BIN_SIZEOF_STRINGS);
|
||||||
strncpy (ret->type, "EXEC (Executable file)", R_BIN_SIZEOF_STRINGS);
|
strncpy (ret->type, "EXEC (Executable file)", R_BIN_SIZEOF_STRINGS);
|
||||||
ret->bits = bits;
|
ret->bits = bits;
|
||||||
|
ret->has_va = 1;
|
||||||
ret->big_endian = big_endian;
|
ret->big_endian = big_endian;
|
||||||
ret->dbg_info = 0;
|
ret->dbg_info = 0;
|
||||||
ret->dbg_info = 0;
|
ret->dbg_info = 0;
|
||||||
|
@ -198,6 +198,7 @@ static RBinInfo* info(RBinArch *arch) {
|
|||||||
ret->bits = PE_(r_bin_pe_get_bits) (arch->bin_obj);
|
ret->bits = PE_(r_bin_pe_get_bits) (arch->bin_obj);
|
||||||
ret->big_endian = PE_(r_bin_pe_is_big_endian) (arch->bin_obj);
|
ret->big_endian = PE_(r_bin_pe_is_big_endian) (arch->bin_obj);
|
||||||
ret->dbg_info = 0;
|
ret->dbg_info = 0;
|
||||||
|
ret->has_va = 0;
|
||||||
if (!PE_(r_bin_pe_is_stripped_debug) (arch->bin_obj))
|
if (!PE_(r_bin_pe_is_stripped_debug) (arch->bin_obj))
|
||||||
ret->dbg_info |= 0x01;
|
ret->dbg_info |= 0x01;
|
||||||
if (PE_(r_bin_pe_is_stripped_line_nums) (arch->bin_obj))
|
if (PE_(r_bin_pe_is_stripped_line_nums) (arch->bin_obj))
|
||||||
|
@ -80,27 +80,26 @@ static int bin_info (RCore *r, int mode) {
|
|||||||
// XXX: hack to disable io.va when loading an elf object
|
// XXX: hack to disable io.va when loading an elf object
|
||||||
// XXX: this must be something generic for all filetypes
|
// XXX: this must be something generic for all filetypes
|
||||||
// XXX: needs new api in r_bin_has_va () or something..
|
// XXX: needs new api in r_bin_has_va () or something..
|
||||||
int has_va = (!strcmp (info->rclass, "elf-object"))? 0: 1;
|
//int has_va = (!strcmp (info->rclass, "elf-object"))? 0: 1;
|
||||||
//if (!strcmp (info->type, "REL"))...relocatable object..
|
//if (!strcmp (info->type, "REL"))...relocatable object..
|
||||||
r_cons_printf (
|
r_cons_printf (
|
||||||
"e file.type=%s\n"
|
"e file.type=%s\n"
|
||||||
"e io.va=%d\n"
|
|
||||||
"e cfg.bigendian=%s\n"
|
"e cfg.bigendian=%s\n"
|
||||||
"e asm.os=%s\n"
|
"e asm.os=%s\n"
|
||||||
"e asm.arch=%s\n"
|
"e asm.arch=%s\n"
|
||||||
"e anal.plugin=%s\n"
|
"e anal.plugin=%s\n"
|
||||||
"e asm.bits=%i\n"
|
"e asm.bits=%i\n"
|
||||||
"e asm.dwarf=%s\n",
|
"e asm.dwarf=%s\n",
|
||||||
info->rclass, has_va,
|
info->rclass, r_str_bool (info->big_endian), info->os,
|
||||||
info->big_endian?"true":"false", info->os,
|
|
||||||
info->arch, info->arch, info->bits,
|
info->arch, info->arch, info->bits,
|
||||||
R_BIN_DBG_STRIPPED (info->dbg_info)?"false":"true");
|
r_str_bool (R_BIN_DBG_STRIPPED (info->dbg_info)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if type is 'fs' show something different?
|
// if type is 'fs' show something different?
|
||||||
r_cons_printf ("[File info]\n");
|
r_cons_printf ("[File info]\n");
|
||||||
r_cons_printf ("File=%s\n"
|
r_cons_printf ("File=%s\n"
|
||||||
"Type=%s\n"
|
"Type=%s\n"
|
||||||
|
"HasVA=%s\n"
|
||||||
"RootClass=%s\n"
|
"RootClass=%s\n"
|
||||||
"Class=%s\n"
|
"Class=%s\n"
|
||||||
"Arch=%s %i\n"
|
"Arch=%s %i\n"
|
||||||
@ -114,7 +113,8 @@ static int bin_info (RCore *r, int mode) {
|
|||||||
"Local_syms=%s\n"
|
"Local_syms=%s\n"
|
||||||
"Relocs=%s\n"
|
"Relocs=%s\n"
|
||||||
"RPath=%s\n",
|
"RPath=%s\n",
|
||||||
info->file, info->type, info->rclass, info->bclass,
|
info->file, info->type, r_str_bool (info->has_va),
|
||||||
|
info->rclass, info->bclass,
|
||||||
info->arch, info->bits, info->machine, info->os,
|
info->arch, info->bits, info->machine, info->os,
|
||||||
info->subsystem,
|
info->subsystem,
|
||||||
r_str_bool (info->big_endian),
|
r_str_bool (info->big_endian),
|
||||||
|
@ -105,6 +105,9 @@ R_API int r_core_bin_load(RCore *r, const char *file) {
|
|||||||
} else if (!r_bin_load (r->bin, file, R_TRUE))
|
} else if (!r_bin_load (r->bin, file, R_TRUE))
|
||||||
return R_FALSE;
|
return R_FALSE;
|
||||||
r->file->obj = r_bin_get_object (r->bin, 0);
|
r->file->obj = r_bin_get_object (r->bin, 0);
|
||||||
|
if (r->file->obj->info != NULL) {
|
||||||
|
r_config_set_i (r->config, "io.va", r->file->obj->info->has_va);
|
||||||
|
} else r_config_set_i (r->config, "io.va", 0);
|
||||||
{
|
{
|
||||||
ut64 offset = r_bin_get_offset (r->bin);
|
ut64 offset = r_bin_get_offset (r->bin);
|
||||||
r_core_bin_info (r, R_CORE_BIN_ACC_ALL, R_CORE_BIN_SET, va, NULL, offset);
|
r_core_bin_info (r, R_CORE_BIN_ACC_ALL, R_CORE_BIN_SET, va, NULL, offset);
|
||||||
|
@ -195,6 +195,7 @@ typedef struct r_bin_info_t {
|
|||||||
char subsystem[R_BIN_SIZEOF_STRINGS];
|
char subsystem[R_BIN_SIZEOF_STRINGS];
|
||||||
char rpath[R_BIN_SIZEOF_STRINGS];
|
char rpath[R_BIN_SIZEOF_STRINGS];
|
||||||
int bits;
|
int bits;
|
||||||
|
int has_va;
|
||||||
int big_endian;
|
int big_endian;
|
||||||
ut64 dbg_info;
|
ut64 dbg_info;
|
||||||
} RBinInfo;
|
} RBinInfo;
|
||||||
|
17
sys/install-rev.sh
Executable file
17
sys/install-rev.sh
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: install-rev [revision-number]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
REV="$1"
|
||||||
|
MAKE=make
|
||||||
|
gmake --help >/dev/null 2>&1
|
||||||
|
[ $? = 0 ] && MAKE=gmake
|
||||||
|
|
||||||
|
# find root
|
||||||
|
cd `dirname $PWD/$0` ; cd ..
|
||||||
|
echo hg up -C -r "${REV}"
|
||||||
|
hg up -C -r "${REV}"
|
||||||
|
|
||||||
|
./sys/build.sh && sudo ${MAKE} symstall
|
Loading…
x
Reference in New Issue
Block a user