[llvm] 35be65c - [MC] Fix an assert in MCAssembler::writeSectionData to be aware of errors
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 29 23:11:27 PDT 2020
Author: Fangrui Song
Date: 2020-10-29T23:11:18-07:00
New Revision: 35be65cb1ceeb1f509ee4696871ddb86a8d16d8f
URL: https://github.com/llvm/llvm-project/commit/35be65cb1ceeb1f509ee4696871ddb86a8d16d8f
DIFF: https://github.com/llvm/llvm-project/commit/35be65cb1ceeb1f509ee4696871ddb86a8d16d8f.diff
LOG: [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"
Added:
Modified:
llvm/lib/MC/MCAssembler.cpp
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 1b2eb2412a16..14220140cfd9 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>
More information about the llvm-commits
mailing list