From 01263d35d4c037a882dbfa6364eb0f6c4e0d87a8 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 4 Oct 2010 15:28:43 +0000 Subject: [PATCH] Correctly compute the relocation when it is not in the first fragment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115506 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/ELFObjectWriter.cpp | 2 +- test/MC/ELF/pic-diff.s | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 614e3967130..cc6d51efb0b 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -539,7 +539,7 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm, const MCSymbol &SymbolB = RefB->getSymbol(); MCSymbolData &SDB = Asm.getSymbolData(SymbolB); IsPCRel = true; - Value += Fixup.getOffset() - Layout.getSymbolAddress(&SDB); + Value += Layout.getFragmentOffset(Fragment) + Fixup.getOffset() - Layout.getSymbolAddress(&SDB); } // Check that this case has already been fully resolved before we get diff --git a/test/MC/ELF/pic-diff.s b/test/MC/ELF/pic-diff.s index 155754717a3..099ae1f0ad6 100644 --- a/test/MC/ELF/pic-diff.s +++ b/test/MC/ELF/pic-diff.s @@ -19,7 +19,8 @@ // CHECK-NEXT: ), // CHECK-NEXT: ]) -.zero 4 +.zero 1 +.align 4 foo: .zero 8 .long baz - foo