-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lld] load rpaths from tbd files #134925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lld] load rpaths from tbd files #134925
Conversation
@llvm/pr-subscribers-lld Author: Richard Howell (rmaz) ChangesTBD files can contain rpaths, add support for setting them in DylibFile during construction. Full diff: https://github.com/llvm/llvm-project/pull/134925.diff 2 Files Affected:
diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 9adfbc9d3f6f5..97b3ed8eb537d 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -1879,6 +1879,8 @@ DylibFile::DylibFile(const InterfaceFile &interface, DylibFile *umbrella,
installName = saver().save(interface.getInstallName());
compatibilityVersion = interface.getCompatibilityVersion().rawValue();
currentVersion = interface.getCurrentVersion().rawValue();
+ for (auto rpath : interface.rpaths())
+ rpaths.push_back(saver().save(rpath.second));
if (config->printEachFile)
message(toString(this));
diff --git a/lld/test/MachO/tapi-rpath.s b/lld/test/MachO/tapi-rpath.s
new file mode 100644
index 0000000000000..48032f28a6ce6
--- /dev/null
+++ b/lld/test/MachO/tapi-rpath.s
@@ -0,0 +1,87 @@
+# REQUIRES: aarch64, shell
+# RUN: rm -rf %t; split-file %s %t
+# RUN: ln -s Versions/A/Developer %t/Developer/Library/Frameworks/Developer.framework/
+# RUN: ln -s Versions/A/DeveloperCore %t/Developer/Library/PrivateFrameworks/DeveloperCore.framework/
+# RUN: llvm-mc -filetype obj -triple arm64-apple-macos11.0 %t/test.s -o %t/test.o
+# RUN: %lld -arch arm64 -platform_version macos 11.0 11.0 -o %t/test -framework Developer -F %t/Developer/Library/Frameworks %t/test.o
+
+# RUN: llvm-objdump --bind --no-show-raw-insn -d %t/test | FileCheck %s
+# CHECK: Bind table:
+# CHECK-DAG: __DATA __data {{.*}} pointer 0 Developer _funcPublic
+# CHECK-DAG: __DATA __data {{.*}} pointer 0 Developer _funcCore
+
+#--- Developer/Library/Frameworks/Developer.framework/Versions/A/Developer
+{
+ "tapi_tbd_version": 5,
+ "main_library": {
+ "target_info": [
+ {
+ "target": "arm64-macos"
+ }
+ ],
+ "install_names": [
+ {
+ "name": "@rpath/Developer.framework/Versions/A/Developer"
+ }
+ ],
+ "rpaths": [
+ {
+ "paths": [
+ "@loader_path/../../../../PrivateFrameworks/"
+ ]
+ }
+ ],
+ "reexported_libraries": [
+ {
+ "names": [
+ "@rpath/DeveloperCore.framework/Versions/A/DeveloperCore"
+ ]
+ }
+ ],
+ "exported_symbols": [
+ {
+ "text": {
+ "global": ["_funcPublic"]
+ }
+ }
+ ]
+ }
+}
+#--- Developer/Library/PrivateFrameworks/DeveloperCore.framework/Versions/A/DeveloperCore
+{
+ "tapi_tbd_version": 5,
+ "main_library": {
+ "target_info": [
+ {
+ "target": "arm64-macos"
+ }
+ ],
+ "install_names": [
+ {
+ "name": "@rpath/DeveloperCore.framework/Versions/A/DeveloperCore"
+ }
+ ],
+ "allowable_clients": [
+ {
+ "clients": ["Developer"]
+ }
+ ],
+ "exported_symbols": [
+ {
+ "text": {
+ "global": ["_funcCore"]
+ }
+ }
+ ]
+ }
+}
+#--- test.s
+.text
+.globl _main
+
+_main:
+ ret
+
+.data
+ .quad _funcPublic
+ .quad _funcCore
|
@llvm/pr-subscribers-lld-macho Author: Richard Howell (rmaz) ChangesTBD files can contain rpaths, add support for setting them in DylibFile during construction. Full diff: https://github.com/llvm/llvm-project/pull/134925.diff 2 Files Affected:
diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 9adfbc9d3f6f5..97b3ed8eb537d 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -1879,6 +1879,8 @@ DylibFile::DylibFile(const InterfaceFile &interface, DylibFile *umbrella,
installName = saver().save(interface.getInstallName());
compatibilityVersion = interface.getCompatibilityVersion().rawValue();
currentVersion = interface.getCurrentVersion().rawValue();
+ for (auto rpath : interface.rpaths())
+ rpaths.push_back(saver().save(rpath.second));
if (config->printEachFile)
message(toString(this));
diff --git a/lld/test/MachO/tapi-rpath.s b/lld/test/MachO/tapi-rpath.s
new file mode 100644
index 0000000000000..48032f28a6ce6
--- /dev/null
+++ b/lld/test/MachO/tapi-rpath.s
@@ -0,0 +1,87 @@
+# REQUIRES: aarch64, shell
+# RUN: rm -rf %t; split-file %s %t
+# RUN: ln -s Versions/A/Developer %t/Developer/Library/Frameworks/Developer.framework/
+# RUN: ln -s Versions/A/DeveloperCore %t/Developer/Library/PrivateFrameworks/DeveloperCore.framework/
+# RUN: llvm-mc -filetype obj -triple arm64-apple-macos11.0 %t/test.s -o %t/test.o
+# RUN: %lld -arch arm64 -platform_version macos 11.0 11.0 -o %t/test -framework Developer -F %t/Developer/Library/Frameworks %t/test.o
+
+# RUN: llvm-objdump --bind --no-show-raw-insn -d %t/test | FileCheck %s
+# CHECK: Bind table:
+# CHECK-DAG: __DATA __data {{.*}} pointer 0 Developer _funcPublic
+# CHECK-DAG: __DATA __data {{.*}} pointer 0 Developer _funcCore
+
+#--- Developer/Library/Frameworks/Developer.framework/Versions/A/Developer
+{
+ "tapi_tbd_version": 5,
+ "main_library": {
+ "target_info": [
+ {
+ "target": "arm64-macos"
+ }
+ ],
+ "install_names": [
+ {
+ "name": "@rpath/Developer.framework/Versions/A/Developer"
+ }
+ ],
+ "rpaths": [
+ {
+ "paths": [
+ "@loader_path/../../../../PrivateFrameworks/"
+ ]
+ }
+ ],
+ "reexported_libraries": [
+ {
+ "names": [
+ "@rpath/DeveloperCore.framework/Versions/A/DeveloperCore"
+ ]
+ }
+ ],
+ "exported_symbols": [
+ {
+ "text": {
+ "global": ["_funcPublic"]
+ }
+ }
+ ]
+ }
+}
+#--- Developer/Library/PrivateFrameworks/DeveloperCore.framework/Versions/A/DeveloperCore
+{
+ "tapi_tbd_version": 5,
+ "main_library": {
+ "target_info": [
+ {
+ "target": "arm64-macos"
+ }
+ ],
+ "install_names": [
+ {
+ "name": "@rpath/DeveloperCore.framework/Versions/A/DeveloperCore"
+ }
+ ],
+ "allowable_clients": [
+ {
+ "clients": ["Developer"]
+ }
+ ],
+ "exported_symbols": [
+ {
+ "text": {
+ "global": ["_funcCore"]
+ }
+ }
+ ]
+ }
+}
+#--- test.s
+.text
+.globl _main
+
+_main:
+ ret
+
+.data
+ .quad _funcPublic
+ .quad _funcCore
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
d51729a
to
ce79202
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that Windows failure must be pre-existing.
TBD files can contain rpaths, add support for setting them in DylibFile during construction.
TBD files can contain rpaths, add support for setting them in DylibFile during construction.
TBD files can contain rpaths, add support for setting them in DylibFile during construction.