diff ticoff/symtab.c @ 78:c2445afce514

tiobjd: symbol storage classes decoded into mnemonics
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Wed, 26 Mar 2014 01:24:17 +0000
parents 590396e27e96
children 8f4996bff904
line wrap: on
line diff
--- a/ticoff/symtab.c	Tue Mar 25 22:47:51 2014 +0000
+++ b/ticoff/symtab.c	Wed Mar 26 01:24:17 2014 +0000
@@ -6,15 +6,66 @@
 #include <stdio.h>
 #include "filestruct.h"
 #include "intstruct.h"
+#include "coffconst.h"
 #include "globals.h"
 
+static struct classmap {
+	int	code;
+	char	*str;
+} classtab[] = {
+	{C_NULL, "NULL"},
+	{C_AUTO, "AUTO"},
+	{C_EXT, "EXT"},
+	{C_STAT, "STAT"},
+	{C_REG, "REG"},
+	{C_EXTREF, "EXTREF"},
+	{C_LABEL, "LABEL"},
+	{C_ULABEL, "ULABEL"},
+	{C_MOS, "MOS"},
+	{C_ARG, "ARG"},
+	{C_STRTAG, "STRTAG"},
+	{C_MOU, "MOU"},
+	{C_UNTAG, "UNTAG"},
+	{C_TPDEF, "TPDEF"},
+	{C_USTATIC, "USTATIC"},
+	{C_ENTAG, "ENTAG"},
+	{C_MOE, "MOE"},
+	{C_REGPARM, "REGPARM"},
+	{C_FIELD, "FIELD"},
+	{C_UEXT, "UEXT"},
+	{C_STATLAB, "STATLAB"},
+	{C_EXTLAB, "EXTLAB"},
+	{C_SYSTEM, "SYSTEM"},
+	{C_VARARG, "VARARG"},
+	{C_BLOCK, "BLOCK"},
+	{C_FCN, "FCN"},
+	{C_EOS, "EOS"},
+	{C_FILE, "FILE"},
+	{C_LINE, "LINE"},
+	{0, 0}
+};
+
+char *
+storage_class_to_string(code, numbuf)
+	char *numbuf;
+{
+	struct classmap *tp;
+
+	for (tp = classtab; tp->str; tp++)
+		if (tp->code == code)
+			return(tp->str);
+	sprintf(numbuf, "%d", code);
+	return(numbuf);
+}
+
 dump_symtab()
 {
 	unsigned n;
 	struct internal_syment *sym;
 	char *sec, secstr[8];
+	char *class, classbuf[8];
 
-	printf("%-5s %-24s %-4s %-5s %-12s %-8s\n",
+	printf("%-5s %-30s %-4s %-7s %-12s %-8s\n",
 		"Num", "Name", "Type", "Class", "Section", "Value");
 	for (n = 0; n < nsymtab; n++) {
 		sym = symtab[n];
@@ -26,8 +77,9 @@
 			sprintf(secstr, "%d", sym->scnum);
 			sec = secstr;
 		}
-		printf("%-5u %-24s %04X %-5d %-12s %08X%s\n",
-			n, sym->name, sym->type, sym->class,
+		class = storage_class_to_string(sym->class, classbuf);
+		printf("%-5u %-30s %04X %-7s %-12s %08X%s\n",
+			n, sym->name, sym->type, class,
 			sec, sym->value, sym->aux ? " Aux" : "");
 	}
 	return(0);