mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-22 07:13:43 +00:00
Minor wip cleanups in bin
This commit is contained in:
parent
ef1e724a1a
commit
ecfb908b6c
@ -1147,22 +1147,24 @@ static char *demangle_classname(const char *s) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *get_class_name(mach0_ut p, RBinFile *bf) {
|
||||
static char *get_class_name(RBinFile *bf, mach0_ut p) {
|
||||
r_return_val_if_fail (bf && bf->bo, NULL);
|
||||
RBinObject *bo = bf->bo;
|
||||
ut32 offset, left;
|
||||
ut64 r;
|
||||
int len;
|
||||
ut8 sc[sizeof (mach0_ut)] = {0};
|
||||
const ut32 ptr_size = sizeof (mach0_ut);
|
||||
|
||||
if (!bf || !bf->bo || !bf->bo->bin_obj || !bf->bo->info) {
|
||||
if (!bo->bin_obj || !bo->info) {
|
||||
R_LOG_WARN ("Invalid RBinFile pointer");
|
||||
return NULL;
|
||||
}
|
||||
if (!p) {
|
||||
return NULL;
|
||||
}
|
||||
bool bigendian = bf->bo->info->big_endian;
|
||||
struct MACH0_(obj_t) *bin = (struct MACH0_(obj_t) *)bf->bo->bin_obj;
|
||||
bool bigendian = bo->info->big_endian;
|
||||
struct MACH0_(obj_t) *bin = (struct MACH0_(obj_t) *)bo->bin_obj;
|
||||
|
||||
if (!(r = va2pa (p, &offset, &left, bf))) {
|
||||
return NULL;
|
||||
@ -1228,8 +1230,7 @@ static char *get_class_name(mach0_ut p, RBinFile *bf) {
|
||||
rc = 0;
|
||||
}
|
||||
name[sizeof (name) - 1] = 0;
|
||||
char *result = demangle_classname (name);
|
||||
return result;
|
||||
return demangle_classname (name);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@ -1422,7 +1423,7 @@ void MACH0_(get_class_t)(mach0_ut p, RBinFile *bf, RBinClass *klass, bool dupe,
|
||||
|
||||
klass->addr = c.isa;
|
||||
if (c.superclass) {
|
||||
const char *klass_name = get_class_name (c.superclass, bf);
|
||||
const char *klass_name = get_class_name (bf, c.superclass);
|
||||
if (klass_name) {
|
||||
if (klass->super == NULL) {
|
||||
klass->super = r_list_newf ((void *)r_bin_name_free);
|
||||
|
@ -91,8 +91,9 @@ static RBinAddr *newEntry(ut64 hpaddr, ut64 paddr, int type, int bits) {
|
||||
ptr->hpaddr = hpaddr;
|
||||
ptr->bits = bits;
|
||||
ptr->type = type;
|
||||
//realign due to thumb
|
||||
// realign due to thumb
|
||||
if (bits == 16 && ptr->vaddr & 1) {
|
||||
// TODO add hint about thumb entrypoint
|
||||
ptr->paddr--;
|
||||
ptr->vaddr--;
|
||||
}
|
||||
@ -252,13 +253,11 @@ static RList *imports(RBinFile *bf) {
|
||||
}
|
||||
|
||||
static void _r_bin_reloc_free(RBinReloc *reloc) {
|
||||
if (!reloc) {
|
||||
return;
|
||||
if (reloc) {
|
||||
// XXX also need to free or unref RBinSymbol?
|
||||
r_bin_import_free (reloc->import);
|
||||
free (reloc);
|
||||
}
|
||||
|
||||
// XXX also need to free RBinSymbol?
|
||||
r_bin_import_free (reloc->import);
|
||||
free (reloc);
|
||||
}
|
||||
|
||||
static RList *relocs(RBinFile *bf) {
|
||||
@ -280,8 +279,8 @@ static RList *relocs(RBinFile *bf) {
|
||||
if (reloc->external) {
|
||||
continue;
|
||||
}
|
||||
RBinReloc *ptr = NULL;
|
||||
if (!(ptr = R_NEW0 (RBinReloc))) {
|
||||
RBinReloc *ptr = R_NEW0 (RBinReloc);
|
||||
if (!ptr) {
|
||||
break;
|
||||
}
|
||||
ptr->type = reloc->type;
|
||||
@ -915,7 +914,7 @@ static RBuffer *create(RBin *bin, const ut8 *code, int clen, const ut8 *data, in
|
||||
filesize = magiclen + cmdsize + clen + dlen;
|
||||
// TEXT SEGMENT should span the whole file //
|
||||
W (p_codefsz, &filesize, 4);
|
||||
W (p_codefsz-8, &filesize, 4); // vmsize = filesize
|
||||
W (p_codefsz - 8, &filesize, 4); // vmsize = filesize
|
||||
W (p_codeva, &codeva, 4);
|
||||
// clen = 4096;
|
||||
W (p_codesz, &clen, 4);
|
||||
|
@ -3991,6 +3991,7 @@ static bool bin_classes(RCore *r, PJ *pj, int mode) {
|
||||
r_list_foreach (c->methods, iter2, sym) {
|
||||
pj_o (pj);
|
||||
pj_ks (pj, "name", sym->name);
|
||||
// eprintf ("%s /// %s\n", sym->name, sym->dname);
|
||||
RFlagItem *fi = r_flag_get_at (r->flags, sym->vaddr, false);
|
||||
if (fi) {
|
||||
pj_ks (pj, "flag", fi->realname? fi->realname: fi->name);
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "../bin/format/pdb/pdb_downloader.h"
|
||||
|
||||
static RCoreHelpMessage help_msg_ih = {
|
||||
"Usage: ih", "[hjq]", "Display header information",
|
||||
"Usage: ih", "[*hjq]", "Display header information",
|
||||
"ih", "", "normal output to display binary headers",
|
||||
"ih*", "", "same as above, but in r2 commands",
|
||||
"ihj", "", "in json format",
|
||||
@ -92,11 +92,11 @@ static RCoreHelpMessage help_msg_id = {
|
||||
#define PAIR_WIDTH 9
|
||||
// TODO: reuse implementation in core/bin.c
|
||||
static void pair(const char *a, const char *b) {
|
||||
char ws[16];
|
||||
int al = strlen (a);
|
||||
if (!b) {
|
||||
return;
|
||||
}
|
||||
char ws[16];
|
||||
int al = strlen (a);
|
||||
memset (ws, ' ', sizeof (ws));
|
||||
al = PAIR_WIDTH - al;
|
||||
if (al < 0) {
|
||||
@ -982,8 +982,7 @@ static void cmd_ic(RCore *core, const char *input, PJ *pj, int is_array, bool va
|
||||
case 'l': // "icl"
|
||||
r_list_foreach (cls->methods, iter2, sym) {
|
||||
const char *comma = iter2->p? " ": "";
|
||||
r_cons_printf ("%s0x%"PFMT64x, comma,
|
||||
iova? sym->vaddr: sym->paddr);
|
||||
r_cons_printf ("%s0x%"PFMT64x, comma, iova? sym->vaddr: sym->paddr);
|
||||
}
|
||||
r_cons_newline ();
|
||||
break;
|
||||
@ -1770,7 +1769,7 @@ static int cmd_info(void *data, const char *input) {
|
||||
break;
|
||||
case 'V': // "iV"
|
||||
{
|
||||
RList *bfiles= r_core_bin_files (core);
|
||||
RList *bfiles = r_core_bin_files (core);
|
||||
RListIter *iter;
|
||||
RBinFile *bf;
|
||||
RBinFile *cur = core->bin->cur;
|
||||
|
Loading…
x
Reference in New Issue
Block a user