nm: understand the fact a U symbol may be segment constrained
authorAlan Cox <alan@linux.intel.com>
Sun, 29 Oct 2017 16:35:38 +0000 (16:35 +0000)
committerAlan Cox <alan@linux.intel.com>
Sun, 29 Oct 2017 16:35:38 +0000 (16:35 +0000)
Applications/MWC/cmd/asz80/nm.c

index c96be53..c9adf51 100644 (file)
@@ -9,6 +9,7 @@
 #include <unistd.h>
 #include <getopt.h>
 #include <stdint.h>
+#include <ctype.h>
 
 #include "obj.h"
 
@@ -18,7 +19,7 @@ static int show_debug = 1;
 static int show_name;
 static int show_undef;
 
-static char segname[] = "ATDB????????????";
+static char segname[] = "ATDB???????????U";
 
 static int do_nm(FILE *fp, const char *name)
 {
@@ -61,14 +62,15 @@ static int do_nm(FILE *fp, const char *name)
         addr = fgetc(fp);
         addr |= fgetc(fp) << 8;
         base += 2;
+        c = segname[type & S_SEGMENT];
         if (!(type & S_UNKNOWN)) {
-            c = segname[type & S_SEGMENT];
             /* Showing undefined only */
             if (show_undef)
                 continue;
         } else {
+            if (c != 'U')
+                c = tolower(c);
             addr = 0;
-            c = 'U';
         }
         printf("%04X %c %s\n", addr, c, symname);
     }