aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2025-05-24 20:43:48 -0700
committerFangrui Song <i@maskray.me>2025-05-24 20:43:48 -0700
commitb65760bc7fcdee8179bf1e57fce3786737528dd8 (patch)
tree705c1f589e21877fac818e6dc54e980969bce00d /llvm/lib/MC/ELFObjectWriter.cpp
parent768726163730dda5bb490a5e88d4463ab5d3d231 (diff)
downloadllvm-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.cpp15
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 &