mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-27 02:49:42 +00:00
Filter out specific symbols first prior to triggering the general case with
C++ symbol demangling.
This commit is contained in:
parent
7a7abb30b4
commit
0c421f0be8
@ -1339,28 +1339,7 @@ int load_elf(const char *filename, FILE *outfile, int out_type)
|
|||||||
for(i = 0, sym = symtab; i < nb_syms; i++, sym++) {
|
for(i = 0, sym = symtab; i < nb_syms; i++, sym++) {
|
||||||
const char *name;
|
const char *name;
|
||||||
name = strtab + sym->st_name;
|
name = strtab + sym->st_name;
|
||||||
/* demangle C++ symbols */
|
if (strstart(name, OP_PREFIX "execute", NULL)) {
|
||||||
demangled_name = cxx_demangle(name, demangled_name, &nd, &status);
|
|
||||||
if (status == 0 && strstart(demangled_name, OP_PREFIX, NULL)) {
|
|
||||||
/* get real function name */
|
|
||||||
char *p = strchr(demangled_name, '(');
|
|
||||||
if (p && !strstart(p, "()::label", NULL)) {
|
|
||||||
int func_name_length = p - demangled_name;
|
|
||||||
if (nd > nf) {
|
|
||||||
nf = nd;
|
|
||||||
if ((func_name = realloc(func_name, nf)) == NULL)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
strncpy(func_name, demangled_name, func_name_length);
|
|
||||||
func_name[func_name_length] = '\0';
|
|
||||||
/* emit code generator */
|
|
||||||
if (sym->st_shndx != (text_sec - shdr))
|
|
||||||
error("invalid section for opcode (%s:0x%x)", name, sym->st_shndx);
|
|
||||||
gen_code(func_name, demangled_name, sym->st_value, sym->st_size, outfile,
|
|
||||||
text, relocs, nb_relocs, 3, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (strstart(name, OP_PREFIX "execute", NULL)) {
|
|
||||||
strcpy(func_name, name);
|
strcpy(func_name, name);
|
||||||
if (sym->st_shndx != (text_sec - shdr))
|
if (sym->st_shndx != (text_sec - shdr))
|
||||||
error("invalid section for opcode (0x%x)", sym->st_shndx);
|
error("invalid section for opcode (0x%x)", sym->st_shndx);
|
||||||
@ -1390,6 +1369,29 @@ int load_elf(const char *filename, FILE *outfile, int out_type)
|
|||||||
do_print_code(outfile, gen_dot_prefix(name), rodata_cst16 + sym->st_value, 16);
|
do_print_code(outfile, gen_dot_prefix(name), rodata_cst16 + sym->st_value, 16);
|
||||||
fprintf(outfile, "#endif\n");
|
fprintf(outfile, "#endif\n");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
/* demangle C++ symbols */
|
||||||
|
demangled_name = cxx_demangle(name, demangled_name, &nd, &status);
|
||||||
|
if (status == 0 && strstart(demangled_name, OP_PREFIX, NULL)) {
|
||||||
|
/* get real function name */
|
||||||
|
char *p = strchr(demangled_name, '(');
|
||||||
|
if (p && !strstart(p, "()::label", NULL)) {
|
||||||
|
int func_name_length = p - demangled_name;
|
||||||
|
if (nd > nf) {
|
||||||
|
nf = nd;
|
||||||
|
if ((func_name = realloc(func_name, nf)) == NULL)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
strncpy(func_name, demangled_name, func_name_length);
|
||||||
|
func_name[func_name_length] = '\0';
|
||||||
|
/* emit code generator */
|
||||||
|
if (sym->st_shndx != (text_sec - shdr))
|
||||||
|
error("invalid section for opcode (%s:0x%x)", name, sym->st_shndx);
|
||||||
|
gen_code(func_name, demangled_name, sym->st_value, sym->st_size, outfile,
|
||||||
|
text, relocs, nb_relocs, 3, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fprintf(outfile, "#undef DEFINE_CST\n");
|
fprintf(outfile, "#undef DEFINE_CST\n");
|
||||||
fprintf(outfile, "#undef DEFINE_GEN\n");
|
fprintf(outfile, "#undef DEFINE_GEN\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user