shithub: scc

Download patch

ref: 4691d9aba548d25e59960b02334f98991a534a4c
parent: 2700167e6aa52cedc2fc267c0784817acc3b0687
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Feb 11 11:56:39 EST 2019

[ld] Store section description from object files

--- a/src/cmd/ld.c
+++ b/src/cmd/ld.c
@@ -30,6 +30,8 @@
 
 struct objlst {
 	Obj *obj;
+	int nsect;
+	Objsect *sect;
 	struct objlst *next;
 };
 
@@ -195,7 +197,9 @@
 static void
 loadobj(Obj *obj)
 {
+	int n;
 	Objlst *lst;
+	Objsect *secp;
 
 	if ((lst = malloc(sizeof(*lst))) == NULL) {
 		error("out of memory");
@@ -202,8 +206,15 @@
 		return;
 	}
 
+	if ((n = objsect(obj, &secp)) < 0) {
+		error("out of memory");
+		goto err1;
+	}
+
 	lst->obj = obj;
 	lst->next = NULL;
+	lst->nsect = n;
+	lst->sect = secp;
 
 	if (!objlast)
 		objlast = objhead = lst;
@@ -211,6 +222,11 @@
 		objlast = objlast->next = lst;
 
 	forsym(obj, newsym, obj);
+
+	return;
+
+err1:
+	free(lst);
 }
 
 static void