Skip to content

Commit

Permalink
Add S.j command to print current section in JSON (radareorg#7490)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianherrera authored and radare committed May 14, 2017
1 parent 478095b commit c7cc81e
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions libr/core/cmd_section.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,29 @@ static int cmd_section(void *data, const char *input) {
if (core->io->va || core->io->debug) {
o = r_io_section_vaddr_to_maddr_try (core->io, o);
}
r_list_foreach (core->io->sections, iter, s) {
if (o >= s->paddr && o < s->paddr + s->size) {
r_cons_printf ("0x%08"PFMT64x" 0x%08"PFMT64x" %s\n",
s->paddr + s->vaddr,
s->paddr + s->vaddr + s->size,
s->name);
break;
if (input[1] == 'j') { // "S.j"
r_cons_printf ("[");
r_list_foreach (core->io->sections, iter, s) {
if (o >= s->paddr && o < s->paddr + s->size) {
char *name = r_str_escape (s->name);
r_cons_printf ("{\"start\":%" PFMT64u ",\"end\":%" PFMT64u ",\"name\":\"%s\"}",
s->paddr + s->vaddr,
s->paddr + s->vaddr + s->size,
name);
free (name);
break;
}
}
r_cons_printf ("]");
} else {
r_list_foreach (core->io->sections, iter, s) {
if (o >= s->paddr && o < s->paddr + s->size) {
r_cons_printf ("0x%08"PFMT64x" 0x%08"PFMT64x" %s\n",
s->paddr + s->vaddr,
s->paddr + s->vaddr + s->size,
s->name);
break;
}
}
}
}
Expand Down

0 comments on commit c7cc81e

Please sign in to comment.