[llvm-commits] [llvm] r148865 - in /llvm/trunk: lib/MC/MachObjectWriter.cpp test/MC/MachO/ARM/no-subsections-reloc.s

Jim Grosbach grosbach at apple.com
Tue Jan 24 13:45:25 PST 2012


Author: grosbach
Date: Tue Jan 24 15:45:25 2012
New Revision: 148865

URL: http://llvm.org/viewvc/llvm-project?rev=148865&view=rev
Log:
ARM Darwin symbol ref differences w/o subsection-via-symbols.

When not using subsections via symbols, the assembler can resolve
symbol differences (including pcrel references) to non-local
labels at assembly time, not just those in the same atom.

Added:
    llvm/trunk/test/MC/MachO/ARM/no-subsections-reloc.s
Modified:
    llvm/trunk/lib/MC/MachObjectWriter.cpp

Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=148865&r1=148864&r2=148865&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MachObjectWriter.cpp Tue Jan 24 15:45:25 2012
@@ -592,7 +592,8 @@
     if (!Asm.getBackend().hasReliableSymbolDifference()) {
       if (!SA.isInSection() || &SecA != &SecB ||
           (!SA.isTemporary() &&
-           FB.getAtom() != Asm.getSymbolData(SA).getFragment()->getAtom()))
+           FB.getAtom() != Asm.getSymbolData(SA).getFragment()->getAtom() &&
+           Asm.getSubsectionsViaSymbols()))
         return false;
       return true;
     }

Added: llvm/trunk/test/MC/MachO/ARM/no-subsections-reloc.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/ARM/no-subsections-reloc.s?rev=148865&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/ARM/no-subsections-reloc.s (added)
+++ llvm/trunk/test/MC/MachO/ARM/no-subsections-reloc.s Tue Jan 24 15:45:25 2012
@@ -0,0 +1,18 @@
+@ RUN: llvm-mc -n -triple thumbv7-apple-darwin10 %s -filetype=obj -o %t.obj
+@ RUN: macho-dump --dump-section-data < %t.obj > %t.dump
+@ RUN: FileCheck < %t.dump %s
+
+@ When not using subsections-via-symbols, references to non-local symbols
+@ in the same section can be resolved at assembly time w/o relocations.
+
+ .syntax unified
+ .text
+ .thumb
+ .thumb_func _foo
+_foo:
+    ldr r3, bar
+bar:
+    .long 0
+
+@ CHECK: 'num_reloc', 0
+@ CHECK: '_section_data', 'dff80030 00000000'





More information about the llvm-commits mailing list