diff options
author | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2018-07-02 17:29:43 +0000 |
---|---|---|
committer | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2018-07-02 17:29:43 +0000 |
commit | 4d5b1073ba87f6709112d0d9b5270ee51d3abd54 (patch) | |
tree | 7092adab58fd58dc72a6580d86337d58dd13a92f /llvm/lib/MC/MCAsmStreamer.cpp | |
parent | d4f77a523bb99d3ac7132dfb5783b85835312cce (diff) | |
download | bcm5719-llvm-4d5b1073ba87f6709112d0d9b5270ee51d3abd54.tar.gz bcm5719-llvm-4d5b1073ba87f6709112d0d9b5270ee51d3abd54.zip |
[MC] Error on a .zerofill directive in a non-virtual section
On darwin, all virtual sections have zerofill type, and having a
.zerofill directive in a non-virtual section is not allowed. Instead of
asserting, show a nicer error.
In order to use the equivalent of .zerofill in a non-virtual section,
the usage of .zero of .space is required.
This patch replaces the assert with an error.
Differential Revision: https://reviews.llvm.org/D48517
llvm-svn: 336127
Diffstat (limited to 'llvm/lib/MC/MCAsmStreamer.cpp')
-rw-r--r-- | llvm/lib/MC/MCAsmStreamer.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index 681e7e482e7..5398cfea786 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -178,7 +178,8 @@ public: unsigned ByteAlignment) override; void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, - uint64_t Size = 0, unsigned ByteAlignment = 0) override; + uint64_t Size = 0, unsigned ByteAlignment = 0, + SMLoc Loc = SMLoc()) override; void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment = 0) override; @@ -749,14 +750,18 @@ void MCAsmStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, } void MCAsmStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol, - uint64_t Size, unsigned ByteAlignment) { + uint64_t Size, unsigned ByteAlignment, + SMLoc Loc) { if (Symbol) AssignFragment(Symbol, &Section->getDummyFragment()); // Note: a .zerofill directive does not switch sections. OS << ".zerofill "; + assert(Section->getVariant() == MCSection::SV_MachO && + ".zerofill is a Mach-O specific directive"); // This is a mach-o specific directive. + const MCSectionMachO *MOSection = ((const MCSectionMachO*)Section); OS << MOSection->getSegmentName() << "," << MOSection->getSectionName(); @@ -779,7 +784,11 @@ void MCAsmStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, assert(Symbol && "Symbol shouldn't be NULL!"); // Instead of using the Section we'll just use the shortcut. + + assert(Section->getVariant() == MCSection::SV_MachO && + ".zerofill is a Mach-O specific directive"); // This is a mach-o specific directive and section. + OS << ".tbss "; Symbol->print(OS, MAI); OS << ", " << Size; |