<div dir="ltr">On Tue, Sep 3, 2013 at 1:45 PM, Joerg Sonnenberger <span dir="ltr"><<a href="mailto:joerg@bec.de" target="_blank">joerg@bec.de</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: joerg<br>
Date: Tue Sep 3 15:45:09 2013<br>
New Revision: 189847<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=189847&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=189847&view=rev</a><br>
Log:<br>
Finish -rpath implementation to actually create the DT_RPATH entries.<br>
<br>
Modified:<br>
lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h<br>
lld/trunk/lib/Driver/GnuLdDriver.cpp<br>
lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h<br>
lld/trunk/test/elf/dynamic.test<br>
<br>
Modified: lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=189847&r1=189846&r2=189847&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=189847&r1=189846&r2=189847&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h (original)<br>
+++ lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h Tue Sep 3 15:45:09 2013<br>
@@ -180,6 +180,14 @@ public:<br>
_sysrootPath = path;<br>
}<br>
<br>
+ void addRpath(StringRef path) {<br>
+ _rpathList.push_back(path);<br>
+ }<br>
+<br>
+ range<const StringRef *> getRpathList() const {<br>
+ return _rpathList;<br>
+ }<br>
+<br>
private:<br>
ELFLinkingContext() LLVM_DELETED_FUNCTION;<br>
<br>
@@ -213,6 +221,7 @@ protected:<br>
StringRefVector _initFunctions;<br>
StringRefVector _finiFunctions;<br>
StringRef _sysrootPath;<br>
+ StringRefVector _rpathList;<br>
};<br>
} // end namespace lld<br>
<br>
<br>
Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=189847&r1=189846&r2=189847&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=189847&r1=189846&r2=189847&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)<br>
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Tue Sep 3 15:45:09 2013<br>
@@ -289,6 +289,14 @@ bool GnuLdDriver::parse(int argc, const<br>
break;<br>
}<br>
<br>
+ case OPT_rpath: {<br>
+ SmallVector<StringRef, 2> rpaths;<br>
+ StringRef(inputArg->getValue()).split(rpaths, ":");<br>
+ for (auto path : rpaths)<br>
+ ctx->addRpath(path);<br>
+ break;<br>
+ }<br></blockquote><div><br></div><div>Well, you missed my comments as to splitting by ":" may not make much sense? Or if it makes sense you should have replied so.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
case OPT_sysroot:<br>
ctx->setSysroot(inputArg->getValue());<br>
break;<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h?rev=189847&r1=189846&r2=189847&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h?rev=189847&r1=189846&r2=189847&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h Tue Sep 3 15:45:09 2013<br>
@@ -160,6 +160,15 @@ void OutputELFWriter<ELFT>::buildDynamic<br>
dyn.d_un.d_val = _dynamicStringTable->addString(loadName.getKey());<br>
_dynamicTable->addEntry(dyn);<br>
}<br>
+ const auto &rpathList = _context.getRpathList();<br>
+ if (!rpathList.empty()) {<br>
+ auto rpath = new (_alloc) std::string(join(rpathList.begin(),<br>
+ rpathList.end(), ":"));<br>
+ Elf_Dyn dyn;<br>
+ dyn.d_tag = DT_RPATH;<br>
+ dyn.d_un.d_val = _dynamicStringTable->addString(*rpath);<br>
+ _dynamicTable->addEntry(dyn);<br>
+ }<br>
// The dynamic symbol table need to be sorted earlier because the hash<br>
// table needs to be built using the dynamic symbol table. It would be<br>
// late to sort the symbols due to that in finalize. In the dynamic symbol<br>
<br>
Modified: lld/trunk/test/elf/dynamic.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/dynamic.test?rev=189847&r1=189846&r2=189847&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/dynamic.test?rev=189847&r1=189846&r2=189847&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/elf/dynamic.test (original)<br>
+++ lld/trunk/test/elf/dynamic.test Tue Sep 3 15:45:09 2013<br>
@@ -1,6 +1,7 @@<br>
# Checks functionality of dynamic executables<br>
RUN: lld -flavor gnu -target x86_64-linux %p/Inputs/use-shared.x86-64 \<br>
-RUN: %p/Inputs/shared.so-x86-64 -o %t -e main --allow-shlib-undefined<br>
+RUN: %p/Inputs/shared.so-x86-64 -o %t -e main --allow-shlib-undefined \<br>
+RUN: -rpath /l1:/l2 -rpath /l3<br>
RUN: lld -flavor gnu -target x86_64-linux %p/Inputs/use-shared.x86-64 \<br>
RUN: %p/Inputs/shared.so-x86-64 -emit-yaml -o %t2 --allow-shlib-undefined \<br>
RUN: --noinhibit-exec<br>
@@ -59,7 +60,7 @@ CHECK-NEXT: Binding: Global<br>
CHECK-NEXT: Type: Function<br>
CHECK: }<br>
<br>
-CHECK: DynamicSection [ (14 entries)<br>
+CHECK: DynamicSection [ (15 entries)<br>
CHECK: Tag Type Name/Value<br>
CHECK: 0x0000000000000004 HASH<br>
CHECK: 0x0000000000000005 STRTAB<br>
@@ -74,5 +75,6 @@ CHECK: 0x0000000000000003 PLTGOT<br>
CHECK: 0x0000000000000014 PLTREL RELA<br>
CHECK: 0x0000000000000017 JMPREL<br>
CHECK: 0x0000000000000001 NEEDED SharedLibrary (shared.so-x86-64)<br>
+CHECK: 0x000000000000000F RPATH /l1:/l2:/l3<br>
CHECK: 0x0000000000000000 NULL 0x0<br>
CHECK: ]<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>