Handle rabin2 -D cxx - like c++filt

This commit is contained in:
pancake 2015-07-07 00:38:51 +02:00
parent cae1d3c8cc
commit 6995ea2c93
2 changed files with 43 additions and 17 deletions

View File

@ -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);

View File

@ -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
@ -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