shithub: scc

Download patch

ref: 5744901a952c06af18e06e5ac6989202b56c50f4
parent: e8065938a7c02560e8ab8f14d6e3b60774c0ad08
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Nov 1 07:52:19 EDT 2019

[ld] Cleanup section.c

There were some old and dirty code in section.c after the last changes.

--- a/src/cmd/ld/Makefile
+++ b/src/cmd/ld/Makefile
@@ -10,7 +10,7 @@
 	section.o\
 	pass1.o\
 	pass2.o \
-#       pass3.o \
+	pass3.o \
 #       pass4.o \
 #       pass5.o \
 
--- a/src/cmd/ld/pass3.c
+++ b/src/cmd/ld/pass3.c
@@ -45,7 +45,6 @@
 pass3(int argc, char *argv[])
 {
 	Obj *obj;
-	Objlst *lst;
 	Objsec *sp;
 	Segment *seg;
 
@@ -57,8 +56,7 @@
 	data.base = rodata.base + rodata.size;
 	bss.base = data.base + data.size;
 
-	for (lst = objhead; lst; lst = lst->next) {
-		obj = lst->obj;
+	for (obj = objhead; obj; obj = obj->next) {
 		for (sp = obj->secs; sp; sp = sp->next) {
 			switch (sp->type) {
 			case 'T':
--- a/src/cmd/ld/section.c
+++ b/src/cmd/ld/section.c
@@ -26,19 +26,6 @@
 static struct sectab *sectab[NR_SECTION];
 static struct sectab secs = {.next = &secs, .prev = &secs};
 
-static Section *
-linksec(struct sectab *lst, Section *sec)
-{
-	struct sectab *sp = (struct sectab *) sec;
-
-	sp->next = lst;
-	sp->prev = lst->prev;
-	lst->prev->next = sp;
-	lst->prev = sp;
-
-	return sec;
-}
-
 Section *
 lookupsec(char *name)
 {
@@ -70,7 +57,7 @@
 	sec->align = 0;
 	sec->index = 0;
 	sec->flags = 0;
-	sp->tmpfp;
+	sp->tmpfp = NULL;
 	sp->hash = sectab[h];
 	sectab[h] = sp;