# HG changeset patch # User lost@l-w.ca # Date 1316128096 21600 # Node ID 606123758641f52ce632a2a589fb0b398402f2c8 # Parent 35f7ce3ef85776074526bfb3e633a07acdde8b90 Added --sysroot support to lwlink and the ld wrapper script diff -r 35f7ce3ef857 -r 606123758641 extra/ld --- a/extra/ld Fri Sep 09 22:08:07 2011 -0600 +++ b/extra/ld Thu Sep 15 17:08:16 2011 -0600 @@ -28,7 +28,13 @@ output_file=a.out libpaths= libs= +stdlibpaths="-L=/usr/local/lib -L=/usr/lib -L=/lib" verbose= + +if [ "$verbose" = 1 ]; then + echo "$0 $@" +fi + case $0 in *m6809-coco-*) options="--format=decb" @@ -101,6 +107,14 @@ --format-lwex) options="$options --format=lwex" ;; + + --sysroot=*) + options="$options $arg" + ;; + + -nostdlib) + stdlibpaths= + ;; -*) echo "ld (m6809): unknown option $arg" @@ -115,7 +129,7 @@ options="$options -o $output_file" if [ "$verbose" = "1" ]; then - echo "$path_to_lwlink $options $input_files $startup_files $libpaths $libs" + echo "$path_to_lwlink $options $input_files $startup_files $libpaths $stdlibpaths $libs" fi $path_to_lwlink $options $input_files $startup_files $libpaths $libs diff -r 35f7ce3ef857 -r 606123758641 lwlink/lwlink.c --- a/lwlink/lwlink.c Fri Sep 09 22:08:07 2011 -0600 +++ b/lwlink/lwlink.c Thu Sep 15 17:08:16 2011 -0600 @@ -49,6 +49,8 @@ int nscriptls = 0; char **scriptls = NULL; +char *sysroot = "/"; + void add_input_file(char *fn) { inputfiles = lw_realloc(inputfiles, sizeof(fileinfo_t *) * (ninputfiles + 1)); diff -r 35f7ce3ef857 -r 606123758641 lwlink/lwlink.h --- a/lwlink/lwlink.h Fri Sep 09 22:08:07 2011 -0600 +++ b/lwlink/lwlink.h Thu Sep 15 17:08:16 2011 -0600 @@ -120,6 +120,8 @@ extern char *map_file; +extern char *sysroot; + #define __lwlink_E__ extern #else #define __lwlink_E__ diff -r 35f7ce3ef857 -r 606123758641 lwlink/main.c --- a/lwlink/main.c Fri Sep 09 22:08:07 2011 -0600 +++ b/lwlink/main.c Thu Sep 15 17:08:16 2011 -0600 @@ -100,6 +100,10 @@ add_section_base(arg); break; + case 0x101: + sysroot = arg; + break; + case 'm': map_file = arg; break; @@ -134,6 +138,8 @@ "Add DIR to the library search path" }, { "section-base", 0x100, "SECT=BASE", 0, "Load section SECT at BASE" }, + { "sysroot", 0x101, "DIR", 0, + "Specify the path to replace an initial = with in library paths" }, { "map", 'm', "FILE", 0, "Output informaiton about the link" }, { 0 } diff -r 35f7ce3ef857 -r 606123758641 lwlink/readfiles.c --- a/lwlink/readfiles.c Fri Sep 09 22:08:07 2011 -0600 +++ b/lwlink/readfiles.c Thu Sep 15 17:08:16 2011 -0600 @@ -77,9 +77,19 @@ for (j = 0; j < nlibdirs; j++) { - s = strlen(libdirs[j]) + 7 + strlen(inputfiles[i] -> filename); - tf = lw_alloc(s + 1); - sprintf(tf, "%s/lib%s.a", libdirs[j], inputfiles[i] -> filename); + if (libdirs[j][0] == '=') + { + // handle sysroot + s = strlen(libdirs[j]) + 7 + strlen(sysroot) + strlen(inputfiles[i] -> filename); + tf = lw_alloc(s + 1); + sprintf(tf, "%s/%s/lib%s.a", sysroot, libdirs[j] + 1, inputfiles[i] -> filename); + } + else + { + s = strlen(libdirs[j]) + 7 + strlen(inputfiles[i] -> filename); + tf = lw_alloc(s + 1); + sprintf(tf, "%s/lib%s.a", libdirs[j], inputfiles[i] -> filename); + } f = fopen(tf, "rb"); if (!f) {