[PATCH] [MC] report error instead of assertion for non-zero initializer in .bss section

Weiming Zhao weimingz at codeaurora.org
Sat Jun 21 17:42:00 PDT 2014


Closed by commit rL211455 (authored by @weimingz).

http://reviews.llvm.org/D4199

Files:
  llvm/trunk/lib/MC/MCAssembler.cpp
  llvm/trunk/test/MC/ELF/ARM/bss-non-zero-value.s

Index: llvm/trunk/test/MC/ELF/ARM/bss-non-zero-value.s
===================================================================
--- llvm/trunk/test/MC/ELF/ARM/bss-non-zero-value.s
+++ llvm/trunk/test/MC/ELF/ARM/bss-non-zero-value.s
@@ -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
Index: llvm/trunk/lib/MC/MCAssembler.cpp
===================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp
+++ llvm/trunk/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 @@
         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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4199.10724.patch
Type: text/x-patch
Size: 1605 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140622/24e7dd32/attachment.bin>


More information about the llvm-commits mailing list