diff options
author | midipix <writeonce@midipix.org> | 2016-04-29 12:04:31 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-04-29 19:22:30 -0400 |
commit | 0f5ca73f2949c3052e8935b2f70096a86f1ffcb1 (patch) | |
tree | 60daef375f8e436f1670b1c8e9044b2eb030a57d /src | |
parent | 2330a5df5438784e4764f7ad0f08f78c8b1a89c4 (diff) | |
download | slibtool-0f5ca73f2949c3052e8935b2f70096a86f1ffcb1.tar.bz2 slibtool-0f5ca73f2949c3052e8935b2f70096a86f1ffcb1.tar.xz |
link mode: added compatible -rpath support.
Diffstat (limited to 'src')
-rw-r--r-- | src/logic/slbt_exec_link.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index 63dd3c6..1c872be 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -88,6 +88,19 @@ static int slbt_get_deps_meta( char depfile[4*PATH_MAX]; char * deplibs = depfile; + /* -rpath */ + if ((size_t)snprintf(depfile,sizeof(depfile),"%s.slibtool.rpath", + libfilename) + >= sizeof(depfile)) + return -1; + + if (!(lstat(depfile,&st))) { + /* -Wl,%s */ + depsmeta->infolen += st.st_size + 4; + depsmeta->infolen++; + } + + /* .deps */ if ((size_t)snprintf(depfile,sizeof(depfile),"%s.slibtool.deps", libfilename) >= sizeof(depfile)) @@ -232,7 +245,10 @@ static int slbt_exec_link_adjust_argument_vector( int argc; char arg[PATH_MAX]; char lib[PATH_MAX]; + char rpathdir[PATH_MAX]; + char rpathlnk[PATH_MAX]; bool fwholearchive = false; + struct stat st; for (argc=0,carg=ectx->cargv; *carg; carg++) argc++; @@ -285,6 +301,23 @@ static int slbt_exec_link_adjust_argument_vector( /* ^^^hoppla^^^ */ *aarg++ = *carg++; } else { + /* -rpath */ + sprintf(rpathlnk,"%s.slibtool.rpath",*carg); + + if (!(lstat(rpathlnk,&st))) { + if (slbt_readlink( + rpathlnk,\ + rpathdir, + sizeof(rpathdir))) + return -1; + + sprintf(darg,"-Wl,%s",rpathdir); + *aarg++ = "-Wl,-rpath"; + *aarg++ = darg; + darg += strlen(darg); + darg++; + } + dpath = lib; freqd = true; sprintf(lib,"%s.slibtool.deps",*carg); @@ -685,6 +718,15 @@ static int slbt_exec_link_create_library( *ectx->lout[0] = "-o"; *ectx->lout[1] = output; + /* ldrpath */ + if (dctx->cctx->host.ldrpath) { + if (slbt_exec_link_remove_file(dctx,ectx,ectx->rpathfilename)) + return -1; + + if (symlink(dctx->cctx->host.ldrpath,ectx->rpathfilename)) + return -1; + } + /* cwd */ if (!getcwd(cwd,sizeof(cwd))) return -1; |