Skip to content

Commit

Permalink
Fix #23538 - iS sha1,sha1/sort/inc table queries + entropy ##bin
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae authored Nov 19, 2024
1 parent f4b0117 commit c9aaba7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
1 change: 1 addition & 0 deletions libr/core/cbin.c
Original file line number Diff line number Diff line change
Expand Up @@ -3062,6 +3062,7 @@ static bool bin_sections(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at
} else if (IS_MODE_RAD (mode) && at == UT64_MAX) {
r_cons_printf ("fs %ss\n", type);
} else if (IS_MODE_NORMAL (mode) && at == UT64_MAX && !printHere) {
// R2_600 - remove this [Sections] header
r_cons_printf ("[%s]\n", print_segments ? "Segments" : "Sections");
} else if (IS_MODE_NORMAL (mode) && printHere) {
r_cons_printf ("Current section\n");
Expand Down
21 changes: 10 additions & 11 deletions libr/core/cmd_info.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1472,12 +1472,6 @@ static void cmd_iS(RCore *core, const char *input, PJ **_pj, int mode, const boo
}
if (!input[1]) {
RBININFO ("sections", R_CORE_BIN_ACC_SECTIONS, NULL, 0);
} else if (input[1] == ',' || input[1] == ' ') {
R_FREE (core->table_query);
core->table_query = strdup (input + 2);
RBinObject *obj = r_bin_cur_object (core->bin);
int count = (obj && obj->sections)? r_list_length (obj->sections): 0;
RBININFO ("sections", R_CORE_BIN_ACC_SECTIONS, input + 1, count);
} else if (input[1] == 'S' && !input[2]) { // "iSS"
RBININFO ("segments", R_CORE_BIN_ACC_SEGMENTS, NULL, 0);
} else { // iS/iSS entropy,sha1
Expand All @@ -1487,13 +1481,18 @@ static void cmd_iS(RCore *core, const char *input, PJ **_pj, int mode, const boo
if (input[1] == 'S') {
name = "segments";
input++;
if (input[1] == ',') {
R_FREE (core->table_query);
core->table_query = strdup (input + 2);
}
action = R_CORE_BIN_ACC_SEGMENTS;
}
switch (input[1]) {
char input0 = input[1];
if (*input == ' ') {
input ++;
}
const char *comma = strchr (input, ',');
if (comma) {
R_FREE (core->table_query);
core->table_query = strdup (comma + 1);
}
switch (input0) {
case '=': // "iS="
mode = R_MODE_EQUAL;
break;
Expand Down
2 changes: 1 addition & 1 deletion test/db/cmd/cmd_i
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NAME=iS query
FILE=bins/elf/analysis/main
CMDS=iS size/sort,vaddr/cols/name
CMDS=iS,size/sort,vaddr/cols/name
EXPECT=<<EOF
[Sections]

Expand Down
32 changes: 16 additions & 16 deletions test/db/formats/dwarf
Original file line number Diff line number Diff line change
Expand Up @@ -730,22 +730,22 @@ colu: 12
addr: 0x00001149
EOF
EXPECT_ERR=<<EOF
DEBUG: [cbin.c:3352] (section .dynsym) Cd 8[21] @ 0x3d8
DEBUG: [cbin.c:3352] (section .dynstr) Css 141 @ 0x480
DEBUG: [cbin.c:3352] (section .rela.dyn) Cd 8[24] @ 0x550
DEBUG: [cbin.c:3352] (section .rela.plt) Cd 8[3] @ 0x610
DEBUG: [cbin.c:3352] (section .init_array) Cd 8[1] @ 0x3db8
DEBUG: [cbin.c:3352] (section .fini_array) Cd 8[1] @ 0x3dc0
DEBUG: [cbin.c:3352] (section .dynamic) Cd 8[62] @ 0x3dc8
DEBUG: [cbin.c:3352] (section .got) Cd 8[9] @ 0x3fb8
DEBUG: [cbin.c:3352] (section .dynsym) Cd 8[21] @ 0x3d8
DEBUG: [cbin.c:3352] (section .dynstr) Css 141 @ 0x480
DEBUG: [cbin.c:3352] (section .rela.dyn) Cd 8[24] @ 0x550
DEBUG: [cbin.c:3352] (section .rela.plt) Cd 8[3] @ 0x610
DEBUG: [cbin.c:3352] (section .init_array) Cd 8[1] @ 0x3db8
DEBUG: [cbin.c:3352] (section .fini_array) Cd 8[1] @ 0x3dc0
DEBUG: [cbin.c:3352] (section .dynamic) Cd 8[62] @ 0x3dc8
DEBUG: [cbin.c:3352] (section .got) Cd 8[9] @ 0x3fb8
DEBUG: [cbin.c:3353] (section .dynsym) Cd 8[21] @ 0x3d8
DEBUG: [cbin.c:3353] (section .dynstr) Css 141 @ 0x480
DEBUG: [cbin.c:3353] (section .rela.dyn) Cd 8[24] @ 0x550
DEBUG: [cbin.c:3353] (section .rela.plt) Cd 8[3] @ 0x610
DEBUG: [cbin.c:3353] (section .init_array) Cd 8[1] @ 0x3db8
DEBUG: [cbin.c:3353] (section .fini_array) Cd 8[1] @ 0x3dc0
DEBUG: [cbin.c:3353] (section .dynamic) Cd 8[62] @ 0x3dc8
DEBUG: [cbin.c:3353] (section .got) Cd 8[9] @ 0x3fb8
DEBUG: [cbin.c:3353] (section .dynsym) Cd 8[21] @ 0x3d8
DEBUG: [cbin.c:3353] (section .dynstr) Css 141 @ 0x480
DEBUG: [cbin.c:3353] (section .rela.dyn) Cd 8[24] @ 0x550
DEBUG: [cbin.c:3353] (section .rela.plt) Cd 8[3] @ 0x610
DEBUG: [cbin.c:3353] (section .init_array) Cd 8[1] @ 0x3db8
DEBUG: [cbin.c:3353] (section .fini_array) Cd 8[1] @ 0x3dc0
DEBUG: [cbin.c:3353] (section .dynamic) Cd 8[62] @ 0x3dc8
DEBUG: [cbin.c:3353] (section .got) Cd 8[9] @ 0x3fb8
WARN: [cbin.c:1899] Relocs has not been applied. Please use `-e bin.relocs.apply=true` or `-e bin.cache=true` next time
DEBUG: [cbin.c:2593] Cannot resolve symbol address __libc_start_main
DEBUG: [cbin.c:2593] Cannot resolve symbol address _ITM_deregisterTMCloneTable
Expand Down

0 comments on commit c9aaba7

Please sign in to comment.