[llvm] r276783 - [MC] Don't crash when trying to emit a relocation against .bss.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 11:16:33 PDT 2016


Author: davide
Date: Tue Jul 26 13:16:33 2016
New Revision: 276783

URL: http://llvm.org/viewvc/llvm-project?rev=276783&view=rev
Log:
[MC] Don't crash when trying to emit a relocation against .bss.

Turn that into an error instead.

Added:
    llvm/trunk/test/MC/X86/reloc-bss.s
Modified:
    llvm/trunk/lib/MC/MCAssembler.cpp

Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=276783&r1=276782&r2=276783&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Tue Jul 26 13:16:33 2016
@@ -575,8 +575,8 @@ void MCAssembler::writeSectionData(const
         // into a virtual section. This is to support clients which use standard
         // directives to fill the contents of virtual sections.
         const MCDataFragment &DF = cast<MCDataFragment>(F);
-        assert(DF.fixup_begin() == DF.fixup_end() &&
-               "Cannot have fixups in virtual section!");
+        if (DF.fixup_begin() != DF.fixup_end())
+          report_fatal_error("cannot have fixups in virtual section!");
         for (unsigned i = 0, e = DF.getContents().size(); i != e; ++i)
           if (DF.getContents()[i]) {
             if (auto *ELFSec = dyn_cast<const MCSectionELF>(Sec))

Added: llvm/trunk/test/MC/X86/reloc-bss.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/reloc-bss.s?rev=276783&view=auto
==============================================================================
--- llvm/trunk/test/MC/X86/reloc-bss.s (added)
+++ llvm/trunk/test/MC/X86/reloc-bss.s Tue Jul 26 13:16:33 2016
@@ -0,0 +1,9 @@
+# RUN: not llvm-mc -filetype=obj -triple=x86_64-linux-gnu %s 2>&1 | FileCheck %s
+# CHECK: LLVM ERROR: cannot have fixups in virtual section!
+
+.section        .init_array,"awT", at nobits
+
+.hidden patatino
+.globl  patatino
+patatino:
+  movl __init_array_start, %eax




More information about the llvm-commits mailing list