Skip to content

Commit a779dc3

Browse files
[PS5][Driver] Supply default linker scripts (llvm#114546)
Until now, this has been hardcoded as a downstream patch in lld. Add it to the driver so that the private patch can be removed. PS5 only. On PS4, the equivalent hardcoded configuration will remain in the proprietary linker. SIE tracker: TOOLCHAIN-16704
1 parent de87dda commit a779dc3

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

clang/lib/Driver/ToolChains/PS4CPU.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,16 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
293293
"dead-reloc-in-nonalloc=.debug_ranges=0xfffffffffffffffe");
294294
CmdArgs.push_back("-z");
295295
CmdArgs.push_back("dead-reloc-in-nonalloc=.debug_loc=0xfffffffffffffffe");
296+
297+
// The PlayStation loader expects linked objects to be laid out in a
298+
// particular way. This is achieved by linker scripts that are supplied
299+
// with the SDK. The scripts are inside <sdkroot>/target/lib, which is
300+
// added as a search path elsewhere.
301+
// "PRX" has long stood for "PlayStation Relocatable eXecutable".
302+
CmdArgs.push_back("--default-script");
303+
CmdArgs.push_back(Static ? "static.script"
304+
: Shared ? "prx.script"
305+
: "main.script");
296306
}
297307

298308
if (Static)

clang/test/Driver/ps5-linker.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@
6666
// CHECK-NO-EXE-NOT: "--unresolved-symbols
6767
// CHECK-NO-EXE-NOT: "-z"
6868

69+
// Test that an appropriate linker script is supplied by the driver.
70+
71+
// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-SCRIPT -DSCRIPT=main %s
72+
// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-SCRIPT -DSCRIPT=prx %s
73+
// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck --check-prefixes=CHECK-SCRIPT -DSCRIPT=static %s
74+
// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-SCRIPT %s
75+
76+
// CHECK-SCRIPT: {{ld(\.exe)?}}"
77+
// CHECK-SCRIPT-SAME: "--default-script" "[[SCRIPT]].script"
78+
79+
// CHECK-NO-SCRIPT: {{ld(\.exe)?}}"
80+
// CHECK-NO-SCRIPT-NOT: "--default-script"
81+
6982
// Test that -static is forwarded to the linker
7083

7184
// RUN: %clang --target=x86_64-sie-ps5 -static %s -### 2>&1 | FileCheck --check-prefixes=CHECK-STATIC %s

0 commit comments

Comments
 (0)