changeset 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
files ticoff/Makefile ticoff/coffconst.h ticoff/symtab.c
diffstat 3 files changed, 87 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ticoff/Makefile	Tue Mar 25 22:47:51 2014 +0000
+++ b/ticoff/Makefile	Wed Mar 26 01:24:17 2014 +0000
@@ -2,7 +2,7 @@
 CFLAGS=	-O2
 PROG=	tiobjd
 OBJS=	basics.o globals.o lowlevel.o main.o symtab.o tables.o
-HDRS=	filestruct.h globals.h intstruct.h
+HDRS=	coffconst.h filestruct.h globals.h intstruct.h
 
 all:	${PROG}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ticoff/coffconst.h	Wed Mar 26 01:24:17 2014 +0000
@@ -0,0 +1,31 @@
+/********************** STORAGE CLASSES **********************/
+
+#define C_NULL		0
+#define C_AUTO		1	/* automatic variable		*/
+#define C_EXT		2	/* external symbol		*/
+#define C_STAT		3	/* static			*/
+#define C_REG		4	/* register variable		*/
+#define C_EXTREF	5	/* external reference 		*/
+#define C_LABEL		6	/* label			*/
+#define C_ULABEL	7	/* undefined label		*/
+#define C_MOS		8	/* member of structure		*/
+#define C_ARG		9	/* function argument		*/
+#define C_STRTAG	10	/* structure tag		*/
+#define C_MOU		11	/* member of union		*/
+#define C_UNTAG		12	/* union tag			*/
+#define C_TPDEF		13	/* type definition		*/
+#define C_USTATIC	14	/* undefined static		*/
+#define C_ENTAG		15	/* enumeration tag		*/
+#define C_MOE		16	/* member of enumeration	*/
+#define C_REGPARM	17	/* register parameter		*/
+#define C_FIELD		18	/* bit field			*/
+#define C_UEXT		19	/* Tentative external definition */
+#define C_STATLAB	20	/* Static load time label */
+#define C_EXTLAB	21	/* External load time label */
+#define C_SYSTEM	23	/* System Wide variable */
+#define	C_VARARG	27	/* from TI's spraao8.pdf */
+#define C_BLOCK		100	/* ".bb" or ".eb"		*/
+#define C_FCN		101	/* ".bf" or ".ef"		*/
+#define C_EOS		102	/* end of structure		*/
+#define C_FILE		103	/* file name			*/
+#define C_LINE		104	/* line # reformatted as symbol table entry */
--- 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);