diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp +++ b/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( diff --git a/llvm/test/MC/MachO/AArch64/ld64-workaround.s b/llvm/test/MC/MachO/AArch64/ld64-workaround.s --- 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 --- 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 @@ // 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: ]