mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01: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 llvm-svn: 211455
This commit is contained in:
parent
13371efcb8
commit
9975517643
@ -27,6 +27,7 @@
|
|||||||
#include "llvm/Support/LEB128.h"
|
#include "llvm/Support/LEB128.h"
|
||||||
#include "llvm/Support/TargetRegistry.h"
|
#include "llvm/Support/TargetRegistry.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
#include "llvm/MC/MCSectionELF.h"
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -782,8 +783,13 @@ void MCAssembler::writeSectionData(const MCSectionData *SD,
|
|||||||
assert(DF.fixup_begin() == DF.fixup_end() &&
|
assert(DF.fixup_begin() == DF.fixup_end() &&
|
||||||
"Cannot have fixups in virtual section!");
|
"Cannot have fixups in virtual section!");
|
||||||
for (unsigned i = 0, e = DF.getContents().size(); i != e; ++i)
|
for (unsigned i = 0, e = DF.getContents().size(); i != e; ++i)
|
||||||
assert(DF.getContents()[i] == 0 &&
|
if (DF.getContents()[i]) {
|
||||||
"Invalid data value for virtual section!");
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case MCFragment::FT_Align:
|
case MCFragment::FT_Align:
|
||||||
|
9
test/MC/ELF/ARM/bss-non-zero-value.s
Normal file
9
test/MC/ELF/ARM/bss-non-zero-value.s
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// RUN: not llvm-mc -filetype=obj -triple arm-linux-gnu %s -o %t 2>%t.out
|
||||||
|
// RUN: FileCheck --input-file=%t.out %s
|
||||||
|
// CHECK: non-zero initializer found in section '.bss'
|
||||||
|
.bss
|
||||||
|
.globl a
|
||||||
|
.align 2
|
||||||
|
a:
|
||||||
|
.long 1
|
||||||
|
.size a, 4
|
Loading…
x
Reference in New Issue
Block a user