[llvm-commits] [llvm] r98420 - in /llvm/trunk: lib/MC/MCAssembler.cpp test/MC/MachO/reloc-pcrel-offset.s

Daniel Dunbar daniel at zuster.org
Fri Mar 12 18:38:00 PST 2010


Author: ddunbar
Date: Fri Mar 12 20:38:00 2010
New Revision: 98420

URL: http://llvm.org/viewvc/llvm-project?rev=98420&view=rev
Log:
MC/Mach-O: PCrel relocations weren't using the right base address, they are
relative to the fragment address, not its offset. This was masked by the text
section normally being at address 0.

Added:
    llvm/trunk/test/MC/MachO/reloc-pcrel-offset.s
Modified:
    llvm/trunk/lib/MC/MCAssembler.cpp

Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=98420&r1=98419&r2=98420&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Fri Mar 12 20:38:00 2010
@@ -1024,7 +1024,7 @@
   }
 
   if (IsPCRel)
-    Value -= DF->getOffset() + Fixup.Offset;
+    Value -= DF->getAddress() + Fixup.Offset;
 
   return IsResolved;
 }

Added: llvm/trunk/test/MC/MachO/reloc-pcrel-offset.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/reloc-pcrel-offset.s?rev=98420&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/reloc-pcrel-offset.s (added)
+++ llvm/trunk/test/MC/MachO/reloc-pcrel-offset.s Fri Mar 12 20:38:00 2010
@@ -0,0 +1,14 @@
+// RUN: llvm-mc -n -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s
+
+// CHECK: # Relocation 0
+// CHECK: (('word-0', 0x1),
+// CHECK: ('word-1', 0x5000002)),
+// CHECK-NEXT: ])
+// CHECK: ('_section_data', '\xe8\xfb\xff\xff\xff')
+
+        .data
+        .long 0
+
+        .text
+_a:
+        call _a





More information about the llvm-commits mailing list