[lld] 8601be8 - [lld-macho] Fix & fold reexport-nested-libs test into stub-link.s
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 4 11:37:10 PST 2021
Author: Jez Ng
Date: 2021-03-04T14:36:46-05:00
New Revision: 8601be809e12a234bbd6264b1a1d37dba2acbe28
URL: https://github.com/llvm/llvm-project/commit/8601be809e12a234bbd6264b1a1d37dba2acbe28
DIFF: https://github.com/llvm/llvm-project/commit/8601be809e12a234bbd6264b1a1d37dba2acbe28.diff
LOG: [lld-macho] Fix & fold reexport-nested-libs test into stub-link.s
The reexport-nested-libs test added in D97438 was a bit wonky.
First, it was linking against libReexportSystem.tbd which targets the
iOS simulator, and which in turn attempted to re-export the iOS
simulator's libSystem. However, due to the way `-syslibroot` works, it
was actually re-exporting the macOS libSystem.
As a result, the test was not actually able to resolve the symbols in
the desired libSystem. I'm guessing that @oontvoo was confused by this
and therefore included those symbols in libReexportSystem.tbd itself.
But this means that the test wasn't actually testing the resolution of
re-exported symbols (though it did at least verify that the re-exported
libraries could be located).
After some consideration, I figured that stub-link.s could be extended
to cover what reexport-nested-libs.s was attempting to do. The test
targets macOS, so we only have one `-syslibroot` and no chance of
confusion.
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D97866
Added:
lld/test/MachO/Inputs/libReexportSystem.tbd
Modified:
lld/MachO/InputFiles.cpp
lld/test/MachO/Inputs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.tbd
lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libSystem.tbd
lld/test/MachO/stub-link.s
Removed:
lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libReexportSystem.tbd
lld/test/MachO/reexport-nested-lib.s
################################################################################
diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index d754568406a3..7c35999582c8 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -576,9 +576,9 @@ findDylib(StringRef path, DylibFile *umbrella,
if (currentTopLevelTapi) {
for (InterfaceFile &child :
make_pointee_range(currentTopLevelTapi->documents())) {
+ assert(child.documents().empty());
if (path == child.getInstallName())
return make<DylibFile>(child, umbrella);
- assert(child.documents().empty());
}
}
diff --git a/lld/test/MachO/Inputs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.tbd b/lld/test/MachO/Inputs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.tbd
index ef122e667281..643dff44bde4 100644
--- a/lld/test/MachO/Inputs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.tbd
+++ b/lld/test/MachO/Inputs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.tbd
@@ -11,3 +11,4 @@ exports:
objc-classes: [ NSObject ]
objc-ivars: [ NSConstantArray._count ]
objc-eh-types: [ NSException ]
+...
diff --git a/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libSystem.tbd b/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libSystem.tbd
index 529bb608d8a2..4c9641f3af2c 100644
--- a/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libSystem.tbd
+++ b/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libSystem.tbd
@@ -6,7 +6,7 @@ install-name: '/usr/lib/libSystem.dylib'
current-version: 1281
exports:
- archs: [ i386, x86_64 ]
- re-exports: [ '/usr/lib/system/libcache.dylib', ]
+ re-exports: [ '/usr/lib/system/libcache.dylib' ]
symbols: [ __crashreporter_info__, _cache_create ]
--- !tapi-tbd-v3
archs: [ i386, x86_64 ]
diff --git a/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libReexportSystem.tbd b/lld/test/MachO/Inputs/libReexportSystem.tbd
similarity index 68%
rename from lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libReexportSystem.tbd
rename to lld/test/MachO/Inputs/libReexportSystem.tbd
index c0fa06bcc8a4..dd857493f441 100644
--- a/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libReexportSystem.tbd
+++ b/lld/test/MachO/Inputs/libReexportSystem.tbd
@@ -1,10 +1,9 @@
--- !tapi-tbd-v3
archs: [ i386, x86_64 ]
uuids: [ 'i386: 00000000-0000-0000-0000-000000000000', 'x86_64: 00000000-0000-0000-0000-000000000001' ]
-platform: ios
+platform: macosx
install-name: '/usr/lib/libReexportSystem.dylib'
exports:
- archs: [ i386, x86_64 ]
- re-exports: [ '/usr/lib/libSystem' ]
- symbols: [ __crashreporter_info__, _cache_create ]
-
+ re-exports: [ '/usr/lib/libSystem.dylib' ]
+...
diff --git a/lld/test/MachO/reexport-nested-lib.s b/lld/test/MachO/reexport-nested-lib.s
deleted file mode 100644
index c6e8c19d2b63..000000000000
--- a/lld/test/MachO/reexport-nested-lib.s
+++ /dev/null
@@ -1,28 +0,0 @@
-# REQUIRES: x86
-#
-# This tests that we can reference symbols from a dylib,
-# re-exported by a top-level tapi document, which itself is
-# re-exported by another top-level tapi document.
-#
-# RUN: rm -rf %t; mkdir -p %t
-# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %s -o %t/test.o
-# RUN: %lld -o %t/test -syslibroot %S/Inputs/iPhoneSimulator.sdk -lReexportSystem %t/test.o
-# RUN: llvm-objdump %t/test --macho --bind %t/test | FileCheck %s
-
-# CHECK: segment section address type addend dylib symbol
-# CHECK: __DATA __data 0x{{[0-9a-f]*}} pointer 0 libReexportSystem __crashreporter_info__
-# CHECK: __DATA __data 0x{{[0-9a-f]*}} pointer 0 libReexportSystem _cache_create
-
-.text
-.globl _main
-
-_main:
- ret
-
-.data
-// This symbol is from libSystem, which is re-exported by libReexportSystem.
-// Reference it here to verify that it is visible.
-.quad __crashreporter_info__
-
-// This symbol is from /usr/lib/system/libcache.dylib, which is re-exported in libSystem.
-.quad _cache_create
diff --git a/lld/test/MachO/stub-link.s b/lld/test/MachO/stub-link.s
index 8d34e958bbbe..c83c149d5b83 100644
--- a/lld/test/MachO/stub-link.s
+++ b/lld/test/MachO/stub-link.s
@@ -3,10 +3,16 @@
# RUN: mkdir -p %t
#
# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %s -o %t/test.o
+
# RUN: %lld -o %t/test -lSystem -lc++ -framework CoreFoundation %t/test.o
-#
# RUN: llvm-objdump --bind --no-show-raw-insn -d -r %t/test | FileCheck %s
+## libReexportSystem.tbd tests that we can reference symbols from a dylib,
+## re-exported by a top-level tapi document, which itself is re-exported by
+## another top-level tapi document.
+# RUN: %lld -o %t/with-reexport %S/Inputs/libReexportSystem.tbd -lc++ -framework CoreFoundation %t/test.o
+# RUN: llvm-objdump --bind --no-show-raw-insn -d -r %t/with-reexport | FileCheck %s
+
# CHECK: Disassembly of section __TEXT,__text:
# CHECK: movq {{.*}} # [[ADDR:[0-9a-f]+]]
@@ -21,6 +27,9 @@
# RUN: llvm-objdump --macho --all-headers %t/test | \
# RUN: FileCheck --check-prefix=LOAD %s
+# RUN: llvm-objdump --macho --all-headers %t/with-reexport | \
+# RUN: FileCheck --check-prefixes=LOAD,LOAD-REEXPORT %s
+
# LOAD: cmd LC_LOAD_DYLIB
# LOAD-NEXT: cmdsize
# LOAD-NEXT: name /usr/lib/libSystem.dylib
@@ -28,6 +37,13 @@
# LOAD-NEXT: current version 1.1.1
# LOAD-NEXT: compatibility version
+# LOAD-REEXPORT: cmd LC_LOAD_DYLIB
+# LOAD-REEXPORT-NEXT: cmdsize
+# LOAD-REEXPORT-NEXT: name /usr/lib/libReexportSystem.dylib
+# LOAD-REEXPORT-NEXT: time stamp
+# LOAD-REEXPORT-NEXT: current version 1.0.0
+# LOAD-REEXPORT-NEXT: compatibility version
+
.section __TEXT,__text
.global _main
More information about the llvm-commits
mailing list