Skip to content

Commit 4b267bb

Browse files
authored
[lld] load rpaths from tbd files (#134925)
TBD files can contain rpaths, add support for setting them in DylibFile during construction.
1 parent 15428e0 commit 4b267bb

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

lld/MachO/InputFiles.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,9 @@ DylibFile::DylibFile(const InterfaceFile &interface, DylibFile *umbrella,
18791879
installName = saver().save(interface.getInstallName());
18801880
compatibilityVersion = interface.getCompatibilityVersion().rawValue();
18811881
currentVersion = interface.getCurrentVersion().rawValue();
1882+
for (const auto &rpath : interface.rpaths())
1883+
if (rpath.first == config->platformInfo.target)
1884+
rpaths.push_back(saver().save(rpath.second));
18821885

18831886
if (config->printEachFile)
18841887
message(toString(this));

lld/test/MachO/tapi-rpath.s

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# REQUIRES: aarch64, shell
2+
# RUN: rm -rf %t; split-file %s %t
3+
# RUN: ln -s Versions/A/Developer %t/Developer/Library/Frameworks/Developer.framework/
4+
# RUN: ln -s Versions/A/DeveloperCore %t/Developer/Library/PrivateFrameworks/DeveloperCore.framework/
5+
# RUN: llvm-mc -filetype obj -triple arm64-apple-macos11.0 %t/test.s -o %t/test.o
6+
# RUN: %lld -arch arm64 -platform_version macos 11.0 11.0 -o %t/test -framework Developer -F %t/Developer/Library/Frameworks %t/test.o
7+
8+
# RUN: llvm-objdump --bind --no-show-raw-insn -d %t/test | FileCheck %s
9+
# CHECK: Bind table:
10+
# CHECK-DAG: __DATA __data {{.*}} pointer 0 Developer _funcPublic
11+
# CHECK-DAG: __DATA __data {{.*}} pointer 0 Developer _funcCore
12+
13+
#--- Developer/Library/Frameworks/Developer.framework/Versions/A/Developer
14+
{
15+
"tapi_tbd_version": 5,
16+
"main_library": {
17+
"target_info": [
18+
{
19+
"target": "arm64-macos"
20+
}
21+
],
22+
"install_names": [
23+
{
24+
"name": "@rpath/Developer.framework/Versions/A/Developer"
25+
}
26+
],
27+
"rpaths": [
28+
{
29+
"paths": [
30+
"@loader_path/../../../../PrivateFrameworks/"
31+
]
32+
}
33+
],
34+
"reexported_libraries": [
35+
{
36+
"names": [
37+
"@rpath/DeveloperCore.framework/Versions/A/DeveloperCore"
38+
]
39+
}
40+
],
41+
"exported_symbols": [
42+
{
43+
"text": {
44+
"global": ["_funcPublic"]
45+
}
46+
}
47+
]
48+
}
49+
}
50+
#--- Developer/Library/PrivateFrameworks/DeveloperCore.framework/Versions/A/DeveloperCore
51+
{
52+
"tapi_tbd_version": 5,
53+
"main_library": {
54+
"target_info": [
55+
{
56+
"target": "arm64-macos"
57+
}
58+
],
59+
"install_names": [
60+
{
61+
"name": "@rpath/DeveloperCore.framework/Versions/A/DeveloperCore"
62+
}
63+
],
64+
"allowable_clients": [
65+
{
66+
"clients": ["Developer"]
67+
}
68+
],
69+
"exported_symbols": [
70+
{
71+
"text": {
72+
"global": ["_funcCore"]
73+
}
74+
}
75+
]
76+
}
77+
}
78+
#--- test.s
79+
.text
80+
.globl _main
81+
82+
_main:
83+
ret
84+
85+
.data
86+
.quad _funcPublic
87+
.quad _funcCore

0 commit comments

Comments
 (0)