summaryrefslogtreecommitdiff
path: root/src/cmd/8l
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2010-02-26 14:03:52 -0800
committerIan Lance Taylor <iant@golang.org>2010-02-26 14:03:52 -0800
commitaf11b1b86dbe30e9a35fa3cd6c5b3775a3c74a31 (patch)
tree606c0a351c81516bc01bf3a74c04716e2ecabaea /src/cmd/8l
parent3e86f1a9b48d063a29ebf9fdfc84978f762f9b0e (diff)
downloadgolang-af11b1b86dbe30e9a35fa3cd6c5b3775a3c74a31.tar.gz
Add -r option to 6l/8l/5l.
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 http://codereview.appspot.com/223068
Diffstat (limited to 'src/cmd/8l')
-rw-r--r--src/cmd/8l/asm.c2
-rw-r--r--src/cmd/8l/doc.go2
-rw-r--r--src/cmd/8l/l.h1
-rw-r--r--src/cmd/8l/obj.c4
4 files changed, 8 insertions, 1 deletions
diff --git a/src/cmd/8l/asm.c b/src/cmd/8l/asm.c
index 005634e42..a1de5fc0e 100644
--- a/src/cmd/8l/asm.c
+++ b/src/cmd/8l/asm.c
@@ -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);
}
}
diff --git a/src/cmd/8l/doc.go b/src/cmd/8l/doc.go
index 3a830cb8e..c8c058684 100644
--- a/src/cmd/8l/doc.go
+++ b/src/cmd/8l/doc.go
@@ -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.
diff --git a/src/cmd/8l/l.h b/src/cmd/8l/l.h
index dd559e419..5940c4a73 100644
--- a/src/cmd/8l/l.h
+++ b/src/cmd/8l/l.h
@@ -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;
diff --git a/src/cmd/8l/obj.c b/src/cmd/8l/obj.c
index c3044c256..cd7984d71 100644
--- a/src/cmd/8l/obj.c
+++ b/src/cmd/8l/obj.c
@@ -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;