shithub: scc

Download patch

ref: f804aedceaa0393ee3e8bf79dd58f6fe83a046c3
parent: 4ca822523b4538c4267bdd8604fd6a71c7e6aca8
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Feb 3 17:03:23 EST 2018

[nm] Add correct type of symbols

--- a/inc/myro.h
+++ b/inc/myro.h
@@ -63,6 +63,13 @@
 	MYROSYM_ABS    = 1 << 4,
 };
 
+enum myrosectnames {
+	MYRO_TEXT = 0,
+	MYRO_DATA = 1,
+	MYRO_BSS  = 2,
+	MYRO_ABS  = 3,
+};
+
 extern int wrmyrohdr(FILE *fp, struct myrohdr *hdr);
 extern int wrmyrosec(FILE *fp, struct myrosect *sect);
 extern int wrmyrosym(FILE *fp, struct myrosym *sym);
--- a/nm/main.c
+++ b/nm/main.c
@@ -1,5 +1,6 @@
 static char sccsid[] = "@(#) ./nm/main.c";
 
+#include <ctype.h>
 #include <errno.h>
 #include <limits.h>
 #include <stdint.h>
@@ -66,7 +67,30 @@
 static int
 typeof(struct myrosym *sym)
 {
-	return 'U';
+	int t, flags = sym->flags;
+
+	switch (sym->section) {
+	case MYRO_TEXT:
+		t = 't';
+		break;
+	case MYRO_DATA:
+		t = 'd';
+		break;
+	case MYRO_BSS:
+		t = (flags & MYROSYM_COMMON) ? 'c' : 'b';
+		break;
+	case MYRO_ABS:
+		t = 'a';
+		break;
+	default:
+		t = (flags & MYROSYM_UNDEF) ? 'u' : '?';
+		break;
+	}
+	if (flags & MYROSYM_ABS)
+		t = 'a';
+	if (flags & MYROSYM_EXTERN)
+		t = tolower(t);
+	return t;
 }
 
 static void