[PATCH] D152831: [AArch64][MachO] Drop a 2015 ld64 workaround avoiding local relocations

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 09:51:21 PDT 2023


MaskRay updated this revision to Diff 530951.
MaskRay added a comment.

remove a stale comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152831/new/

https://reviews.llvm.org/D152831

Files:
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
  llvm/test/MC/MachO/AArch64/ld64-workaround.s
  llvm/test/MC/MachO/AArch64/mergeable.s


Index: llvm/test/MC/MachO/AArch64/mergeable.s
===================================================================
--- llvm/test/MC/MachO/AArch64/mergeable.s
+++ 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 @@
 // 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: ]
Index: llvm/test/MC/MachO/AArch64/ld64-workaround.s
===================================================================
--- llvm/test/MC/MachO/AArch64/ld64-workaround.s
+++ 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
Index: llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
===================================================================
--- llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
+++ llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
@@ -139,13 +139,11 @@
     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(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152831.530951.patch
Type: text/x-patch
Size: 3360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230613/fc422488/attachment.bin>


More information about the llvm-commits mailing list