# HG changeset patch # User lost@l-w.ca # Date 1324602119 25200 # Node ID c6a38fd8bd337546faa4a0b0d83d95993c5b41fc # Parent e0cc66fd05515bed7e2735555ff551bd8d58a0f1 Added --entry option for lwlink diff -r e0cc66fd0551 -r c6a38fd8bd33 lwlink/lwlink.c --- a/lwlink/lwlink.c Wed Sep 21 21:14:09 2011 -0600 +++ b/lwlink/lwlink.c Thu Dec 22 18:01:59 2011 -0700 @@ -51,6 +51,8 @@ char *sysroot = "/"; +char *entrysym = NULL; + void add_input_file(char *fn) { inputfiles = lw_realloc(inputfiles, sizeof(fileinfo_t *) * (ninputfiles + 1)); diff -r e0cc66fd0551 -r c6a38fd8bd33 lwlink/lwlink.h --- a/lwlink/lwlink.h Wed Sep 21 21:14:09 2011 -0600 +++ b/lwlink/lwlink.h Thu Dec 22 18:01:59 2011 -0700 @@ -109,6 +109,7 @@ extern int ninputfiles; extern fileinfo_t **inputfiles; extern char *scriptfile; +extern char *entrysym; extern int nlibdirs; extern char **libdirs; diff -r e0cc66fd0551 -r c6a38fd8bd33 lwlink/main.c --- a/lwlink/main.c Wed Sep 21 21:14:09 2011 -0600 +++ b/lwlink/main.c Thu Dec 22 18:01:59 2011 -0700 @@ -55,6 +55,11 @@ // debug debug_level++; break; + + case 'e': + // entry symbol + entrysym = arg; + break; case 'b': // decb output @@ -138,6 +143,8 @@ "Add DIR to the library search path" }, { "section-base", 0x100, "SECT=BASE", 0, "Load section SECT at BASE" }, + { "entry", 'e', "SYM", 0, + "Specify SYM as program entry point" }, { "sysroot", 0x101, "DIR", 0, "Specify the path to replace an initial = with in library paths" }, { "map", 'm', "FILE", 0, diff -r e0cc66fd0551 -r c6a38fd8bd33 lwlink/script.c --- a/lwlink/script.c Wed Sep 21 21:14:09 2011 -0600 +++ b/lwlink/script.c Thu Dec 22 18:01:59 2011 -0700 @@ -326,4 +326,25 @@ if (scriptfile || nscriptls) lw_free(oscript); + + if (entrysym) + { + int eaddr; + char *ptr2; + + lw_free(linkscript.execsym); + + eaddr = strtol(entrysym, &ptr2, 0); + if (*ptr2) + { + linkscript.execaddr = -1; + linkscript.execsym = lw_strdup(entrysym); + } + else + { + linkscript.execaddr = eaddr; + linkscript.execsym = NULL; + } + + } }