scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 72b972cb111d6e0469328a6134c1bad62e9a6880
parent f936910b6f7325ad57fe4306e5e4b9a5c3a85924
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 31 Mar 2019 11:10:12 +0100

[ld] Add debugsym()

This function helps to debug the current state of the symbols

Diffstat:
Msrc/cmd/ld/ld.h | 1+
Msrc/cmd/ld/symbol.c | 16++++++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/cmd/ld/ld.h b/src/cmd/ld/ld.h @@ -55,6 +55,7 @@ extern int newsym(struct objsym *osym, struct obj *obj); extern int moreundef(void); extern void listundef(void); extern int defasym(struct obj *obj); +extern int debugsym(void); /* globals */ extern char *filename, *membname; diff --git a/src/cmd/ld/symbol.c b/src/cmd/ld/symbol.c @@ -144,3 +144,19 @@ defasym(Obj *obj) return 0; } + +#ifndef NDEBUG +int +debugsym(void) +{ + Symbol **symp, *sym; + + for (symp = symtab; symp < &symtab[NR_SYMBOL]; symp++) { + for (sym = *symp; sym; sym = sym->hash) + fprintf(stderr, + "sym: %s (%#x)\n", + sym->name, + sym->value); + } +} +#endif