From f17d48e58a76cef6cc6bfeb2d7b59c30d80d42de Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Tue, 26 Jul 2016 18:16:33 +0000 Subject: [PATCH] [MC] Don't crash when trying to emit a relocation against .bss. Turn that into an error instead. llvm-svn: 276783 --- llvm/lib/MC/MCAssembler.cpp | 4 ++-- llvm/test/MC/X86/reloc-bss.s | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 llvm/test/MC/X86/reloc-bss.s diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 7a42108..4735f6c 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -575,8 +575,8 @@ void MCAssembler::writeSectionData(const MCSection *Sec, // into a virtual section. This is to support clients which use standard // directives to fill the contents of virtual sections. const MCDataFragment &DF = cast(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(Sec)) diff --git a/llvm/test/MC/X86/reloc-bss.s b/llvm/test/MC/X86/reloc-bss.s new file mode 100644 index 0000000..3cf26d8 --- /dev/null +++ b/llvm/test/MC/X86/reloc-bss.s @@ -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",@nobits + +.hidden patatino +.globl patatino +patatino: + movl __init_array_start, %eax -- 2.7.4