mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00:00
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
This commit is contained in:
@ -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:
|
||||
|
Reference in New Issue
Block a user