Fix ignored asm.bits settings because of RBin overrides ##asm (#15677)

This commit is contained in:
radare 2019-12-18 17:33:56 +01:00 committed by GitHub
parent 74a42f0ead
commit 9fc6367338
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 5 deletions

View File

@ -2498,7 +2498,8 @@ static int bin_sections(RCore *r, int mode, ut64 laddr, int va, ut64 at, const c
r_flag_space_set (r->flags, print_segments? R_FLAGS_FS_SEGMENTS: R_FLAGS_FS_SECTIONS);
}
if (IS_MODE_NORMAL (mode)) {
r_table_set_columnsf (table, "dXxXxss", "nth", "paddr", "size", "vaddr", "vsize", "perm", "name");
r_table_set_columnsf (table, "dXxXxss",
"nth", "paddr", "size", "vaddr", "vsize", "perm", "name");
// r_table_align (table, 0, R_TABLE_ALIGN_CENTER);
r_table_align (table, 2, R_TABLE_ALIGN_RIGHT);
r_table_align (table, 4, R_TABLE_ALIGN_RIGHT);
@ -2716,6 +2717,8 @@ static int bin_sections(RCore *r, int mode, ut64 laddr, int va, ut64 at, const c
const char *name = (r->bin->prefix)
? sdb_fmt ("%s.%s", r->bin->prefix, section->name)
: section->name;
// seems like asm.bits is a bitmask that seems to be always 32,64
// const char *asmbits = r_str_sysbits (bits);
r_table_add_rowf (table, "dXxXxss", i,
(ut64)section->paddr, (ut64)section->size,
(ut64)addr, (ut64)section->vsize,

View File

@ -344,18 +344,25 @@ R_API void r_core_arch_bits_at(RCore *core, ut64 addr, R_OUT R_NULLABLE int *bit
if (!core->fixedarch) {
archval = s->arch;
}
if (!core->fixedbits) {
bitsval = s->bits;
if (!core->fixedbits && s->bits) {
// only enforce if there's one bits set
switch (s->bits) {
case R_SYS_BITS_16:
case R_SYS_BITS_32:
case R_SYS_BITS_64:
bitsval = s->bits;
break;
}
}
}
if (bits && !bitsval && !core->fixedbits) {
//if we found bits related with anal hints pick it up
__choose_bits_anal_hints (core, addr, &bitsval);
}
if (bits) {
if (bits && bitsval) {
*bits = bitsval;
}
if (arch) {
if (arch && archval) {
*arch = archval;
}
}

View File

@ -90,6 +90,7 @@ R_API bool r_str_is_printable_incl_newlines(const char *str);
R_API char *r_str_appendlen(char *ptr, const char *string, int slen);
R_API char *r_str_newf(const char *fmt, ...);
R_API char *r_str_newlen(const char *str, int len);
R_API const char *r_str_sysbits(const int v);
R_API char *r_str_trunc_ellipsis(const char *str, int len);
R_API const char *r_str_bool(int b);
R_API bool r_str_is_true(const char *s);

View File

@ -156,6 +156,19 @@ R_API int r_str_bits(char *strout, const ut8 *buf, int len, const char *bitz) {
return j;
}
R_API const char *r_str_sysbits(const int v) {
switch (v) {
case R_SYS_BITS_8: return "8";
case R_SYS_BITS_16: return "16";
case R_SYS_BITS_32: return "32";
case R_SYS_BITS_64: return "64";
case R_SYS_BITS_16 | R_SYS_BITS_32: return "16,32";
case R_SYS_BITS_16 | R_SYS_BITS_32 | R_SYS_BITS_64: return "16,32,64";
case R_SYS_BITS_32 | R_SYS_BITS_64: return "32,64";
}
return "?";
}
// In-place trims a bitstring to groups of 8 bits.
// For example, the bitstring 1000000000000000 will not be modified, but the
// bitstring 0000000001000000 will be changed to 01000000.