Switch iI command to use RzTable API

* Implement `rz_table_transpose()`
* Switch `iI` command to use RzTable API
This commit is contained in:
sandrabeme 2021-05-07 23:54:14 +05:30 committed by Anton Kochkov
parent d6da1ddd54
commit bdface85a2
19 changed files with 500 additions and 335 deletions

View file

@ -33,34 +33,54 @@
static RZ_NULLABLE RZ_BORROW const RzList *core_bin_strings(RzCore *r, RzBinFile *file);
static void pair(const char *key, const char *val) {
static void pair(const char *key, const char *val, RzList *row_list, RzTable *t) {
if (!val || !*val) {
return;
}
rz_cons_printf("%-" PAIR_WIDTH "s%s\n", key, val);
RzTableColumnType *typeString = rz_table_type("string");
rz_table_add_column(t, typeString, key, 0);
rz_list_append(row_list, strdup(val));
val = NULL;
key = NULL;
}
static void pair_bool(PJ *pj, const char *key, bool val) {
static char *get_coloured(const char *flag, bool use_color) {
if (use_color == true) {
if (strncmp(flag, "true", 5) == 0) {
return rz_str_newf(Color_GREEN "true" Color_RESET);
} else {
return rz_str_newf(Color_RED "false" Color_RESET);
}
} else {
return strncmp(flag, "true", 5) == 0 ? strdup("true") : strdup("false");
}
}
static void pair_bool(bool use_color, RzTable *t, PJ *pj, const char *key, bool val, RzList *row_list) {
if (pj) {
pj_kb(pj, key, val);
} else {
pair(key, rz_str_bool(val));
RzTableColumnType *typeString = rz_table_type("bool");
const char *b = val || typeString ? get_coloured(rz_str_bool(val), use_color) : "";
pair(key, b, row_list, t);
}
}
static void pair_int(PJ *pj, const char *key, int val) {
static void pair_int(RzTable *t, PJ *pj, const char *key, int val, RzList *row_list) {
if (pj) {
pj_ki(pj, key, val);
} else {
pair(key, sdb_fmt("%d", val));
const char *fmt = rz_str_newf("%d", val);
pair(key, fmt, row_list, t);
}
}
static void pair_ut64(PJ *pj, const char *key, ut64 val) {
static void pair_ut64(RzTable *t, PJ *pj, const char *key, ut64 val, RzList *row_list) {
if (pj) {
pj_kn(pj, key, val);
} else {
pair(key, sdb_fmt("%" PFMT64d, val));
const char *fmt = rz_str_newf("%" PFMT64d, val);
pair(key, fmt, row_list, t);
}
}
@ -117,22 +137,23 @@ static char *__filterShell(const char *arg) {
return a;
}
static void pair_ut64x(PJ *pj, const char *key, ut64 val) {
static void pair_ut64x(RzTable *t, PJ *pj, const char *key, ut64 val, RzList *row_list) {
if (pj) {
pair_ut64(pj, key, val);
pair_ut64(t, pj, key, val, row_list);
} else {
pair(key, sdb_fmt("0x%" PFMT64x, val));
const char *fmt = rz_str_newf("0x%" PFMT64x, val);
pair(key, fmt, row_list, t);
}
}
static void pair_str(PJ *pj, const char *key, const char *val) {
static void pair_str(RzTable *t, PJ *pj, const char *key, const char *val, RzList *row_list) {
if (pj) {
if (!val) {
val = "";
}
pj_ks(pj, key, val);
} else {
pair(key, val);
pair(key, val, row_list, t);
}
}
@ -1724,6 +1745,7 @@ static int bin_info(RzCore *r, PJ *pj, int mode, ut64 laddr) {
int i, j, v;
RzBinInfo *info = rz_bin_get_info(r->bin);
RzBinFile *bf = rz_bin_cur(r->bin);
bool use_color = rz_config_get_i(r->config, "scr.color");
if (!bf) {
if (IS_MODE_JSON(mode)) {
pj_o(pj);
@ -1802,94 +1824,110 @@ static int bin_info(RzCore *r, PJ *pj, int mode, ut64 laddr) {
}
}
} else {
// XXX: if type is 'fs' show something different?
char *tmp_buf;
RzTable *table = rz_core_table(r);
RzList *row_list = rz_list_new();
if (IS_MODE_JSON(mode)) {
pj_o(pj);
}
pair_str(pj, "arch", info->arch);
pair_str(table, pj, "arch", info->arch, row_list);
if (info->cpu && *info->cpu) {
pair_str(pj, "cpu", info->cpu);
pair_str(table, pj, "cpu", info->cpu, row_list);
}
pair_ut64x(pj, "baddr", rz_bin_get_baddr(r->bin));
pair_ut64(pj, "binsz", rz_bin_get_size(r->bin));
pair_str(pj, "bintype", info->rclass);
pair_int(pj, "bits", info->bits);
pair_bool(pj, "canary", info->has_canary);
pair_ut64x(table, pj, "baddr", rz_bin_get_baddr(r->bin), row_list);
pair_ut64(table, pj, "binsz", rz_bin_get_size(r->bin), row_list);
pair_str(table, pj, "bintype", info->rclass, row_list);
pair_int(table, pj, "bits", info->bits, row_list);
if (info->has_retguard != -1) {
pair_bool(pj, "retguard", info->has_retguard);
pair_bool(use_color, table, pj, "retguard", info->has_retguard, row_list);
}
pair_str(pj, "class", info->bclass);
pair_str(table, pj, "class", info->bclass, row_list);
if (info->actual_checksum) {
/* computed checksum */
pair_str(pj, "cmp.csum", info->actual_checksum);
pair_str(table, pj, "cmp.csum", info->actual_checksum, row_list);
}
pair_str(pj, "compiled", compiled);
pair_str(pj, "compiler", info->compiler);
pair_bool(pj, "crypto", info->has_crypto);
pair_str(pj, "dbg_file", info->debug_file_name);
pair_str(pj, "endian", info->big_endian ? "big" : "little");
pair_str(table, pj, "compiled", compiled, row_list);
if (info->compiler) {
pair_str(table, pj, "compiler", rz_str_newf("%s", info->compiler), row_list);
}
pair_str(table, pj, "dbg_file", info->debug_file_name, row_list);
const char *endian = info->big_endian ? "BE" : "LE";
pair_str(table, pj, "endian", endian, row_list);
if (info->rclass && !strcmp(info->rclass, "mdmp")) {
tmp_buf = sdb_get(bf->sdb, "mdmp.flags", 0);
if (tmp_buf) {
pair_str(pj, "flags", tmp_buf);
pair_str(table, pj, "flags", tmp_buf, row_list);
free(tmp_buf);
}
}
pair_bool(pj, "havecode", havecode);
if (info->claimed_checksum) {
/* checksum specified in header */
pair_str(pj, "hdr.csum", info->claimed_checksum);
pair_str(table, pj, "hdr.csum", info->claimed_checksum, row_list);
}
pair_str(pj, "guid", info->guid);
pair_str(pj, "intrp", info->intrp);
pair_ut64x(pj, "laddr", laddr);
pair_str(pj, "lang", info->lang);
pair_bool(pj, "linenum", RZ_BIN_DBG_LINENUMS & info->dbg_info);
pair_bool(pj, "lsyms", RZ_BIN_DBG_SYMS & info->dbg_info);
pair_str(pj, "machine", info->machine);
v = rz_analysis_archinfo(r->analysis, RZ_ANALYSIS_ARCHINFO_MAX_OP_SIZE);
pair_str(table, pj, "guid", info->guid, row_list);
pair_str(table, pj, "intrp", info->intrp, row_list);
pair_ut64x(table, pj, "laddr", laddr, row_list);
pair_str(table, pj, "lang", info->lang, row_list);
pair_str(table, pj, "machine", info->machine, row_list);
st32 u = rz_analysis_archinfo(r->analysis, RZ_ANALYSIS_ARCHINFO_MAX_OP_SIZE);
if (u != -1) {
pair_int(table, pj, "maxopsz", u, row_list);
}
st32 v = rz_analysis_archinfo(r->analysis, RZ_ANALYSIS_ARCHINFO_MIN_OP_SIZE);
if (v != -1) {
pair_int(pj, "maxopsz", v);
pair_int(table, pj, "minopsz", v, row_list);
}
v = rz_analysis_archinfo(r->analysis, RZ_ANALYSIS_ARCHINFO_MIN_OP_SIZE);
if (v != -1) {
pair_int(pj, "minopsz", v);
}
pair_bool(pj, "nx", info->has_nx);
pair_str(pj, "os", info->os);
pair_str(table, pj, "os", info->os, row_list);
if (info->rclass && !strcmp(info->rclass, "pe")) {
pair_bool(pj, "overlay", info->pe_overlay);
pair_bool(use_color, table, pj, "overlay", info->pe_overlay, row_list);
}
pair_str(pj, "cc", info->default_cc);
v = rz_analysis_archinfo(r->analysis, RZ_ANALYSIS_ARCHINFO_ALIGN);
if (v != -1) {
pair_int(pj, "pcalign", v);
pair_str(table, pj, "cc", info->default_cc, row_list);
st32 uv = rz_analysis_archinfo(r->analysis, RZ_ANALYSIS_ARCHINFO_ALIGN);
if (uv != -1) {
pair_int(table, pj, "pcalign", uv, row_list);
}
pair_bool(pj, "pic", info->has_pi);
pair_bool(pj, "relocs", RZ_BIN_DBG_RELOCS & info->dbg_info);
Sdb *sdb_info = sdb_ns(obj->kv, "info", false);
tmp_buf = sdb_get(sdb_info, "elf.relro", 0);
if (tmp_buf) {
pair_str(pj, "relro", tmp_buf);
pair_str(table, pj, "relro", tmp_buf, row_list);
free(tmp_buf);
}
pair_str(pj, "rpath", info->rpath);
pair_str(table, pj, "rpath", info->rpath, row_list);
if (info->rclass && !strcmp(info->rclass, "pe")) {
//this should be moved if added to mach0 (or others)
pair_bool(pj, "signed", info->signature);
pair_bool(use_color, table, pj, "signed", info->signature, row_list);
}
pair_bool(pj, "sanitiz", info->has_sanitizers);
pair_bool(pj, "static", rz_bin_is_static(r->bin));
if (info->rclass && !strcmp(info->rclass, "mdmp")) {
v = sdb_num_get(bf->sdb, "mdmp.streams", 0);
if (v != -1) {
pair_int(pj, "streams", v);
pair_int(table, pj, "streams", v, row_list);
}
}
pair_bool(pj, "stripped", RZ_BIN_DBG_STRIPPED & info->dbg_info);
pair_str(pj, "subsys", info->subsystem);
pair_bool(pj, "va", info->has_va);
pair_str(table, pj, "subsys", info->subsystem, row_list);
pair_bool(use_color, table, pj, "stripped", RZ_BIN_DBG_STRIPPED & info->dbg_info, row_list);
pair_bool(use_color, table, pj, "crypto", info->has_crypto, row_list);
pair_bool(use_color, table, pj, "havecode", havecode, row_list);
pair_bool(use_color, table, pj, "va", info->has_va, row_list);
pair_bool(use_color, table, pj, "sanitiz", info->has_sanitizers, row_list);
pair_bool(use_color, table, pj, "static", rz_bin_is_static(r->bin), row_list);
pair_bool(use_color, table, pj, "linenum", RZ_BIN_DBG_LINENUMS & info->dbg_info, row_list);
pair_bool(use_color, table, pj, "lsyms", RZ_BIN_DBG_SYMS & info->dbg_info, row_list);
pair_bool(use_color, table, pj, "canary", info->has_canary, row_list);
pair_bool(use_color, table, pj, "PIE", info->has_pi, row_list);
pair_bool(use_color, table, pj, "RELROCS", RZ_BIN_DBG_RELOCS & info->dbg_info, row_list);
pair_bool(use_color, table, pj, "NX", info->has_nx, row_list);
rz_table_add_row_list(table, row_list);
if (!IS_MODE_JSON(mode)) {
RzTable *transpose = rz_table_transpose(table);
char *t = rz_table_tostring(transpose);
rz_cons_print(t);
rz_table_free(transpose);
free(t);
}
if (IS_MODE_JSON(mode)) {
pj_ko(pj, "checksums");
}
@ -1919,6 +1957,7 @@ static int bin_info(RzCore *r, PJ *pj, int mode, ut64 laddr) {
pj_end(pj);
pj_end(pj);
}
rz_table_free(table);
}
return true;
}
@ -2328,9 +2367,8 @@ static int print_relocs_for_object(RzCore *r, RzBinFile *bf, RzBinObject *o, int
} else if (IS_MODE_NORMAL(mode)) {
char *name = reloc->import
? strdup(reloc->import->name)
: reloc->symbol
? strdup(reloc->symbol->name)
: NULL;
: reloc->symbol ? strdup(reloc->symbol->name)
: NULL;
if (bin_demangle) {
char *mn = rz_bin_demangle(r->bin->cur, NULL, name, addr, keep_lib);
if (mn && *mn) {

View file

@ -89,11 +89,10 @@ RZ_API RzTable *rz_table_pop(RzTable *t);
RZ_API void rz_table_fromjson(RzTable *t, const char *csv);
RZ_API void rz_table_fromcsv(RzTable *t, const char *csv);
RZ_API char *rz_table_tohtml(RzTable *t);
RZ_API void rz_table_transpose(RzTable *t);
RZ_API RzTable *rz_table_transpose(RzTable *t);
RZ_API void rz_table_format(RzTable *t, int nth, RzTableColumnType *type);
RZ_API ut64 rz_table_reduce(RzTable *t, int nth);
RZ_API void rz_table_columns(RzTable *t, RzList *cols); // const char *name, ...);
#ifdef __cplusplus
}
#endif

View file

@ -1180,6 +1180,77 @@ RZ_API void rz_table_visual_list(RzTable *table, RzList *list, ut64 seek, ut64 l
}
}
/**
* /brief Generates the transpose of RzTable.
*
* /param t Referenced \p RzTable
* /return t Referenced \p RzTable
*
* This function returns the transpose of the RzTable passed to the table.
*/
RZ_OWN RZ_API RzTable *rz_table_transpose(RZ_NONNULL RzTable *t) {
rz_return_val_if_fail(t, NULL);
RzListIter *iter1;
RzListIter *iter;
RzListIter *trrow_iter; // transpose row iter
RzList *row_name = rz_list_new();
RzList *row_list;
RzTable *transpose = rz_table_new();
RzTableColumn *col;
RzTableRow *row;
RzTableColumnType *typeString = rz_table_type("string");
char *item;
// getting table column names to add to row head
rz_table_add_column(transpose, typeString, "Name", 0);
// adding rows to transpose table rows * (number of columns in the table)
for (int i = 0; i < t->rows->length; i++) {
rz_table_add_column(transpose, typeString, "Value", 0);
}
// column names to row heads
rz_list_foreach (t->cols, iter1, col) {
rz_list_append(row_name, col->name);
}
// adding rows with name alone
if (row_name && t->rows) {
iter = row_name->head;
if (iter) {
item = iter->data;
for (int i = 0; i < t->totalCols; i++) {
rz_table_add_row(transpose, item, NULL);
if (iter->n) {
iter = iter->n;
item = iter->data;
}
}
}
}
if (transpose->rows) {
row_list = transpose->rows;
trrow_iter = row_list->head;
RzTableRow *trans_row = trrow_iter->data;
rz_list_foreach (t->rows, iter, row) {
trrow_iter = row_list->head;
if (trrow_iter) {
trans_row = trrow_iter->data;
rz_list_foreach (row->items, iter1, item) {
if (trrow_iter && trans_row->items) {
trans_row = trrow_iter->data;
rz_list_append(trans_row->items, strdup(item));
trrow_iter = trrow_iter->n;
}
}
}
}
//free(item);
}
return transpose;
}
#if 0
// TODO: to be implemented
RZ_API RzTable *rz_table_clone(RzTable *t) {

View file

@ -191,34 +191,36 @@ format java
iorw true
block 0x100
type JAVA CLASS
Name Value
--------------
arch java
baddr 0x0
binsz 1024
bintype class
bits 32
canary false
retguard false
class Java SE 1.7
crypto false
endian big
havecode true
endian BE
laddr 0x0
lang java
linenum true
lsyms true
machine jvm
maxopsz 16
minopsz 1
nx false
os any
pcalign 0
pic false
relocs false
subsys any
stripped false
crypto false
havecode true
va false
sanitiz false
static false
stripped false
subsys any
va false
linenum true
lsyms true
canary false
PIE false
RELROCS false
NX false
;-- entry0:
;-- section.class.methods._init_.attr.0.code:
;-- sym.radare_test_cases_challenge.radare_test_cases.challenge._init:

View file

@ -7,7 +7,7 @@ iI~machine
EOF
EXPECT=<<EOF
arch sh
endian big
endian BE
machine Hitachi SH
EOF
RUN

View file

@ -217,26 +217,28 @@ mode rwx
format any
iorw true
block 0x100
Name Value
--------------
baddr 0x0
binsz 1025
bits 64
canary false
crypto false
endian little
havecode false
endian LE
laddr 0x0
linenum false
lsyms false
maxopsz 16
minopsz 1
nx false
pcalign 0
pic false
relocs false
stripped false
crypto false
havecode false
va false
sanitiz false
static true
stripped false
va false
linenum false
lsyms false
canary false
PIE false
RELROCS false
NX false
[Imports]
nth vaddr bind type lib name
----------------------------
@ -301,26 +303,28 @@ e cfg.bigendian=false
e asm.bits=64
e asm.dwarf=false
e asm.pcalign=0
Name Value
--------------
baddr 0x0
binsz 1024
bits 64
canary false
crypto false
endian little
havecode false
endian LE
laddr 0x0
linenum false
lsyms false
maxopsz 16
minopsz 1
nx false
pcalign 0
pic false
relocs false
stripped false
crypto false
havecode false
va false
sanitiz false
static true
stripped false
va false
linenum false
lsyms false
canary false
PIE false
RELROCS false
NX false
e cfg.bigendian=false
e asm.bits=64
e asm.dwarf=false
@ -339,37 +343,39 @@ mode r-x
format elf
iorw false
block 0x100
Name Value
--------------
arch x86
baddr 0x8048000
binsz 4899
bintype elf
bits 32
canary false
class ELF32
compiler GCC: (GNU) 4.8.2
crypto false
endian little
havecode true
endian LE
intrp /lib/ld-linux.so.2
laddr 0x0
lang c
linenum true
lsyms true
machine Intel 80386
maxopsz 16
minopsz 1
nx true
os linux
pcalign 0
pic false
relocs true
relro no
rpath NONE
subsys linux
stripped false
crypto false
havecode true
va true
sanitiz false
static false
stripped false
subsys linux
va true
linenum true
lsyms true
canary false
PIE false
RELROCS true
NX true
EOF
RUN
@ -431,34 +437,36 @@ format java
iorw true
block 0x100
type JAVA CLASS
Name Value
--------------
arch java
baddr 0x0
binsz 1024
bintype class
bits 32
canary false
retguard false
class Java SE 1.6
crypto false
endian big
havecode true
endian BE
laddr 0x0
lang java
linenum true
lsyms true
machine jvm
maxopsz 16
minopsz 1
nx false
os any
pcalign 0
pic false
relocs false
subsys any
stripped false
crypto false
havecode true
va false
sanitiz false
static false
stripped false
subsys any
va false
linenum true
lsyms true
canary false
PIE false
RELROCS false
NX false
;-- entry1:
;-- section.class.methods.TestMultipleVariable.attr.0.code:
;-- sym.TestVariableSwitchUp.TestVariableSwitchUp.TestMultipleVariable:
@ -1552,37 +1560,39 @@ NAME=iI (file x86)
FILE=bins/elf/analysis/x86-helloworld-gcc
CMDS=iI
EXPECT=<<EOF
Name Value
--------------
arch x86
baddr 0x8048000
binsz 4899
bintype elf
bits 32
canary false
class ELF32
compiler GCC: (GNU) 4.8.2
crypto false
endian little
havecode true
endian LE
intrp /lib/ld-linux.so.2
laddr 0x0
lang c
linenum true
lsyms true
machine Intel 80386
maxopsz 16
minopsz 1
nx true
os linux
pcalign 0
pic false
relocs true
relro no
rpath NONE
subsys linux
stripped false
crypto false
havecode true
va true
sanitiz false
static false
stripped false
subsys linux
va true
linenum true
lsyms true
canary false
PIE false
RELROCS true
NX true
EOF
RUN
@ -1596,36 +1606,36 @@ EXPECT=<<EOF
"binsz": 4899,
"bintype": "elf",
"bits": 32,
"canary": false,
"class": "ELF32",
"compiled": "",
"compiler": "GCC: (GNU) 4.8.2",
"crypto": false,
"dbg_file": "",
"endian": "little",
"havecode": true,
"endian": "LE",
"guid": "",
"intrp": "/lib/ld-linux.so.2",
"laddr": 0,
"lang": "c",
"linenum": true,
"lsyms": true,
"machine": "Intel 80386",
"maxopsz": 16,
"minopsz": 1,
"nx": true,
"os": "linux",
"cc": "",
"pcalign": 0,
"pic": false,
"relocs": true,
"relro": "no",
"rpath": "NONE",
"subsys": "linux",
"stripped": false,
"crypto": false,
"havecode": true,
"va": true,
"sanitiz": false,
"static": false,
"stripped": false,
"subsys": "linux",
"va": true,
"linenum": true,
"lsyms": true,
"canary": false,
"PIE": false,
"RELROCS": true,
"NX": true,
"checksums": {
}
@ -3133,37 +3143,39 @@ format elf64
iorw false
block 0x100
type EXEC (Executable file)
Name Value
--------------
arch x86
baddr 0x400000
binsz 6710
bintype elf
bits 64
canary false
class ELF64
compiler GCC: (GNU) 4.7.2
crypto false
endian little
havecode true
endian LE
intrp /lib/ld-linux-x86-64.so.2
laddr 0x0
lang c
linenum true
lsyms true
machine AMD x86-64 architecture
maxopsz 16
minopsz 1
nx true
os linux
pcalign 0
pic false
relocs true
relro no
rpath NONE
subsys linux
stripped false
crypto false
havecode true
va true
sanitiz false
static false
stripped false
subsys linux
va true
linenum true
lsyms true
canary false
PIE false
RELROCS true
NX true
EOF
RUN
@ -3225,37 +3237,39 @@ NAME=iI (file x86_64)
FILE=bins/elf/analysis/hello-linux-x86_64
CMDS=iI
EXPECT=<<EOF
Name Value
--------------
arch x86
baddr 0x400000
binsz 6710
bintype elf
bits 64
canary false
class ELF64
compiler GCC: (GNU) 4.7.2
crypto false
endian little
havecode true
endian LE
intrp /lib/ld-linux-x86-64.so.2
laddr 0x0
lang c
linenum true
lsyms true
machine AMD x86-64 architecture
maxopsz 16
minopsz 1
nx true
os linux
pcalign 0
pic false
relocs true
relro no
rpath NONE
subsys linux
stripped false
crypto false
havecode true
va true
sanitiz false
static false
stripped false
subsys linux
va true
linenum true
lsyms true
canary false
PIE false
RELROCS true
NX true
EOF
RUN

View file

@ -466,36 +466,38 @@ format elf
iorw false
block 0x100
type EXEC (Executable file)
Name Value
--------------
arch x86
baddr 0x8048000
binsz 20668
bintype elf
bits 32
canary true
class ELF32
crypto false
endian little
havecode true
endian LE
intrp /lib/ld-linux.so.2
laddr 0x0
lang c
linenum false
lsyms false
machine Intel 80386
maxopsz 16
minopsz 1
nx true
os linux
pcalign 0
pic false
relocs false
relro partial
rpath NONE
subsys linux
stripped true
crypto false
havecode true
va true
sanitiz false
static false
stripped true
subsys linux
va true
linenum false
lsyms false
canary true
PIE false
RELROCS false
NX true
--
1
fd 3

View file

@ -10,31 +10,33 @@ NAME=: DMP64 Info
FILE=bins/dmp/bmp.dmp
CMDS=iI
EXPECT=<<EOF
Name Value
--------------
arch x86
baddr 0xffffffffffffffff
binsz 88428600
bintype dmp64
bits 64
canary false
retguard false
crypto false
endian little
havecode true
endian LE
laddr 0x0
linenum false
lsyms false
machine AMD64
maxopsz 16
minopsz 1
nx false
os Unknown
pcalign 0
pic false
relocs false
stripped false
crypto false
havecode true
va true
sanitiz false
static true
stripped false
va true
linenum false
lsyms false
canary false
PIE false
RELROCS false
NX false
EOF
RUN

View file

@ -18,32 +18,34 @@ format dyldcache
iorw false
block 0x100
type library-cache
Name Value
--------------
arch arm
baddr 0x180000000
binsz 212992
bits 64
canary false
retguard false
class dyldcache
crypto false
endian little
havecode true
endian LE
laddr 0x0
linenum false
lsyms false
machine arm
maxopsz 4
minopsz 4
nx false
os Darwin
pcalign 4
pic false
relocs false
subsys xnu
stripped false
crypto false
havecode true
va true
sanitiz false
static true
stripped false
subsys xnu
va true
linenum false
lsyms false
canary false
PIE false
RELROCS false
NX false
[Symbols]
nth paddr vaddr bind type size lib name
@ -94,32 +96,34 @@ format dyldcache
iorw false
block 0x100
type library-cache
Name Value
--------------
arch arm
baddr 0x180000000
binsz 212992
bits 64
canary false
retguard false
class dyldcache
crypto false
endian little
havecode true
endian LE
laddr 0x0
linenum false
lsyms false
machine arm
maxopsz 4
minopsz 4
nx false
os Darwin
pcalign 4
pic false
relocs false
subsys xnu
stripped false
crypto false
havecode true
va true
sanitiz false
static true
stripped false
subsys xnu
va true
linenum false
lsyms false
canary false
PIE false
RELROCS false
NX false
[Symbols]
nth paddr vaddr bind type size lib name

View file

@ -1,8 +1,8 @@
NAME=ELF: elf-nx - nx enabled
FILE=bins/elf/analysis/elf-nx
ARGS=-A
CMDS=iI~^nx
CMDS=iI~^NX
EXPECT=<<EOF
nx true
NX true
EOF
RUN

View file

@ -408,32 +408,34 @@ format elf64
iorw false
block 0x100
type EXEC (Executable file)
Name Value
--------------
arch riscv
baddr 0x10000
binsz 643108
bintype elf
bits 64
canary false
class ELF64
compiler GCC: (GNU) 5.2.0
crypto false
endian little
havecode true
endian LE
laddr 0x0
lang c
linenum true
lsyms true
machine RISC V
nx false
os linux
pic false
relocs true
rpath NONE
subsys linux
stripped false
crypto false
havecode true
va true
sanitiz false
static true
stripped false
subsys linux
va true
linenum true
lsyms true
canary false
PIE false
RELROCS true
NX false
EOF
RUN

View file

@ -8,8 +8,8 @@ RUN
NAME=PE: corkami elf-nx - nx disabled
FILE=bins/elf/analysis/elf-xnorelro
CMDS=iI~^nx
CMDS=iI~^NX
EXPECT=<<EOF
nx false
NX false
EOF
RUN

View file

@ -16,35 +16,37 @@ format elf
iorw false
block 0x100
type EXEC (Executable file)
Name Value
--------------
arch v850
baddr 0x100000
binsz 973677
bintype elf
bits 32
canary false
class ELF32
compiler GCC: (GNU) 9.3.0
crypto false
endian little
havecode true
endian LE
laddr 0x0
lang c
linenum true
lsyms true
machine NEC V800 series
maxopsz 8
minopsz 2
nx false
os linux
pcalign 2
pic false
relocs true
rpath NONE
subsys linux
stripped false
crypto false
havecode true
va true
sanitiz false
static true
stripped false
subsys linux
va true
linenum true
lsyms true
canary false
PIE false
RELROCS true
NX false
0x00100004 3506ffff movea 0xffff, r21, r0
0x00100008 0000 mov r0, r0
0x0010000a 23060000 movea 0x0, r3, r0

View file

@ -10,35 +10,37 @@ NAME=mdmp info
FILE=bins/mdmp/calc.dmp
CMDS=iI
EXPECT=<<EOF
Name Value
--------------
arch x86
baddr 0xffffffffffffffff
binsz 36724
bintype mdmp
bits 64
canary false
retguard false
crypto false
endian little
endian LE
flags 0x00040000
havecode true
hdr.csum 0x00000000
laddr 0x0
linenum false
lsyms false
machine AMD64
maxopsz 16
minopsz 1
nx false
os Windows NT Workstation 6.1.7601
pcalign 0
pic false
relocs false
rpath NONE
sanitiz false
static true
streams 13
stripped false
crypto false
havecode true
va true
sanitiz false
static true
linenum false
lsyms false
canary false
PIE false
RELROCS false
NX false
EOF
RUN

View file

@ -1,18 +1,18 @@
NAME=PE: corkami dll.dll - DYNAMIC_BASE/ASLR disabled
FILE=bins/pe/dll.dll
ARGS=-n
CMDS=!rz-bin -I bins/pe/dll.dll | grep "pic false"
CMDS=!rz-bin -I bins/pe/dll.dll | grep "PIE false"
EXPECT=<<EOF
pic false
PIE false
EOF
RUN
NAME=PE: corkami aslr.dll - DYNAMIC_BASE/ASLR enabled
FILE=bins/pe/aslr.dll
ARGS=-n
CMDS=!rz-bin -I bins/pe/aslr.dll | grep pic | grep true
CMDS=!rz-bin -I bins/pe/aslr.dll | grep PIE | grep true
EXPECT=<<EOF
pic true
PIE true
EOF
RUN

View file

@ -6,27 +6,29 @@ iI
p8 0x30 @ 0x0801
EOF
EXPECT=<<EOF
Name Value
--------------
arch 6502
baddr 0x801
binsz 38
bits 8
canary false
retguard false
crypto false
endian little
havecode true
endian LE
laddr 0x0
linenum false
lsyms false
machine Commodore 64
nx false
os c64
pic false
relocs false
stripped false
crypto false
havecode true
va true
sanitiz false
static true
stripped false
va true
linenum false
lsyms false
canary false
PIE false
RELROCS false
NX false
0c08e2079e2032303632000000a941a2ff9dff03cad0faad2408a2ff9dffd7cad0fa6005ffffffffffffffffffffffff
EOF
RUN

View file

@ -10,28 +10,30 @@ format smd
iorw false
block 0x100
type ROM
Name Value
--------------
arch m68k
baddr 0x0
binsz 160504
bits 16
canary false
retguard false
class SEGA MEGASIS (C)2015 James L.
crypto false
endian big
havecode true
endian BE
laddr 0x0
linenum false
lsyms false
machine Sega Megadrive
nx false
os smd
pic false
relocs false
stripped false
crypto false
havecode true
va true
sanitiz false
static true
stripped false
va true
linenum false
lsyms false
canary false
PIE false
RELROCS false
NX false
EOF
RUN

View file

@ -615,37 +615,39 @@ nth paddr vaddr bind type size lib name
nth paddr vaddr len size section type string
-------------------------------------------------------
0 0x000004b0 0x080484b0 12 13 .rodata ascii Hello world!
Name Value
--------------
arch x86
baddr 0x8048000
binsz 4899
bintype elf
bits 32
canary false
class ELF32
compiler GCC: (GNU) 4.8.2
crypto false
endian little
havecode true
endian LE
intrp /lib/ld-linux.so.2
laddr 0x0
lang c
linenum true
lsyms true
machine Intel 80386
maxopsz 16
minopsz 1
nx true
os linux
pcalign 0
pic false
relocs true
relro no
rpath NONE
subsys linux
stripped false
crypto false
havecode true
va true
sanitiz false
static false
stripped false
subsys linux
va true
linenum true
lsyms true
canary false
PIE false
RELROCS true
NX true
0x00000000 ELF MAGIC 0x464c457f
0x00000010 Type 0x0002
0x00000012 Machine 0x0003
@ -723,37 +725,39 @@ NAME=rz-bin -I elf_cpp
FILE=bins/elf/analysis/a.out.cpp
CMDS=!rz-bin -I ${RZ_FILE}
EXPECT=<<EOF
Name Value
--------------
arch x86
baddr 0x0
binsz 7051
bintype elf
bits 64
canary false
class ELF64
compiler GCC: (Ubuntu 7.3.0-16ubuntu3) 7.3.0
crypto false
endian little
havecode true
endian LE
intrp /lib64/ld-linux-x86-64.so.2
laddr 0x0
lang c++
linenum true
lsyms true
machine AMD x86-64 architecture
maxopsz 16
minopsz 1
nx true
os linux
pcalign 0
pic true
relocs true
relro full
rpath NONE
subsys linux
stripped false
crypto false
havecode true
va true
sanitiz false
static false
stripped false
subsys linux
va true
linenum true
lsyms true
canary false
PIE true
RELROCS true
NX true
EOF
RUN
@ -761,37 +765,39 @@ NAME=rz-bin -I asan
FILE=bins/elf/analysis/a.out.asan
CMDS=!rz-bin -I ${RZ_FILE}
EXPECT=<<EOF
Name Value
--------------
arch x86
baddr 0x400000
binsz 1603255
bintype elf
bits 64
canary false
class ELF64
compiler GCC: (Debian 8.2.0-5) 8.2.0 clang version 6.0.1-6 (tags/RELEASE_601/final)
crypto false
endian little
havecode true
endian LE
intrp /lib64/ld-linux-x86-64.so.2
laddr 0x0
lang c++
linenum true
lsyms true
machine AMD x86-64 architecture
maxopsz 16
minopsz 1
nx true
os linux
pcalign 0
pic false
relocs true
relro partial
rpath NONE
subsys linux
stripped false
crypto false
havecode true
va true
sanitiz true
static false
stripped false
subsys linux
va true
linenum true
lsyms true
canary false
PIE false
RELROCS true
NX true
EOF
RUN
@ -799,34 +805,36 @@ NAME=rz-bin -I apple-blocks-ext
FILE=bins/mach0/mach0-blocks-ext
CMDS=!rz-bin -I ${RZ_FILE}
EXPECT=<<EOF
Name Value
--------------
arch x86
baddr 0x100000000
binsz 9828
bintype mach0
bits 64
canary false
class MACH064
crypto false
endian little
havecode true
endian LE
intrp /usr/lib/dyld
laddr 0x0
lang c++ with blocks
linenum false
lsyms false
machine x86 64 all
maxopsz 16
minopsz 1
nx false
os darwin
pcalign 0
pic true
relocs false
subsys darwin
stripped false
crypto false
havecode true
va true
sanitiz false
static false
stripped false
subsys darwin
va true
linenum false
lsyms false
canary false
PIE true
RELROCS false
NX false
EOF
RUN

View file

@ -322,6 +322,20 @@ bool test_rz_table_columns() {
#undef CREATE_TABLE
}
bool test_rz_table_transpose() {
RzTable *t = __table_test_data1();
rz_table_add_row(t, "d", "100", NULL);
char *table = rz_table_tostring(rz_table_transpose(t));
mu_assert_streq(table,
"Name Value Value Value Value\n"
"-----------------------------\n"
"ascii a b c d\n"
"code 97 98 99 100\n",
"rz_table_transpose");
free(table);
mu_end;
}
bool all_tests() {
mu_run_test(test_rz_table);
mu_run_test(test_rz_table_column_type);
@ -330,6 +344,7 @@ bool all_tests() {
mu_run_test(test_rz_table_uniq);
mu_run_test(test_rz_table_group);
mu_run_test(test_rz_table_columns);
mu_run_test(test_rz_table_transpose);
return tests_passed != tests_run;
}