diff leo-obj/tool/richsym.c @ 208:f7943bdbb3ea

tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Fri, 04 Mar 2016 23:36:16 +0000
parents 15743b40e03a
children
line wrap: on
line diff
--- a/leo-obj/tool/richsym.c	Fri Jan 01 23:24:05 2016 +0000
+++ b/leo-obj/tool/richsym.c	Fri Mar 04 23:36:16 2016 +0000
@@ -1,6 +1,6 @@
 /*
  * Code for working with the "rich" symbolic info
- * present in TI's GPF libraries
+ * present in TI's GPF libraries and L1 objects
  */
 
 #include <sys/types.h>
@@ -417,7 +417,7 @@
 }
 
 static int
-localsym_sanity_check(sym)
+localsym_sanity_check_aux(sym)
 	struct internal_syment *sym;
 {
 	if (!sym->aux) {
@@ -425,6 +425,13 @@
 			sym->number, storage_class_to_string(sym->class, 0));
 		return(-1);
 	}
+	return(0);
+}
+
+static int
+localsym_sanity_check_scnum(sym)
+	struct internal_syment *sym;
+{
 	if (sym->scnum != -1) {
 		printf("; symbol #%u of class %s: section != ABS\n",
 			sym->number, storage_class_to_string(sym->class, 0));
@@ -433,6 +440,21 @@
 	return(0);
 }
 
+static int
+localsym_sanity_check(sym)
+	struct internal_syment *sym;
+{
+	int rc;
+
+	rc = localsym_sanity_check_aux(sym);
+	if (rc)
+		return(rc);
+	rc = localsym_sanity_check_scnum(sym);
+	if (rc)
+		return(rc);
+	return(0);
+}
+
 richsym_function_locals(headsym)
 	struct internal_syment *headsym;
 {
@@ -472,6 +494,56 @@
 				sym->value);
 			richsym_print_in_c("", sym, 0);
 			continue;
+		case C_STRTAG:
+		case C_UNTAG:
+		case C_ENTAG:
+			count++;
+			printf("; %s {", sym->struct_name_raw);
+			if (richsym_print_bitsize && sym->aux)
+				printf("\t/* %u bits */", get_u32(sym->aux+4));
+			putchar('\n');
+			continue;
+		case C_EOS:
+			count++;
+			fputs("; };", stdout);
+			if (richsym_print_bitsize && sym->aux)
+				printf("\t/* %u bits */", get_u32(sym->aux+4));
+			putchar('\n');
+			continue;
+		case C_MOS:
+		case C_MOU:
+			count++;
+			if (localsym_sanity_check(sym) < 0)
+				continue;
+			richsym_print_in_c(";   ", sym, 0);
+			continue;
+		case C_MOE:
+			count++;
+			if (localsym_sanity_check_scnum(sym) < 0)
+				continue;
+			if (sym->name[0] == '_')
+				printf(";   %s = %u;", sym->name + 1,
+					sym->value);
+			else
+				printf(";   \"%s\" = %u;", sym->name,
+					sym->value);
+			if (sym->value >= 10)
+				printf("\t/* 0x%x */", sym->value);
+			putchar('\n');
+			continue;
+		case C_TPDEF:
+			count++;
+			if (localsym_sanity_check_aux(sym) < 0)
+				continue;
+			richsym_print_in_c("; typedef ", sym,
+						!(sym->type & 0xFFF0));
+			continue;
+		case C_STAT:
+			count++;
+			if (localsym_sanity_check_aux(sym) < 0)
+				continue;
+			richsym_print_in_c("; static ", sym, 0);
+			continue;
 		case C_FCN:
 			return(count);
 		default: