# HG changeset patch # User Michael Spacefalcon # Date 1398757888 0 # Node ID df01a4f4c2726213ff596e3564667ba6c0a89d1b # Parent fdf3137c703ab4ca7bf242c4da56e07789252d7d tiobjd disasm -g: dump of function locals implemented diff -r fdf3137c703a -r df01a4f4c272 leo-obj/tool/disasm.c --- a/leo-obj/tool/disasm.c Tue Apr 29 07:11:33 2014 +0000 +++ b/leo-obj/tool/disasm.c Tue Apr 29 07:51:28 2014 +0000 @@ -97,6 +97,8 @@ } if (sym->class == C_FCN && !strcmp(sym->name, ".bf")) { printf("; Begin function\n"); + if (disasm_richsym) + richsym_function_locals(sym); return; } switch (sym->class) { diff -r fdf3137c703a -r df01a4f4c272 leo-obj/tool/richsym.c --- a/leo-obj/tool/richsym.c Tue Apr 29 07:11:33 2014 +0000 +++ b/leo-obj/tool/richsym.c Tue Apr 29 07:51:28 2014 +0000 @@ -203,7 +203,19 @@ char *buf; int isund, len; - isund = (sym->name[0] == '_'); + switch (sym->name[0]) { + case '_': + isund = 1; + break; + case '$': + if ((sym->type & 0x30) == 0x20) + isund = 1; + else + isund = 0; + break; + default: + isund = 0; + } len = strlen(sym->name) + 1; if (isund) len--; @@ -396,3 +408,70 @@ } exit(0); } + +static int +localsym_sanity_check(sym) + struct internal_syment *sym; +{ + if (!sym->aux) { + printf("; symbol #%u of class %s has no aux record\n", + sym->number, storage_class_to_string(sym->class, 0)); + return(-1); + } + if (sym->scnum != -1) { + printf("; symbol #%u of class %s: section != ABS\n", + sym->number, storage_class_to_string(sym->class, 0)); + return(-1); + } + return(0); +} + +void +richsym_function_locals(headsym) + struct internal_syment *headsym; +{ + unsigned n; + struct internal_syment *sym; + char classbuf[8]; + + for (n = headsym->number + 1; n < nsymtab; n++) { + sym = symtab[n]; + if (!sym) + continue; + switch (sym->class) { + case C_REG: + case C_REGPARM: + if (localsym_sanity_check(sym) < 0) + continue; + if (sym->value > 0xF) { + printf( + "; symbol #%u of class %s: value is not a valid register number\n", + sym->number, + storage_class_to_string(sym->class, 0)); + continue; + } + printf("; %s r%u: ", + storage_class_to_string(sym->class, 0), + sym->value); + richsym_print_in_c("", sym, 0); + continue; + case C_ARG: + case C_AUTO: + if (localsym_sanity_check(sym) < 0) + continue; + printf("; %s at 0x%x: ", + storage_class_to_string(sym->class, 0), + sym->value); + richsym_print_in_c("", sym, 0); + continue; + case C_FCN: + return; + default: + printf( + "; presumed local symbol #%u: unexpected class %s\n", + sym->number, + storage_class_to_string(sym->class, classbuf)); + return; + } + } +}