shithub: scc

Download patch

ref: d69fcbb76aac150d3e8a2fef26ef405010e5f4f5
parent: 050797f4780ad8b7737975cfe9a60d52d4bc67a4
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Mar 31 07:10:12 EDT 2019

[ld] Add debugsym()

This function helps to debug the current state of the symbols

--- a/src/cmd/ld/ld.h
+++ b/src/cmd/ld/ld.h
@@ -55,6 +55,7 @@
 extern int moreundef(void);
 extern void listundef(void);
 extern int defasym(struct obj *obj);
+extern int debugsym(void);
 
 /* globals */
 extern char *filename, *membname;
--- a/src/cmd/ld/symbol.c
+++ b/src/cmd/ld/symbol.c
@@ -144,3 +144,19 @@
 
 	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