aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCAssembler.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2020-10-29 23:09:57 -0700
committerFangrui Song <i@maskray.me>2020-10-29 23:11:18 -0700
commit35be65cb1ceeb1f509ee4696871ddb86a8d16d8f (patch)
tree113811e9ad481ed926031712e49606353240a16e /llvm/lib/MC/MCAssembler.cpp
parent61f11f807cfc359b38b9e22d005456f924464c30 (diff)
downloadllvm-35be65cb1ceeb1f509ee4696871ddb86a8d16d8f.zip
llvm-35be65cb1ceeb1f509ee4696871ddb86a8d16d8f.tar.gz
llvm-35be65cb1ceeb1f509ee4696871ddb86a8d16d8f.tar.bz2
[MC] Fix an assert in MCAssembler::writeSectionData to be aware of errors
If MCContext has an error, MCAssembler::layout may stop early and some MCFragment's may not finalize. In the Linux kernel, arch/x86/lib/memcpy_64.S could trigger the assert before "x86_64: Change .weak to SYM_FUNC_START_WEAK for arch/x86/lib/mem*_64.S"
Diffstat (limited to 'llvm/lib/MC/MCAssembler.cpp')
-rw-r--r--llvm/lib/MC/MCAssembler.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 1b2eb24..1422014 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -768,7 +768,8 @@ void MCAssembler::writeSectionData(raw_ostream &OS, const MCSection *Sec,
for (const MCFragment &F : *Sec)
writeFragment(OS, *this, Layout, F);
- assert(OS.tell() - Start == Layout.getSectionAddressSize(Sec));
+ assert(getContext().hadError() ||
+ OS.tell() - Start == Layout.getSectionAddressSize(Sec));
}
std::tuple<MCValue, uint64_t, bool>