]> Cypherpunks repositories - gostls13.git/commitdiff
Add -r option to 6l/8l/5l.
authorIan Lance Taylor <iant@golang.org>
Fri, 26 Feb 2010 22:03:52 +0000 (14:03 -0800)
committerIan Lance Taylor <iant@golang.org>
Fri, 26 Feb 2010 22:03:52 +0000 (14:03 -0800)
This permits more flexibility with cgo and swig in cases where
the program is run on a machine other than the one on which it
is built.  Rather than storing the absolute path to the shared
library in the DT_NEEDED entry, we can store just the name,
and let the dynamic linker find it using DT_RUNPATH or the
LD_LIBRARY_PATH environment variable.

R=rsc
CC=golang-dev
https://golang.org/cl/223068

12 files changed:
src/cmd/5l/asm.c
src/cmd/5l/doc.go
src/cmd/5l/l.h
src/cmd/5l/obj.c
src/cmd/6l/asm.c
src/cmd/6l/doc.go
src/cmd/6l/l.h
src/cmd/6l/obj.c
src/cmd/8l/asm.c
src/cmd/8l/doc.go
src/cmd/8l/l.h
src/cmd/8l/obj.c

index 143a4076d1ac63b7af959e46a16ac5d2bf7c7672..2a9265a885c28dff868eb1309160b70eef55f09e 100644 (file)
@@ -322,6 +322,8 @@ doelf(void)
                elfwritedynentsym(s, DT_REL, lookup(".rel", 0));
                elfwritedynentsymsize(s, DT_RELSZ, lookup(".rel", 0));
                elfwritedynent(s, DT_RELENT, ELF32RELSIZE);
+               if(rpath)
+                       elfwritedynent(s, DT_RUNPATH, addstring(dynstr, rpath));
                elfwritedynent(s, DT_NULL, 0);
        }
 }
index b724e7012ff4b79d4e97a8744173dd903e7f7b0d..b09995d719f92b0ca038a9b21a3c781736fe4740 100644 (file)
@@ -23,6 +23,8 @@ Options new in this version:
 -L dir1,dir2,..
        Search for libraries (package files) in the comma-separated list of directories.
        The default is the single location $GOROOT/pkg/$GOOS_arm.
+-r dir1:dir2:...
+       Set the dynamic linker search path when using ELF.
 -V
        Print the linker version.
 
index 9a54122a71ebc860487f2fa5bbd4b936df752d96..ac627e456be3b09d530bb24bd51e13bcea06521c 100644 (file)
@@ -333,6 +333,7 @@ EXTERN      Oprang  thumboprange[ALAST];
 EXTERN char*   outfile;
 EXTERN int32   pc;
 EXTERN uchar   repop[ALAST];
+EXTERN char*   rpath;
 EXTERN uint32  stroffset;
 EXTERN int32   symsize;
 EXTERN Prog*   textp;
index 9f7aa19c33d8cdde0dad995517101af022b0f49b..06a84eeace48aa591615a83819a84301dc34af90 100644 (file)
@@ -81,7 +81,7 @@ linkername[] =
 void
 usage(void)
 {
-       fprint(2, "usage: 5l [-E entry] [-H head] [-L dir] [-T text] [-D data] [-R rnd] [-o out] main.5\n");
+       fprint(2, "usage: 5l [-E entry] [-H head] [-L dir] [-T text] [-D data] [-R rnd] [-r path] [-o out] main.5\n");
        errorexit();
 }
 
@@ -128,6 +128,9 @@ main(int argc, char *argv[])
        case 'R':
                INITRND = atolwhex(EARGF(usage()));
                break;
+       case 'r':
+               rpath = EARGF(usage());
+               break;
        case 'H':
                HEADTYPE = atolwhex(EARGF(usage()));
                /* do something about setting INITTEXT */
index d3f3e358bfdeb4be29eafd8f270e1e4c1afc9ef1..d55c0cee4d4dade50394a4601021870edc0514d9 100644 (file)
@@ -408,6 +408,8 @@ doelf(void)
                elfwritedynentsym(s, DT_RELA, lookup(".rela", 0));
                elfwritedynentsymsize(s, DT_RELASZ, lookup(".rela", 0));
                elfwritedynent(s, DT_RELAENT, ELF64RELASIZE);
+               if(rpath)
+                       elfwritedynent(s, DT_RUNPATH, addstring(dynstr, rpath));
                elfwritedynent(s, DT_NULL, 0);
        }
 }
index fb88df500d1a933c520ae4f7f442bb78996e5a54..a74e9b5c0ccfb654dbfb9db9c06dac9c8a0a25aa 100644 (file)
@@ -35,6 +35,8 @@ Options new in this version:
 -L dir1,dir2,..
        Search for libraries (package files) in the comma-separated list of directories.
        The default is the single location $GOROOT/pkg/$GOOS_amd64.
+-r dir1:dir2:...
+       Set the dynamic linker search path when using ELF.
 -V
        Print the linker version.
 
index be1aa41781b514e09ac1bb4f7f5b0d6d55ae81ac..87b81d7f6db0e468da4991c14824e5fb0f583d7c 100644 (file)
@@ -330,6 +330,7 @@ EXTERN      int     nerrors;
 EXTERN char*   noname;
 EXTERN char*   outfile;
 EXTERN vlong   pc;
+EXTERN char*   rpath;
 EXTERN int32   spsize;
 EXTERN Sym*    symlist;
 EXTERN int32   symsize;
index d95169697802aff338a448b46f38d10a97fd188a..b75f8bea28a9ca5de24954234a71acfd42718978 100644 (file)
@@ -76,7 +76,7 @@ isobjfile(char *f)
 void
 usage(void)
 {
-       fprint(2, "usage: 6l [-options] [-E entry] [-H head] [-L dir] [-T text] [-R rnd] [-o out] main.6\n");
+       fprint(2, "usage: 6l [-options] [-E entry] [-H head] [-L dir] [-T text] [-R rnd] [-r path] [-o out] main.6\n");
        exits("usage");
 }
 
@@ -126,6 +126,9 @@ main(int argc, char *argv[])
        case 'R':
                INITRND = atolwhex(EARGF(usage()));
                break;
+       case 'r':
+               rpath = EARGF(usage());
+               break;
        case 'x':       /* produce export table */
                doexp = 1;
                if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1]))
index 005634e42992fbcecb92b85654a6da037537c7b7..a1de5fc0e3ff36750343357b3b6fde20efd3dca9 100644 (file)
@@ -398,6 +398,8 @@ doelf(void)
                elfwritedynentsym(s, DT_REL, lookup(".rel", 0));
                elfwritedynentsymsize(s, DT_RELSZ, lookup(".rel", 0));
                elfwritedynent(s, DT_RELENT, ELF32RELSIZE);
+               if(rpath)
+                       elfwritedynent(s, DT_RUNPATH, addstring(dynstr, rpath));
                elfwritedynent(s, DT_NULL, 0);
        }
 }
index 3a830cb8e12b0ad4a0a925abc26ba65d7c553d69..c8c05868469c7e0b5b669130e182c4abf12b67b1 100644 (file)
@@ -32,6 +32,8 @@ Options new in this version:
 -L dir1,dir2,..
        Search for libraries (package files) in the comma-separated list of directories.
        The default is the single location $GOROOT/pkg/$GOOS_386.
+-r dir1:dir2:...
+       Set the dynamic linker search path when using ELF.
 -V
        Print the linker version.
 
index dd559e419595ca7be8d88cb9c491f17199b16218..5940c4a7333c4dc6e9c987e69beba9f299ad5596 100644 (file)
@@ -295,6 +295,7 @@ EXTERN      int     maxop;
 EXTERN int     nerrors;
 EXTERN char*   noname;
 EXTERN int32   pc;
+EXTERN char*   rpath;
 EXTERN int32   spsize;
 EXTERN Sym*    symlist;
 EXTERN int32   symsize;
index c3044c2561f84f7bffc0d32005e8b44c7608cf95..cd7984d7158264e11252f4fc44a53ba8cbf0e2c0 100644 (file)
@@ -81,7 +81,7 @@ isobjfile(char *f)
 void
 usage(void)
 {
-       fprint(2, "usage: 8l [-options] [-E entry] [-H head] [-L dir] [-T text] [-R rnd] [-o out] main.8\n");
+       fprint(2, "usage: 8l [-options] [-E entry] [-H head] [-L dir] [-T text] [-R rnd] [-r path] [-o out] main.8\n");
        exits("usage");
 }
 
@@ -131,6 +131,8 @@ main(int argc, char *argv[])
        case 'R':
                INITRND = atolwhex(EARGF(usage()));
                break;
+       case 'r':
+               rpath = EARGF(usage());
                break;
        case 'x':       /* produce export table */
                doexp = 1;