summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2014-07-01 08:41:45 +0000
committerTim Northover <tnorthover@apple.com>2014-07-01 08:41:45 +0000
commit9bdf90e5c29032cc2a74c32167d1e5b0b9a8d5f5 (patch)
tree091910445e3d81e7742a0b50e9094dc0171b7739
parent301c4e690a84d262125674f34d4b23a09649fdec (diff)
downloadbcm5719-llvm-9bdf90e5c29032cc2a74c32167d1e5b0b9a8d5f5.tar.gz
bcm5719-llvm-9bdf90e5c29032cc2a74c32167d1e5b0b9a8d5f5.zip
[mach-o]: make the default dylib install-name the output filename.
llvm-svn: 212094
-rw-r--r--lld/lib/Driver/DarwinLdDriver.cpp4
-rw-r--r--lld/test/mach-o/dylib-install-names.yaml17
2 files changed, 21 insertions, 0 deletions
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp
index c6678408768..6686caf14f7 100644
--- a/lld/lib/Driver/DarwinLdDriver.cpp
+++ b/lld/lib/Driver/DarwinLdDriver.cpp
@@ -191,6 +191,8 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
// Handle -o xxx
if (llvm::opt::Arg *outpath = parsedArgs->getLastArg(OPT_output))
ctx.setOutputPath(outpath->getValue());
+ else
+ ctx.setOutputPath("a.out");
// Handle -dead_strip
if (parsedArgs->getLastArg(OPT_dead_strip))
@@ -203,6 +205,8 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
// Handle -install_name
if (llvm::opt::Arg *installName = parsedArgs->getLastArg(OPT_install_name))
ctx.setInstallName(installName->getValue());
+ else
+ ctx.setInstallName(ctx.outputPath());
// Handle -mark_dead_strippable_dylib
if (parsedArgs->getLastArg(OPT_mark_dead_strippable_dylib))
diff --git a/lld/test/mach-o/dylib-install-names.yaml b/lld/test/mach-o/dylib-install-names.yaml
index 6a1c6c24bb2..05f268fcae7 100644
--- a/lld/test/mach-o/dylib-install-names.yaml
+++ b/lld/test/mach-o/dylib-install-names.yaml
@@ -1,7 +1,20 @@
+# Check we accept -install_name correctly:
# RUN: lld -flavor darwin -arch x86_64 -install_name libwibble.dylib -dylib %s -o %t.dylib
# RUN: macho-dump %t.dylib | FileCheck %s --check-prefix=CHECK-BINARY-WRITE
+
+# Check we read LC_ID_DYLIB correctly:
# RUN: lld -flavor darwin -arch x86_64 %p/Inputs/use-dylib-install-names.yaml %t.dylib -r -print_atoms | FileCheck %s --check-prefix=CHECK-BINARY-READ
+# Check we default the install-name to the output file:
+# RUN: lld -flavor darwin -arch x86_64 -dylib %s -o libwibble.dylib
+# RUN: macho-dump libwibble.dylib | FileCheck %s --check-prefix=CHECK-BINARY-WRITE
+# RUN: rm -f libwibble.dylib
+
+# Check the default output file is a.out, and this also goes into LC_ID_DYLIB.
+# RUN: lld -flavor darwin -arch x86_64 -dylib %s
+# RUN: macho-dump a.out | FileCheck %s --check-prefix=CHECK-BINARY-WRITE-AOUT
+# RUN: rm -f a.out
+
--- !mach-o
arch: x86_64
file-type: MH_OBJECT
@@ -36,6 +49,10 @@ global-symbols:
# CHECK-BINARY-WRITE-NEXT: ('size', 40)
# CHECK-BINARY-WRITE-NEXT: ('install_name', 'libwibble.dylib')
+# CHECK-BINARY-WRITE-AOUT: (('command', 13)
+# CHECK-BINARY-WRITE-AOUT-NEXT: ('size', 32)
+# CHECK-BINARY-WRITE-AOUT-NEXT: ('install_name', 'a.out')
+
# CHECK-BINARY-READ: shared-library-atoms:
# CHECK-BINARY-READ: - name: _myGlobal
# CHECK-BINARY-READ: load-name: libwibble.dylib
OpenPOWER on IntegriCloud