ref: e119c49880f616f781206c4bca93a6a684fc61ff
parent: 5744901a952c06af18e06e5ac6989202b56c50f4
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Nov 2 14:10:46 EDT 2019
[ld] Remove the double linked list for sections It doesn't add anything and the work can be done in a simpler way using a single linked list.
--- a/src/cmd/ld/section.c
+++ b/src/cmd/ld/section.c
@@ -20,11 +20,11 @@
Section sec;
FILE *tmpfp;
struct sectab *hash;
- struct sectab *next, *prev;
+ struct sectab *next;
};
static struct sectab *sectab[NR_SECTION];
-static struct sectab secs = {.next = &secs, .prev = &secs};
+static struct sectab *secs;
Section *
lookupsec(char *name)
@@ -60,12 +60,9 @@
sp->tmpfp = NULL;
sp->hash = sectab[h];
sectab[h] = sp;
+ sp->next = secs;
+ secs = sp;
- sp->next = &secs;
- sp->prev = secs.prev;
- secs.prev->next = sp;
- secs.prev = sp;
-
return sec;
}
@@ -76,7 +73,7 @@
Section *sec, **p;
int n = 0;
- for (sp = secs.next; sp != &secs; sp = sp->next) {
+ for (sp = secs; sp; sp = sp->next) {
sec = &sp->sec;
if (sec->type != seg->type)
continue;