summaryrefslogtreecommitdiff
path: root/src/cmd/ld
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-06-30 23:31:27 -0700
committerRuss Cox <rsc@golang.org>2010-06-30 23:31:27 -0700
commit94a61eaf452acf5b9ac7fd24e5b1ac16bf03cc48 (patch)
treec0c2aab135ee32235cc1e035a8e6ff1298c1bb6f /src/cmd/ld
parentdbdbfcf74725a012a6b111697f31db87bc3d392a (diff)
downloadgolang-94a61eaf452acf5b9ac7fd24e5b1ac16bf03cc48.tar.gz
cgo: use slash-free relative paths for .so references
The Makefile and cgo now rewrite / to _ when creating the path. The .so for gosqlite.googlecode.com/hg/sqlite is named cgo_gosqlite.googlecode.com_hg_sqlite.so, and then 6l and 8l both include a default rpath of $GOROOT/pkg/$GOOS_$GOARCH. This should make it easier to move binaries from one system to another. Fixes issue 857. R=iant, r CC=golang-dev http://codereview.appspot.com/1700048
Diffstat (limited to 'src/cmd/ld')
-rw-r--r--src/cmd/ld/macho.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cmd/ld/macho.c b/src/cmd/ld/macho.c
index 3e33fe494..24400cf14 100644
--- a/src/cmd/ld/macho.c
+++ b/src/cmd/ld/macho.c
@@ -441,6 +441,7 @@ asmbmacho(vlong symdatva, vlong symo)
vlong v, w;
vlong va;
int a, i, ptrsize;
+ char *pkgroot;
MachoHdr *mh;
MachoSect *msect;
MachoSeg *ms;
@@ -584,6 +585,12 @@ asmbmacho(vlong symdatva, vlong symo)
ml->data[0] = 12; /* offset to string */
strcpy((char*)&ml->data[1], "/usr/lib/dyld");
+ if(ndylib > 0) { /* add reference to where .so files are installed */
+ pkgroot = smprint("%s/pkg/%s_%s", goroot, goos, goarch);
+ ml = newMachoLoad(0x80000000 | 0x1c, 1+(strlen(pkgroot)+1+7)/8*2); /* LC_RPATH */
+ ml->data[0] = 12; /* offset of string from beginning of load */
+ strcpy((char*)&ml->data[1], pkgroot);
+ }
for(i=0; i<ndylib; i++) {
ml = newMachoLoad(12, 4+(strlen(dylib[i])+1+7)/8*2); /* LC_LOAD_DYLIB */
ml->data[0] = 24; /* offset of string from beginning of load */