commit 6fa227852ba779950f62c092c1a5bb6d20216afb
parent 44127ce7cb456a8ed9885416745a158db8aaddeb
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 23 Nov 2017 08:20:39 +0000
[as] Add a list for symbols
This list is needed to run over all the symbols
defined in the object file.
Diffstat:
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/as/as.h b/as/as.h
@@ -95,11 +95,11 @@ struct section {
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 Op optab[];
extern int pass;
extern TUINT maxaddr;
extern int endian;
-extern Symbol *linesym;
+extern Symbol *linesym, *symlist;
extern char *filename;
diff --git a/as/symbol.c b/as/symbol.c
@@ -41,7 +41,7 @@ int pass;
static Symbol *hashtbl[HASHSIZ];
static Alloc *tmpalloc;
-Symbol *linesym;
+Symbol *linesym, *symlist;
#ifndef NDEBUG
void
@@ -55,7 +55,7 @@ dumpstab(char *msg)
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 @@ lookup(char *name, int type)
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 @@ lookup(char *name, int type)
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 *