Darwin assembler improved relocs when w/o subsections_via_symbols.
authorJim Grosbach <grosbach@apple.com>
Wed, 7 Dec 2011 19:46:59 +0000 (19:46 +0000)
committerJim Grosbach <grosbach@apple.com>
Wed, 7 Dec 2011 19:46:59 +0000 (19:46 +0000)
When the file isn't being built with subsections-via-symbols, symbol
differences involving non-local symbols can be resolved more aggressively.
Needed for gas compatibility.

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

lib/MC/MachObjectWriter.cpp
lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
test/MC/MachO/ARM/darwin-ARM-reloc.s
test/MC/MachO/reloc-pcrel-offset.s
test/MC/MachO/reloc-pcrel.s

index 6e720115dd1648687a704e96797903c5b2bfbfdd..e016f09c95f0e5b605debbce0e007bd3c15e1a8b 100644 (file)
@@ -584,9 +584,14 @@ IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
     // requires the compiler to use .set to absolutize the differences between
     // symbols which the compiler knows to be assembly time constants, so we
     // don't need to worry about considering symbol differences fully resolved.
+    //
+    // If the file isn't using sub-sections-via-symbols, we can make the
+    // same assumptions about any symbol that we normally make about
+    // assembler locals.
 
     if (!Asm.getBackend().hasReliableSymbolDifference()) {
-      if (!SA.isTemporary() || !SA.isInSection() || &SecA != &SecB)
+      if ((!SA.isTemporary() && Asm.getSubsectionsViaSymbols()) ||
+           !SA.isInSection() || &SecA != &SecB)
         return false;
       return true;
     }
index f394b4f37551fab4431f0423861f40dfd575d8b7..d0e66828c0c9503601fab86409e12256a4881483 100644 (file)
@@ -62,6 +62,9 @@ static bool getARMFixupKindMachOInfo(unsigned Kind, unsigned &RelocType,
   default:
     return false;
 
+  case ARM::fixup_t2_condbranch:
+    assert(0);
+    return false;
   case FK_Data_1:
     Log2Size = llvm::Log2_32(1);
     return true;
index 86b45e07bf386a4e7acbeb79ecf53c79e0e5df9f..fe69a94c276dd3adb052ffd9f914e3159afc7b13 100644 (file)
@@ -19,12 +19,14 @@ Ld0_0:
 Lsc0_0:
         .long 0
 
+        .subsections_via_symbols
+
 @ CHECK: ('cputype', 12)
 @ CHECK: ('cpusubtype', 9)
 @ CHECK: ('filetype', 1)
 @ CHECK: ('num_load_commands', 3)
 @ CHECK: ('load_commands_size', 364)
-@ CHECK: ('flag', 0)
+@ CHECK: ('flag', 8192)
 @ CHECK: ('load_commands', [
 @ CHECK:   # Load Command 0
 @ CHECK:  (('command', 1)
index e0f12bf4ba2ffcc3a42bd77ad15b706c74c6eb8e..bc611d7f369d48cd81b75c5aa8564fc65bb57e63 100644 (file)
@@ -12,3 +12,5 @@
         .text
 _a:
         call _a
+
+        .subsections_via_symbols
index fff7cc0ada04e162f5724d2118c44ad84f38750f..26844083c5f876ef76077ef32eeeaa82617d031d 100644 (file)
@@ -60,3 +60,5 @@ L1:
         call _c + 1
 //        call _a - L0
         call _b - L0
+
+        .subsections_via_symbols