summaryrefslogtreecommitdiffstats
path: root/lld/lib/Driver/DarwinLdDriver.cpp
diff options
context:
space:
mode:
authorJean-Daniel Dupas <devlists@shadowlab.org>2014-12-18 21:33:38 +0000
committerJean-Daniel Dupas <devlists@shadowlab.org>2014-12-18 21:33:38 +0000
commit23dd15e26d81c3230e7dc7b184a5dc8e37e8f3bb (patch)
treeb01942ecb8283f26d86804fb8a8282c310166503 /lld/lib/Driver/DarwinLdDriver.cpp
parentf27ae736175a3cc339af15ffc8ad3cb518224c0c (diff)
downloadbcm5719-llvm-23dd15e26d81c3230e7dc7b184a5dc8e37e8f3bb.tar.gz
bcm5719-llvm-23dd15e26d81c3230e7dc7b184a5dc8e37e8f3bb.zip
[macho] -rpath support
Summary: Work on adding -rpath support to the mach-o linker. This patch is based on the ld64 behavior for the command line option validation. It includes a basic test to check that the LC_RPATH load commands are properly generated when that option is used. It also add LC_RPATH support to the binary reader, but I don't know how to test it though. Reviewers: kledzik Subscribers: llvm-commits Projects: #lld Differential Revision: http://reviews.llvm.org/D6724 llvm-svn: 224544
Diffstat (limited to 'lld/lib/Driver/DarwinLdDriver.cpp')
-rw-r--r--lld/lib/Driver/DarwinLdDriver.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp
index 6c80c5c8e65..754c8ac18b7 100644
--- a/lld/lib/Driver/DarwinLdDriver.cpp
+++ b/lld/lib/Driver/DarwinLdDriver.cpp
@@ -709,6 +709,34 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
}
}
+ // Handle -rpath <path>
+ if (parsedArgs->hasArg(OPT_rpath)) {
+ switch (ctx.outputMachOType()) {
+ case llvm::MachO::MH_EXECUTE:
+ case llvm::MachO::MH_DYLIB:
+ case llvm::MachO::MH_BUNDLE:
+ if (!ctx.minOS("10.5", "2.0")) {
+ if (ctx.os() == MachOLinkingContext::OS::macOSX) {
+ diagnostics << "error: -rpath can only be used when targeting "
+ "OS X 10.5 or later\n";
+ } else {
+ diagnostics << "error: -rpath can only be used when targeting "
+ "iOS 2.0 or later\n";
+ }
+ return false;
+ }
+ break;
+ default:
+ diagnostics << "error: -rpath can only be used when creating "
+ "a dynamic final linked image\n";
+ return false;
+ }
+
+ for (auto rPath : parsedArgs->filtered(OPT_rpath)) {
+ ctx.addRpath(rPath->getValue());
+ }
+ }
+
// Handle input files
for (auto &arg : *parsedArgs) {
bool upward;
OpenPOWER on IntegriCloud