From c3dc4867523f395709b95da2a3d79cf30f5c6a6a Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 21 Apr 2011 18:36:50 +0000 Subject: Fix relative relocations. This is sufficient for running the rust testsuite with MC :-) llvm-svn: 129923 --- llvm/lib/MC/WinCOFFObjectWriter.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'llvm/lib') diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp index fe3342c886b..101237aabb0 100644 --- a/llvm/lib/MC/WinCOFFObjectWriter.cpp +++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp @@ -656,8 +656,13 @@ void WinCOFFObjectWriter::RecordRelocation(const MCAssembler &Asm, const MCSymbol *B = &Target.getSymB()->getSymbol(); MCSymbolData &B_SD = Asm.getSymbolData(*B); - FixedValue = Layout.getSymbolOffset(&A_SD) - Layout.getSymbolOffset(&B_SD); + // Offset of the symbol in the section + int64_t a = Layout.getSymbolOffset(&B_SD); + // Ofeset of the relocation in the section + int64_t b = Layout.getFragmentOffset(Fragment) + Fixup.getOffset(); + + FixedValue = b - a; // In the case where we have SymbA and SymB, we just need to store the delta // between the two symbols. Update FixedValue to account for the delta, and // skip recording the relocation. -- cgit v1.2.3