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

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Fri Jun 20 09:49:04 PDT 2014


================
Comment at: lib/MC/MCAssembler.cpp:788
@@ +787,3 @@
+            std::string SecName = "virtual section";
+            if (SD->getSection().getVariant() == MCSection::SV_ELF)
+              SecName = "section '" + static_cast<const MCSectionELF&>
----------------
You can probably use a dyn_cast.

================
Comment at: lib/MC/MCAssembler.cpp:791
@@ +790,3 @@
+                (SD->getSection()).getSectionName().str()  + "'";
+            report_fatal_error("non-zero initializer found in " + SecName);
+            return;
----------------
How about just having two report_fatal_error calls? The ELF one could be

report_fatal_error("non-zero initializer found in " + Section->getSectionName())

and the non-elf one

report_fatal_error("non-zero initializer found in an virtual section");


================
Comment at: lib/MC/MCAssembler.cpp:792
@@ +791,3 @@
+            report_fatal_error("non-zero initializer found in " + SecName);
+            return;
+          }
----------------
report_fatal_error doesn't return, so you don't need this.

http://reviews.llvm.org/D4199






More information about the llvm-commits mailing list