scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 075f12ca9418f5a5e37bdf4893d865f3697c25ed
parent f118bda209b47d84d74d5e5fe50b1f97d9a368d4
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat,  3 Feb 2018 22:03:23 +0100

[nm] Add correct type of symbols

Diffstat:
Minc/myro.h | 7+++++++
Mnm/main.c | 26+++++++++++++++++++++++++-
2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/inc/myro.h b/inc/myro.h @@ -63,6 +63,13 @@ enum myrosymflg { 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); diff --git 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 @@ cmp(const void *p1, const void *p2) 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