diff options
author | Fangrui Song <i@maskray.me> | 2025-05-24 20:43:48 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2025-05-24 20:43:48 -0700 |
commit | b65760bc7fcdee8179bf1e57fce3786737528dd8 (patch) | |
tree | 705c1f589e21877fac818e6dc54e980969bce00d /llvm/lib/MC/ELFObjectWriter.cpp | |
parent | 768726163730dda5bb490a5e88d4463ab5d3d231 (diff) | |
download | llvm-b65760bc7fcdee8179bf1e57fce3786737528dd8.zip llvm-b65760bc7fcdee8179bf1e57fce3786737528dd8.tar.gz llvm-b65760bc7fcdee8179bf1e57fce3786737528dd8.tar.bz2 |
MCObjectTargetWriter: Add getContext/reportError and use it for ELF
Prepare for removing MCContext from getRelocType functions.
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/ELFObjectWriter.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index 5741848..4665d85 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -1182,6 +1182,11 @@ void ELFObjectWriter::reset() { MCObjectWriter::reset(); } +void ELFObjectWriter::setAssembler(MCAssembler *Asm) { + MCObjectWriter::setAssembler(Asm); + TargetObjectWriter->setAssembler(Asm); +} + bool ELFObjectWriter::hasRelocationAddend() const { return TargetObjectWriter->hasRelocationAddend(); } @@ -1303,15 +1308,15 @@ bool ELFObjectWriter::useSectionSymbol(const MCValue &Val, return !TargetObjectWriter->needsRelocateWithSymbol(Val, *Sym, Type); } -bool ELFObjectWriter::checkRelocation(MCContext &Ctx, SMLoc Loc, - const MCSectionELF *From, +bool ELFObjectWriter::checkRelocation(SMLoc Loc, const MCSectionELF *From, const MCSectionELF *To) { if (isDwoSection(*From)) { - Ctx.reportError(Loc, "A dwo section may not contain relocations"); + getContext().reportError(Loc, "A dwo section may not contain relocations"); return false; } if (To && isDwoSection(*To)) { - Ctx.reportError(Loc, "A relocation may not refer to a dwo section"); + getContext().reportError(Loc, + "A relocation may not refer to a dwo section"); return false; } return true; @@ -1339,7 +1344,7 @@ void ELFObjectWriter::recordRelocation(const MCFragment &F, const MCSectionELF *SecA = (SymA && SymA->isInSection()) ? cast<MCSectionELF>(&SymA->getSection()) : nullptr; - if (DwoOS && !checkRelocation(Ctx, Fixup.getLoc(), &FixupSection, SecA)) + if (DwoOS && !checkRelocation(Fixup.getLoc(), &FixupSection, SecA)) return; bool IsPCRel = Backend.getFixupKindInfo(Fixup.getKind()).Flags & |