[PATCH] D78138: [MC][ELF] Reject instructions in SHT_NOBITS sections

Kan Shengchen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 22:17:39 PDT 2020


skan 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;
+  }
----------------
MaskRay wrote:
> 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`.
But `EmitInstToData` can not check if a relaxable instruction is emitted into a virtual section.


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