scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 5407099465e7f5282aebcf438f2baa02fb90082c
parent 840644947a275f354a1872c6e788210e45304ea9
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu,  8 Aug 2019 00:06:30 +0100

[ld] Add ld() function

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

Diffstat:
Msrc/cmd/ld/main.c | 19+++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/cmd/ld/main.c b/src/cmd/ld/main.c @@ -53,6 +53,20 @@ cleanup(void) 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) { @@ -147,12 +161,9 @@ main(int argc, char *argv[]) if (argc == 0) usage(); - atexit(cleanup); - pass1(argc, argv); - pass2(argc, argv); - pass3(argc, argv); + ld(argc, argv); return status; }