ref: 751095831f3fdd1004805a31342c6da6c6976eca
parent: eebf49a86e90ebb4493045c188fdd734cc7c6332
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed May 30 16:42:13 EDT 2018
[as] Add newsect() We need a list of segments to run over them and calculate the size base address of every segment.
--- a/ld/coff32.c
+++ b/ld/coff32.c
@@ -133,7 +133,7 @@
}
sym->size += p->s_size;
obj->sections[i] = sym;
-
+ newsect(sym);
}
return 0;
--- a/ld/ld.h
+++ b/ld/ld.h
@@ -26,6 +26,10 @@
struct obj *next, *prev;
};
+enum symflgs {
+ SSECT = 1 << 0,
+};
+
struct symbol {
char *name;
char type;
@@ -34,7 +38,7 @@
TUINT base;
TUINT value;
Obj *where;
- struct symbol *hash;
+ struct symbol *hash, *next;
};
struct objfmt {
@@ -48,6 +52,7 @@
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 */
--- a/ld/obj.c
+++ b/ld/obj.c
@@ -14,6 +14,7 @@
static Obj *objtail;
Symbol *sectlst;
+static Symbol *secttail;
static Symbol *symtbl[NR_SYM_HASH];
/*
@@ -87,6 +88,22 @@
}
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