shithub: scc

Download patch

ref: 8f241ba283b03cd4dffcd8bc1753bb3f500949f5
parent: 3c75d277b5d0bdbaff7de7d7c3a9c07a6638b75e
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Aug 7 20:06:30 EDT 2019

[ld] Add ld() function

This function encapsulates the actual work of the linker and
isolates it from the parsing work done in main.

--- a/src/cmd/ld/main.c
+++ b/src/cmd/ld/main.c
@@ -53,7 +53,21 @@
 		remove(output);
 }
 
+/*
+ * pass1: Get the list of object files that are going to be linked.
+ * pass2: Calculate the size of every segment.
+ * pass3: Rebase all symbols in sections
+ */
 static void
+ld(int argc, char*argv[])
+{
+	pass1(argc, argv);
+	pass2(argc, argv);
+	pass3(argc, argv);
+	debugsym();
+}
+
+static void
 usage(void)
 {
 	fputs("usage: ld [options] file ...\n", stderr);
@@ -147,12 +161,9 @@
 
 	if (argc == 0)
 		usage();
-
 	atexit(cleanup);
 
-	pass1(argc, argv);
-	pass2(argc, argv);
-	pass3(argc, argv);
+	ld(argc, argv);
 
 	return status;
 }