Skip to content

Commit

Permalink
Adding relro to i and putting stuff in semiorder
Browse files Browse the repository at this point in the history
  • Loading branch information
oddcoder authored and radare committed Apr 4, 2017
1 parent 86f2793 commit b25e990
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 52 deletions.
75 changes: 41 additions & 34 deletions libr/core/cbin.c
Expand Up @@ -673,59 +673,66 @@ static int bin_info(RCore *r, int mode) {
if (IS_MODE_JSON (mode)) {
r_cons_printf ("{");
}
pair_bool ("havecode", havecode, mode, false);
pair_bool ("pic", info->has_pi, mode, false);
pair_str ("arch", info->arch, mode, false);
pair_int ("binsz", r_bin_get_size (r->bin), mode, false);
pair_str ("bintype", info->rclass, mode, false);
pair_int ("bits", info->bits, mode, false);
pair_bool ("canary", info->has_canary, mode, false);
pair_bool ("nx", info->has_nx, mode, false);
pair_str ("class", info->bclass, mode, false);
if (info->actual_checksum) {
/* computed checksum */
pair_str ("cmp.csum", info->actual_checksum, mode, false);
}
pair_str ("compiled", compiled, mode, false);
pair_bool ("crypto", info->has_crypto, mode, false);
pair_bool ("va", info->has_va, mode, false);
tmp_buf = r_str_escape (info->debug_file_name);
pair_str ("dbg_file", tmp_buf, mode, false);
free (tmp_buf);
pair_str ("endian", info->big_endian ? "big" : "little", mode, false);
pair_bool ("havecode", havecode, mode, false);
if (info->claimed_checksum) {
/* checksum specified in header */
pair_str ("hdr.csum", info->claimed_checksum, mode, false);
}
pair_str ("guid", info->guid, mode, false);
pair_str ("intrp", info->intrp, mode, false);
pair_str ("bintype", info->rclass, mode, false);
pair_str ("class", info->bclass, mode, false);
pair_str ("lang", info->lang, mode, false);
pair_str ("arch", info->arch, mode, false);
pair_int ("bits", info->bits, mode, false);
pair_bool ("linenum", R_BIN_DBG_LINENUMS & info->dbg_info, mode, false);
pair_bool ("lsyms", R_BIN_DBG_SYMS & info->dbg_info, mode, false);
pair_str ("machine", info->machine, mode, false);
pair_str ("os", info->os, mode, false);
v = r_anal_archinfo (r->anal, R_ANAL_ARCHINFO_MAX_OP_SIZE);
if (v != -1) {
pair_int ("maxopsz", v, mode, false);
}
v = r_anal_archinfo (r->anal, R_ANAL_ARCHINFO_MIN_OP_SIZE);
if (v != -1) {
pair_int ("minopsz", v, mode, false);
}
v = r_anal_archinfo (r->anal, R_ANAL_ARCHINFO_MAX_OP_SIZE);
if (v != -1) {
pair_int ("maxopsz", v, mode, false);
pair_bool ("nx", info->has_nx, mode, false);
pair_str ("os", info->os, mode, false);
if (info->rclass && !strcmp (info->rclass, "pe")) {
pair_bool ("overlay", info->pe_overlay, mode, false);
}
v = r_anal_archinfo (r->anal, R_ANAL_ARCHINFO_ALIGN);
if (v != -1) {
pair_int ("pcalign", v, mode, false);
}
pair_str ("subsys", info->subsystem, mode, false);
pair_str ("endian", info->big_endian ? "big" : "little", mode, false);
pair_bool ("stripped", R_BIN_DBG_STRIPPED & info->dbg_info, mode, false);
pair_bool ("static", r_bin_is_static (r->bin), mode, false);
pair_bool ("linenum", R_BIN_DBG_LINENUMS & info->dbg_info, mode, false);
pair_bool ("lsyms", R_BIN_DBG_SYMS & info->dbg_info, mode, false);
pair_bool ("pic", info->has_pi, mode, false);
pair_bool ("relocs", R_BIN_DBG_RELOCS & info->dbg_info, mode, false);
pair_str ("rpath", info->rpath, mode, false);
pair_int ("binsz", r_bin_get_size (r->bin), mode, false);
pair_str ("compiled", compiled, mode, false);
tmp_buf = r_str_escape (info->debug_file_name);
pair_str ("dbg_file", tmp_buf, mode, false);
free (tmp_buf);
if (info->claimed_checksum) {
/* checksum specified in header */
pair_str ("hdr.csum", info->claimed_checksum, mode, false);
}
if (info->actual_checksum) {
/* computed checksum */
pair_str ("cmp.csum", info->actual_checksum, mode, false);
tmp_buf = sdb_get (obj->kv, "elf.relro", 0);
if (tmp_buf) {
pair_str ("relro", tmp_buf, mode, false);
free (tmp_buf);
}
pair_str ("rpath", info->rpath, mode, false);
if (info->rclass && !strcmp (info->rclass, "pe")) {
pair_bool ("overlay", info->pe_overlay, mode, false);
//this should be moved if added to mach0 (or others)
pair_bool ("signed", info->signature, mode, false);
}

pair_bool ("static", r_bin_is_static (r->bin), mode, false);
pair_bool ("stripped", R_BIN_DBG_STRIPPED & info->dbg_info, mode, false);
pair_str ("subsys", info->subsystem, mode, false);
pair_bool ("va", info->has_va, mode, true);
for (i = 0; info->sum[i].type; i++) {
RBinHash *h = &info->sum[i];
ut64 hash = r_hash_name_to_bits (h->type);
Expand All @@ -742,7 +749,7 @@ static int bin_info(RCore *r, int mode) {
}
r_cons_newline ();
}
pair_str ("guid", info->guid, mode, true);

if (IS_MODE_JSON (mode)) r_cons_printf ("}");
}
r_core_anal_type_init (r);
Expand Down
44 changes: 26 additions & 18 deletions libr/core/cmd_info.c
Expand Up @@ -85,13 +85,8 @@ static void r_core_file_info(RCore *core, int mode) {
}
if (info) {
fn = info->file;
switch (mode) {
case R_CORE_BIN_JSON:
if (mode == R_CORE_BIN_JSON) {
r_cons_printf ("\"type\":\"%s\"", STR (info->type));
break;
default:
pair ("type", info->type);
break;
}
} else {
fn = (cf && cf->desc)? cf->desc->name: NULL;
Expand Down Expand Up @@ -139,32 +134,44 @@ static void r_core_file_info(RCore *core, int mode) {
r_cons_printf ("}");
} else if (cf && mode != R_CORE_BIN_SIMPLE) {
//r_cons_printf ("# Core file info\n");
pair ("file", fn? fn: cf->desc->uri);
if (dbg) {
dbg = R_IO_WRITE | R_IO_EXEC;
}
if (cf->desc) {
ut64 fsz = r_io_desc_size (core->io, cf->desc);
if (cf->desc->referer && *cf->desc->referer) {
pair ("referer", cf->desc->referer);
}
pair ("blksz", sdb_fmt (0, "0x%"PFMT64x, (ut64) core->io->desc->obsz));
}
pair ("block", sdb_fmt (0, "0x%x", core->blocksize));
if (cf->desc) {
pair ("fd", sdb_fmt (0, "%d", cf->desc->fd));
}
pair ("file", fn? fn: cf->desc->uri);
if (plugin) {
pair ("format", plugin->name);
}
if (cf->desc) {
if (fsz != UT64_MAX) {
pair ("size", sdb_fmt (0,"0x%"PFMT64x, fsz));
pair ("humansz", r_num_units (NULL, fsz));
}
pair ("iorw", r_str_bool ( io_cache ||\
cf->desc->flags & R_IO_WRITE ));
pair ("iorw", r_str_bool (io_cache || cf->desc->flags & R_IO_WRITE ));
pair ("blksz", sdb_fmt (0, "0x%"PFMT64x,
(ut64) core->io->desc->obsz));
pair ("mode", r_str_rwx_i (cf->desc->flags & 7));
}
pair ("block", sdb_fmt (0, "0x%x", core->blocksize));
if (binfile && binfile->curxtr) {
pair ("packet", binfile->curxtr->name);
}
if (plugin) {
pair ("format", plugin->name);
if (cf->desc && cf->desc->referer && *cf->desc->referer) {
pair ("referer", cf->desc->referer);
}
if (cf->desc) {
ut64 fsz = r_io_desc_size (core->io, cf->desc);
if (fsz != UT64_MAX) {
pair ("size", sdb_fmt (0,"0x%"PFMT64x, fsz));
}
}
if (info) {
pair ("type", info->type);
}
}
}
Expand Down Expand Up @@ -202,9 +209,10 @@ static void cmd_info_bin(RCore *core, int va, int mode) {
if (obj && bin_is_executable (obj)) {
if ((mode & R_CORE_BIN_JSON)) {
r_cons_printf (",\"bin\":");
} else {
r_cons_printf("\n");
}
r_core_bin_info (core, R_CORE_BIN_ACC_INFO,
mode, va, NULL, NULL);
r_core_bin_info (core, R_CORE_BIN_ACC_INFO, mode, va, NULL, NULL);
}
if (mode == R_CORE_BIN_JSON && array == 0) {
r_cons_printf ("}\n");
Expand Down

0 comments on commit b25e990

Please sign in to comment.