1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

[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"
This commit is contained in:
Fangrui Song 2020-10-29 23:09:57 -07:00
parent 62df0bc052
commit 95980dfb95

View File

@ -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>