FreeCalypso > hg > freecalypso-reveng
diff objgrep/dumpmatch.c @ 173:77cd647375e5
objgrep -r: dump symbols in other sections recovered through relocs
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 04 Jul 2014 06:34:33 +0000 |
parents | 452baa748747 |
children |
line wrap: on
line diff
--- a/objgrep/dumpmatch.c Fri Jul 04 03:22:41 2014 +0000 +++ b/objgrep/dumpmatch.c Fri Jul 04 06:34:33 2014 +0000 @@ -69,12 +69,11 @@ return(dest); } -dump_relocs_on_match() +process_relocs_on_match() { unsigned n, value; struct internal_reloc *rel; - printf("\nDeduced from relocs:\n\n"); for (n = 0, rel = relocs; n < grep_section->nreloc; n++, rel++) { switch (rel->type) { case RTYPE_LONG: @@ -93,15 +92,51 @@ abort(); } value -= rel->addend; - if (rel->secbase) - printf("%s:%s = %08X\n", objfilename, - rel->secbase->name, value); - else if (rel->extsym) - printf("%s = %08X\n", rel->extsym->name, value); - else { - fprintf(stderr, - "BUG in dump_relocs_on_match(): no base for reloc\n"); - abort(); + rel->symvalue = value; + if (rel->secbase) { + if (!rel->secbase->recov_flag) { + rel->secbase->recov_flag = 1; + rel->secbase->recov_addr = value; + } else if (rel->secbase->recov_addr != value) + printf("Multiple addresses for %s:%s: %08X, %08X\n", + objfilename, rel->secbase->name, + rel->secbase->recov_addr, value); } } } + +dump_ext_relocs_on_match() +{ + unsigned n; + struct internal_reloc *rel; + + printf("\nExternals deduced from relocs:\n\n"); + for (n = 0, rel = relocs; n < grep_section->nreloc; n++, rel++) + if (rel->extsym) + printf("%s = %08X\n", rel->extsym->name, rel->symvalue); +} + +dump_reloc_symtab_on_match() +{ + unsigned n; + struct internal_syment *sym; + + printf("\nThis module's symbols deduced from section relocs:\n\n"); + for (n = 0; n < nsymtab; n++) { + sym = symtab[n]; + if (!sym || !sym->section) + continue; + if (!sym->section->recov_flag) + continue; + switch (sym->class) { + case C_EXT: + printf("%s = %08X\n", sym->name, + sym->value + sym->section->recov_addr); + continue; + case C_STAT: + printf("%s:%s = %08X\n", objfilename, sym->name, + sym->value + sym->section->recov_addr); + continue; + } + } +}