Skip to content

Commit a393c92

Browse files
[PS5][Driver] Update default linking options when -r omitted. (#113595)
Until now, these options have been hardcoded as downstream patches in lld. Add them to the driver so that the private patches can be removed. PS5 only. On PS4, the proprietary linker will continue to perform the equivalent behaviours itself. SIE tracker: TOOLCHAIN-16704
1 parent dfb60bb commit a393c92

File tree

2 files changed

+40
-15
lines changed

2 files changed

+40
-15
lines changed

clang/lib/Driver/ToolChains/PS4CPU.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,20 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
250250
CmdArgs.push_back("-pie");
251251

252252
if (!Relocatable) {
253+
CmdArgs.push_back("--eh-frame-hdr");
254+
CmdArgs.push_back("--hash-style=sysv");
255+
256+
// Add a build-id by default to allow the PlayStation symbol server to
257+
// index the symbols. `uuid` is the cheapest fool-proof method.
258+
// (The non-determinism and alternative methods are noted in the downstream
259+
// PlayStation docs).
260+
CmdArgs.push_back("--build-id=uuid");
261+
262+
// All references are expected to be resolved at static link time for both
263+
// executables and dynamic libraries. This has been the default linking
264+
// behaviour for numerous PlayStation generations.
265+
CmdArgs.push_back("--unresolved-symbols=report-all");
266+
253267
// Lazy binding of PLTs is not supported on PlayStation. They are placed in
254268
// the RelRo segment.
255269
CmdArgs.push_back("-z");

clang/test/Driver/ps5-linker.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,32 @@
1414
// CHECK-NO-PIE-NOT: "-pie"
1515
// CHECK-SHARED: "--shared"
1616

17-
// Test the driver passes PlayStation-specific -z options to the linker.
18-
19-
// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-Z %s
20-
21-
// CHECK-Z: {{ld(\.exe)?}}"
22-
// CHECK-Z-SAME: "-z" "now"
23-
// CHECK-Z-SAME: "-z" "start-stop-visibility=hidden"
24-
// CHECK-Z-SAME: "-z" "dead-reloc-in-nonalloc=.debug_*=0xffffffffffffffff"
25-
// CHECK-Z-SAME: "-z" "dead-reloc-in-nonalloc=.debug_ranges=0xfffffffffffffffe"
26-
// CHECK-Z-SAME: "-z" "dead-reloc-in-nonalloc=.debug_loc=0xfffffffffffffffe"
27-
28-
// RUN: %clang --target=x86_64-sie-ps5 -r %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-Z %s
29-
30-
// CHECK-NO-Z: {{ld(\.exe)?}}"
31-
// CHECK-NO-Z-NOT: "-z"
17+
// Test the driver passes PlayStation-specific options to the linker that are
18+
// appropriate for the type of output. Many options don't apply for relocatable
19+
// output (-r).
20+
21+
// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-EXE %s
22+
// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-EXE %s
23+
// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck --check-prefixes=CHECK-EXE %s
24+
// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-EXE %s
25+
26+
// CHECK-EXE: {{ld(\.exe)?}}"
27+
// CHECK-EXE-SAME: "--eh-frame-hdr"
28+
// CHECK-EXE-SAME: "--hash-style=sysv"
29+
// CHECK-EXE-SAME: "--build-id=uuid"
30+
// CHECK-EXE-SAME: "--unresolved-symbols=report-all"
31+
// CHECK-EXE-SAME: "-z" "now"
32+
// CHECK-EXE-SAME: "-z" "start-stop-visibility=hidden"
33+
// CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_*=0xffffffffffffffff"
34+
// CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_ranges=0xfffffffffffffffe"
35+
// CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_loc=0xfffffffffffffffe"
36+
37+
// CHECK-NO-EXE: {{ld(\.exe)?}}"
38+
// CHECK-NO-EXE-NOT: "--eh-frame-hdr"
39+
// CHECK-NO-EXE-NOT: "--hash-style
40+
// CHECK-NO-EXE-NOT: "--build-id
41+
// CHECK-NO-EXE-NOT: "--unresolved-symbols
42+
// CHECK-NO-EXE-NOT: "-z"
3243

3344
// Test that -static is forwarded to the linker
3445

0 commit comments

Comments
 (0)