Learn that __DATA,__objc_classrefs is not atomized via symbols.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 12 Feb 2015 23:11:59 +0000 (23:11 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 12 Feb 2015 23:11:59 +0000 (23:11 +0000)
This should hopefully fix objc on AArch64.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228976 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCAsmInfoDarwin.cpp
lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
test/MC/MachO/AArch64/classrefs.s [new file with mode: 0644]

index f7054902f24c2ab6faea5dfeeb7592bc27e5e2f0..a2a2504b4c88705ab3e450c25c64cf3c9fdc396d 100644 (file)
@@ -33,6 +33,10 @@ bool MCAsmInfoDarwin::isSectionAtomizableBySymbols(
   if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring")
     return false;
 
+  if (SMO.getSegmentName() == "__DATA" &&
+      SMO.getSectionName() == "__objc_classrefs")
+    return false;
+
   switch (SMO.getType()) {
   default:
     return true;
index 6c554fde1153a25d831ed50b2986d5e57e690fcf..0d9385dcb147909d6c97d876ff178e8f46b3902a 100644 (file)
@@ -134,6 +134,10 @@ static bool canUseLocalRelocation(const MCSectionMachO &Section,
       RefSec.getSectionName() == "__cfstring")
     return false;
 
+  if (RefSec.getSegmentName() == "__DATA" &&
+      RefSec.getSectionName() == "__objc_classrefs")
+    return false;
+
   return true;
 }
 
diff --git a/test/MC/MachO/AArch64/classrefs.s b/test/MC/MachO/AArch64/classrefs.s
new file mode 100644 (file)
index 0000000..5edc82c
--- /dev/null
@@ -0,0 +1,25 @@
+; 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 with Lbar. We could also produce
+; an internal relocation. We just have to be careful to not use another symbol.
+
+// CHECK:      Relocations [
+// CHECK-NEXT:   Section __data {
+// CHECK-NEXT:     Relocation {
+// CHECK-NEXT:       Offset: 0x0
+// CHECK-NEXT:       PCRel: 0
+// CHECK-NEXT:       Length: 3
+// CHECK-NEXT:       Extern: 1
+// CHECK-NEXT:       Type: ARM64_RELOC_UNSIGNED (0)
+// CHECK-NEXT:       Symbol: Lbar
+// CHECK-NEXT:       Scattered: 0
+// CHECK-NEXT:     }
+// CHECK-NEXT:   }
+// CHECK-NEXT: ]
+
+        .section        __DATA,__objc_classrefs,regular,no_dead_strip
+Lbar:
+
+        .section        __DATA,__data
+        .quad   Lbar
+