[PATCH] D78138: [MC][ELF] Reject instructions in SHT_NOBITS sections
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 21:12:41 PDT 2020
MaskRay marked an inline comment as done.
MaskRay added inline comments.
================
Comment at: llvm/lib/MC/MCELFStreamer.cpp:514-519
+ MCSection &Sec = *getCurrentSectionOnly();
+ if (Sec.isVirtualSection()) {
+ getContext().reportError(Inst.getLoc(),
+ "SHT_NOBITS section cannot have instructions");
+ return;
+ }
----------------
skan wrote:
> Do you think `MCObjectStreamer::emitInstruction` is a better place to check `Sec.isVirtualSection()`?
For an error message specific to the binary format (e.g. ELF), EmitInstToData is probably the best choice.
For the COFF error message, the error message may mention `IMAGE_SCN_CNT_UNINITIALIZED_DATA`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D78138/new/
https://reviews.llvm.org/D78138
More information about the llvm-commits
mailing list