Skip to content

Commit

Permalink
Handle rabin2 -D cxx - like c++filt
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Jul 6, 2015
1 parent cae1d3c commit 6995ea2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 17 deletions.
54 changes: 40 additions & 14 deletions binr/rabin2/rabin2.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,20 +535,46 @@ int main(int argc, char **argv) {
}
type = r_bin_demangle_type (do_demangle);
file = argv[optind +1];
switch (type) {
case R_BIN_NM_CXX: res = r_bin_demangle_cxx (file); break;
case R_BIN_NM_JAVA: res = r_bin_demangle_java (file); break;
case R_BIN_NM_OBJC: res = r_bin_demangle_objc (NULL, file); break;
case R_BIN_NM_SWIFT: res = r_bin_demangle_swift (file); break;
case R_BIN_NM_MSVC: res = r_bin_demangle_msvc(file); break;
default:
eprintf ("Unknown lang to demangle. Use: cxx, java, objc, swift\n");
return 1;
}
if (res && *res) {
printf ("%s\n", res);
free(res);
return 0;
if (!strcmp (file, "-")) {
for (;;) {
file = stdin_gets();
if (!file || !*file) break;
switch (type) {
case R_BIN_NM_CXX: res = r_bin_demangle_cxx (file); break;
case R_BIN_NM_JAVA: res = r_bin_demangle_java (file); break;
case R_BIN_NM_OBJC: res = r_bin_demangle_objc (NULL, file); break;
case R_BIN_NM_SWIFT: res = r_bin_demangle_swift (file); break;
case R_BIN_NM_MSVC: res = r_bin_demangle_msvc(file); break;
default:
eprintf ("Unknown lang to demangle. Use: cxx, java, objc, swift\n");
return 1;
}
if (res && *res) {
printf ("%s\n", res);
} else if (file && *file) {
printf ("%s\n", file);
}
R_FREE (res);
R_FREE (file);
}
} else {
switch (type) {
case R_BIN_NM_CXX: res = r_bin_demangle_cxx (file); break;
case R_BIN_NM_JAVA: res = r_bin_demangle_java (file); break;
case R_BIN_NM_OBJC: res = r_bin_demangle_objc (NULL, file); break;
case R_BIN_NM_SWIFT: res = r_bin_demangle_swift (file); break;
case R_BIN_NM_MSVC: res = r_bin_demangle_msvc(file); break;
default:
eprintf ("Unknown lang to demangle. Use: cxx, java, objc, swift\n");
return 1;
}
if (res && *res) {
printf ("%s\n", res);
free(res);
return 0;
} else {
printf ("%s\n", file);
}
}
free (res);
//eprintf ("%s\n", file);
Expand Down
6 changes: 3 additions & 3 deletions man/rabin2.1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
.Op Fl b Ar bits
.Op Fl B Ar addr
.Op Fl C Ar fmt:C:[D]
.Op Fl D Ar lang
.Op Fl D Ar lang sym|-
.Op Fl f Ar subbin
.Op Fl k Ar query
.Op Fl K Ar algo
Expand Down Expand Up @@ -39,8 +39,8 @@ List classes
Create [elf,mach0,pe] for arm and x86-32/64 tiny binaries where 'C' is an hexpair list of the code bytes and ':D' is an optional concatenation to describe the bytes for the data section.
.It Fl d
Show debug/dwarf information
.It Fl D Ar lang symbolname
Demangle symbol name for lang
.It Fl D Ar lang symbolname|-
Demangle symbol name (or - to read from stdin) for lang (cxx, swift, java, cxx, ..)
.It Fl e
Show entrypoints for disk and on-memory
.It Fl f Ar subbin
Expand Down

0 comments on commit 6995ea2

Please sign in to comment.