shithub: scc

Download patch

ref: 3d8ea19c9a097c23e1a55774653909b5ba0d6997
parent: 85fb4f175cc3404aebdd9d690cc3c616a9833cef
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Jan 19 10:15:56 EST 2020

ld: Simplify newsec()

--- a/src/cmd/ld/pass1.c
+++ b/src/cmd/ld/pass1.c
@@ -41,25 +41,26 @@
 	unsigned long long base;
 
 	sec = lookupsec(osec->name);
-	if (sec->type != 'U') {
+	if (sec->type == 'U') {
+		sec->type = osec->type;
+		sec->base = osec->base;
+		sec->size = osec->size;
+		sec->flags = osec->flags;
+		align = 0;
+	} else {
 		if (sec->type != osec->type
 		|| sec->flags != osec->flags
-		|| sec->base != osec->base
 		|| sec->align != osec->align) {
-			error("incompatible definition of section %s", sec->name);
+			error("incompatible definition of section %s",
+			      sec->name);
 			return;
 		}
 		align = osec->align;
 		align -= sec->size & align-1;
 		grow(sec, align);
-		rebase(obj, osec->index,  sec->size);
-	} else {
-		sec->type = osec->type;
-		sec->base = osec->base;
-		sec->size = osec->size;
-		sec->flags = osec->flags;
 	}
 
+	rebase(obj, osec->index, sec->size);
 	copy(obj, osec, sec);
 }