ref: 03364b67869bdfc077933d481624896c87986bb9
parent: 4534415354538af9795b3387baac108ead851aab
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Nov 23 03:20:39 EST 2017
[as] Add a list for symbols This list is needed to run over all the symbols defined in the object file.
--- a/as/as.h
+++ b/as/as.h
@@ -95,11 +95,11 @@
struct symbol {
String name;
unsigned char flags;
- char pass;
- char argtype;
- short desc;
+ unsigned char pass;
+ unsigned char argtype;
TUINT value;
struct symbol *next;
+ struct symbol *hash;
};
struct node {
@@ -154,5 +154,5 @@
extern int pass;
extern TUINT maxaddr;
extern int endian;
-extern Symbol *linesym;
+extern Symbol *linesym, *symlist;
extern char *filename;
--- a/as/symbol.c
+++ b/as/symbol.c
@@ -41,7 +41,7 @@
static Symbol *hashtbl[HASHSIZ];
static Alloc *tmpalloc;
-Symbol *linesym;
+Symbol *linesym, *symlist;
#ifndef NDEBUG
void
@@ -55,7 +55,7 @@
continue;
fprintf(stderr, "[%d]", (int) (bp - hashtbl));
- for (sym = *bp; sym; sym = sym->next) {
+ for (sym = *bp; sym; sym = sym->hash) {
fprintf(stderr, " -> %s:%0X:%0X",
sym->name.buf, sym->flags, sym->argtype);
}
@@ -79,7 +79,7 @@
c = toupper(*name);
list = &hashtbl[h];
- for (sym = *list; sym; sym = sym->next) {
+ for (sym = *list; sym; sym = sym->hash) {
t = sym->name.buf;
if (c != toupper(*t) || casecmp(t, name))
continue;
@@ -92,12 +92,11 @@
sym = xmalloc(sizeof(*sym));
sym->name = newstring(name);
sym->flags = FLOCAL | FUNDEF | type;
- sym->desc = 0;
sym->value = 0;
- sym->next = *list;
- *list = sym;
+ sym->hash = *list;
+ sym->next = symlist;
- return sym;
+ return symlist = *list = sym;
}
Symbol *