summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/MC/MCAssembler.cpp2
-rw-r--r--llvm/test/MC/MachO/reloc-pcrel-offset.s14
2 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 88be99cffdd..29ac8684bde 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -1024,7 +1024,7 @@ bool MCAssembler::EvaluateFixup(const MCAsmLayout &Layout, MCAsmFixup &Fixup,
}
if (IsPCRel)
- Value -= DF->getOffset() + Fixup.Offset;
+ Value -= DF->getAddress() + Fixup.Offset;
return IsResolved;
}
diff --git a/llvm/test/MC/MachO/reloc-pcrel-offset.s b/llvm/test/MC/MachO/reloc-pcrel-offset.s
new file mode 100644
index 00000000000..46dc3a9c57d
--- /dev/null
+++ b/llvm/test/MC/MachO/reloc-pcrel-offset.s
@@ -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
OpenPOWER on IntegriCloud