commit 29ccac8d84406c05b0b6a444da9daa597c7658f3
parent 0fed41f4804eb01cb3e9b2a532df0b4adc243261
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 30 May 2018 20:42:13 +0100
[as] Add newsect()
We need a list of segments to run over them and calculate the
size base address of every segment.
Diffstat:
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/ld/coff32.c b/ld/coff32.c
@@ -133,7 +133,7 @@ readsects(Obj *obj, long off)
}
sym->size += p->s_size;
obj->sections[i] = sym;
-
+ newsect(sym);
}
return 0;
diff --git a/ld/ld.h b/ld/ld.h
@@ -26,6 +26,10 @@ struct obj {
struct obj *next, *prev;
};
+enum symflgs {
+ SSECT = 1 << 0,
+};
+
struct symbol {
char *name;
char type;
@@ -34,7 +38,7 @@ struct symbol {
TUINT base;
TUINT value;
Obj *where;
- struct symbol *hash;
+ struct symbol *hash, *next;
};
struct objfmt {
@@ -48,6 +52,7 @@ extern Obj *newobj(char *fname, char *member, FILE *fp);
extern void delobj(Obj *obj);
extern void pop(Obj *obj);
extern void push(Obj *obj);
+extern void newsect(Symbol *sym);
extern Symbol *lookup(char *name);
/* main.c */
diff --git a/ld/obj.c b/ld/obj.c
@@ -14,6 +14,7 @@ Obj *objlst;
static Obj *objtail;
Symbol *sectlst;
+static Symbol *secttail;
static Symbol *symtbl[NR_SYM_HASH];
/*
@@ -89,6 +90,22 @@ newobj(char *fname, char *member, FILE *fp)
return obj;
}
+void
+newsect(Symbol *sym)
+{
+ if (sym->flags & SSECT)
+ return;
+
+ if (!sectlst) {
+ secttail = sectlst = sym;
+ } else {
+ secttail->next = sym;
+ secttail = sym;
+ }
+
+ sym->flags |= SSECT;
+}
+
static unsigned
hash(char *s)
{