diff options
author | Weiming Zhao <weimingz@codeaurora.org> | 2014-06-22 00:33:44 +0000 |
---|---|---|
committer | Weiming Zhao <weimingz@codeaurora.org> | 2014-06-22 00:33:44 +0000 |
commit | 09f104fc323ff9b8cfcecd1f0ec7b470b38c69a1 (patch) | |
tree | 23a761858fb05d09bcb11ee86ff3a7ef6be1d29d /lib/MC | |
parent | 427afb91d38252b1abf0afaa08099f1f8cda3b66 (diff) | |
download | llvm-09f104fc323ff9b8cfcecd1f0ec7b470b38c69a1.tar.gz llvm-09f104fc323ff9b8cfcecd1f0ec7b470b38c69a1.tar.bz2 llvm-09f104fc323ff9b8cfcecd1f0ec7b470b38c69a1.tar.xz |
Report error for non-zero data in .bss
User may initialize a var with non-zero value and specify .bss section.
E.g. : int a __attribute__((section(".bss"))) = 2;
This patch converts an assertion to error report for better user
experience.
Differential Revision: http://reviews.llvm.org/D4199
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211455 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCAssembler.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 886a5f5545..4f876c8ce7 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -27,6 +27,7 @@ #include "llvm/Support/LEB128.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/MC/MCSectionELF.h" #include <tuple> using namespace llvm; @@ -782,8 +783,13 @@ void MCAssembler::writeSectionData(const MCSectionData *SD, assert(DF.fixup_begin() == DF.fixup_end() && "Cannot have fixups in virtual section!"); for (unsigned i = 0, e = DF.getContents().size(); i != e; ++i) - assert(DF.getContents()[i] == 0 && - "Invalid data value for virtual section!"); + if (DF.getContents()[i]) { + if (auto *ELFSec = dyn_cast<const MCSectionELF>(&SD->getSection())) + report_fatal_error("non-zero initializer found in section '" + + ELFSec->getSectionName() + "'"); + else + report_fatal_error("non-zero initializer found in virtual section"); + } break; } case MCFragment::FT_Align: |