Include the section address in the computation of the relocation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115509 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2010-10-04 15:59:01 +00:00
parent 01263d35d4
commit 55fb102130
2 changed files with 11 additions and 1 deletions

View File

@ -539,7 +539,14 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
const MCSymbol &SymbolB = RefB->getSymbol();
MCSymbolData &SDB = Asm.getSymbolData(SymbolB);
IsPCRel = true;
Value += Layout.getFragmentOffset(Fragment) + Fixup.getOffset() - Layout.getSymbolAddress(&SDB);
MCSectionData *Sec = Fragment->getParent();
// Offset of the symbol in the section
int64_t a = Layout.getSymbolAddress(&SDB) - Layout.getSectionAddress(Sec);
// Ofeset of the relocation in the section
int64_t b = Layout.getFragmentOffset(Fragment) + Fixup.getOffset();
Value += b - a;
}
// Check that this case has already been fully resolved before we get

View File

@ -19,6 +19,9 @@
// CHECK-NEXT: ),
// CHECK-NEXT: ])
.zero 4
.data
.zero 1
.align 4
foo: