diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-03-09 21:27:58 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-03-09 21:27:58 +0000 |
commit | f3a066f7c3ef4e729c92929acab352a93f8d7563 (patch) | |
tree | b8f1cb4ce987581be42a2369851b2b085859ab08 /lib | |
parent | aef9d7af69913740f313c5cc1dfe2a8e1d352227 (diff) |
MC/Mach-O: For PCrel relocations, we need to compensate for the PCrel adjustment when determining if we need a scattered relocation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98082 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MC/MCAssembler.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index b3e8114b42..cf02cc15c5 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -504,15 +504,21 @@ public: MCAsmFixup &Fixup, DenseMap<const MCSymbol*,MCSymbolData*> &SymbolMap, std::vector<MachRelocationEntry> &Relocs) { + unsigned IsPCRel = isFixupKindPCRel(Fixup.Kind); + unsigned Log2Size = getFixupKindLog2Size(Fixup.Kind); + MCValue Target; if (!Fixup.Value->EvaluateAsRelocatable(Target)) llvm_report_error("expected relocatable expression"); - // If this is a difference or a local symbol plus an offset, then we need a - // scattered relocation entry. + // If this is a difference or a defined symbol plus an offset, then we need + // a scattered relocation entry. + uint32_t Offset = Target.getConstant(); + if (IsPCRel) + Offset += 1 << Log2Size; if (Target.getSymB() || (Target.getSymA() && !Target.getSymA()->isUndefined() && - Target.getConstant())) + Offset)) return ComputeScatteredRelocationInfo(Asm, Fragment, Fixup, Target, SymbolMap, Relocs); @@ -520,8 +526,6 @@ public: uint32_t Address = Fragment.getOffset() + Fixup.Offset; uint32_t Value = 0; unsigned Index = 0; - unsigned IsPCRel = isFixupKindPCRel(Fixup.Kind); - unsigned Log2Size = getFixupKindLog2Size(Fixup.Kind); unsigned IsExtern = 0; unsigned Type = 0; |