[llvm] 05fb769 - [AArch64][MachO] Drop a 2015 ld64 workaround avoiding local relocations
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 29 17:59:20 PDT 2023
Author: Fangrui Song
Date: 2023-06-29T17:59:15-07:00
New Revision: 05fb769b72834c62de3ac2d282e4949e77996c60
URL: https://github.com/llvm/llvm-project/commit/05fb769b72834c62de3ac2d282e4949e77996c60
DIFF: https://github.com/llvm/llvm-project/commit/05fb769b72834c62de3ac2d282e4949e77996c60.diff
LOG: [AArch64][MachO] Drop a 2015 ld64 workaround avoiding local relocations
Commit d6223a24718df3c30b67422c2eb6d0e93af9c4e8 introduced an ld64 workaround
that disables local relocations for many pointer-sized relocations (e.g.
relocations referencing `__DATA,__literal*`).
ld64 has been fixed long ago (2015). Drop this workaround so that the
behavior matches x86-64.
Reviewed By: pete
Differential Revision: https://reviews.llvm.org/D152831
Added:
Modified:
llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
llvm/test/MC/MachO/AArch64/ld64-workaround.s
llvm/test/MC/MachO/AArch64/mergeable.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
index 012661edbbfda3..04bd85260c5600 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
@@ -139,13 +139,11 @@ static bool canUseLocalRelocation(const MCSectionMachO &Section,
return false;
if (RefSec.getSegmentName() == "__DATA" &&
- RefSec.getName() == "__objc_classrefs")
+ (RefSec.getName() == "__cfstring" ||
+ RefSec.getName() == "__objc_classrefs"))
return false;
- // FIXME: ld64 currently handles internal pointer-sized relocations
- // incorrectly (applying the addend twice). We should be able to return true
- // unconditionally by this point when that's fixed.
- return false;
+ return true;
}
void AArch64MachObjectWriter::recordRelocation(
diff --git a/llvm/test/MC/MachO/AArch64/ld64-workaround.s b/llvm/test/MC/MachO/AArch64/ld64-workaround.s
index 807580c06dbf13..8e59b07c9ea577 100644
--- a/llvm/test/MC/MachO/AArch64/ld64-workaround.s
+++ b/llvm/test/MC/MachO/AArch64/ld64-workaround.s
@@ -1,8 +1,8 @@
; RUN: llvm-mc -triple arm64-apple-darwin10 %s -filetype=obj -o - | llvm-readobj -r --expand-relocs - | FileCheck %s
-; Test that we produce an external relocation. This is a known and temporary bug
-; in ld64, where it mishandles pointer-sized internal relocations. We should be
-; able to remove this entirely soon.
+/// To work around an ld64 arm64 bug before 2015, we used to disable local
+/// relocations for many pointer-sized relocations. Test that the workaround
+/// is dropped and the behavior now matches x86-64.
// CHECK: Relocations [
// CHECK-NEXT: Section __data {
@@ -11,21 +11,21 @@
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: ARM64_RELOC_UNSIGNED (0)
-// CHECK-NEXT: Symbol: Llit16
+// CHECK-NEXT: Section: __literal16
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x10
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: ARM64_RELOC_UNSIGNED (0)
-// CHECK-NEXT: Symbol: Llit8
+// CHECK-NEXT: Section: __literal8
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x8
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: ARM64_RELOC_UNSIGNED (0)
-// CHECK-NEXT: Symbol: Llit4
+// CHECK-NEXT: Section: __literal4
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x0
diff --git a/llvm/test/MC/MachO/AArch64/mergeable.s b/llvm/test/MC/MachO/AArch64/mergeable.s
index 8621b25e80d329..4aa2d0136eed27 100644
--- a/llvm/test/MC/MachO/AArch64/mergeable.s
+++ b/llvm/test/MC/MachO/AArch64/mergeable.s
@@ -1,6 +1,4 @@
// RUN: llvm-mc -triple aarch64-apple-darwin14 %s -filetype=obj -o - | llvm-readobj -r --expand-relocs - | FileCheck %s
-// FIXME: the final relocation should be internal, but the linker doesn't
-// currently handle the it correctly.
// Test that we "S + K" produce a relocation with a symbol, but just S produces
// a relocation with the section.
@@ -47,7 +45,7 @@ L1:
// CHECK-NEXT: PCRel: 0
// CHECK-NEXT: Length: 3
// CHECK-NEXT: Type: ARM64_RELOC_UNSIGNED (0)
-// CHECK-NEXT: Symbol: L0
+// CHECK-NEXT: Section: __literal4
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: ]
More information about the llvm-commits
mailing list