shithub: scc

Download patch

ref: e8065938a7c02560e8ab8f14d6e3b60774c0ad08
parent: c21c4a5a605800e23251b85c8a94a8873b144868
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Nov 1 07:46:08 EDT 2019

[ld] Link objects in a list

Objects were not linked, which meant that was impossible to run
over the list of object files. We insert at the end of a list
because it keeps the order in which the objects were discovered
in the command line.

--- a/src/cmd/ld/pass1.c
+++ b/src/cmd/ld/pass1.c
@@ -85,6 +85,7 @@
 	Obj *obj;
 	Section sec;
 	Symbol sym;
+	static Obj *last;
 
 	if ((t = objtype(fp, NULL)) < 0) {
 		error("bad format");
@@ -116,7 +117,10 @@
 	for ( i = 0; getsym(obj, &i, &sym); i++)
 		newsym(&sym, obj);
 
-	/* TODO: link the object */
+	obj->next = last;
+	last = obj;
+	if (!objhead)
+		objhead = obj;
 
 	return;