Fix c++ demangling check

This commit is contained in:
pancake 2015-01-09 22:15:25 +01:00
parent b23768c227
commit eefb49e91d

View file

@ -1,7 +1,15 @@
/* radare - LGPL - Copyright 2013 - pancake */
/* radare - LGPL - Copyright 2013-2015 - pancake */
#include <r_bin.h>
static int is_cxx_symbol (const char *name) {
if (!strncmp (name, "_Z", 2))
return 1;
if (!strncmp (name, "__Z", 3))
return 1;
return 0;
}
R_API int r_bin_lang_cxx(RBinFile *binfile) {
RBinObject *o = binfile ? binfile->o : NULL;
RBinInfo *info = o ? o->info : NULL;
@ -15,17 +23,18 @@ R_API int r_bin_lang_cxx(RBinFile *binfile) {
r_list_foreach (o->libs, iter, lib) {
if (strstr (lib, "stdc++")) {
hascxx = R_TRUE;
info->lang = "cxx";
break;
}
}
if (!hascxx)
r_list_foreach (o->symbols, iter, sym) {
if (!strncmp (sym->name, "__Z", 3)) {
hascxx = R_TRUE;
info->lang = "cxx";
break;
if (!hascxx) {
r_list_foreach (o->symbols, iter, sym) {
if (is_cxx_symbol (sym->name)) {
hascxx = R_TRUE;
break;
}
}
}
if (hascxx)
info->lang = "cxx";
return hascxx;
}