From 4f066b6db8a7a95b206725aecf99a64fd6e9415c Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Wed, 28 Aug 2013 17:50:59 +0000 Subject: The integrated darwin assembler can hang in an infinite loop (or get an assert with a debug build) with this buggy .indirect_symbol directive usage: % cat test.s x: .indirect_symbol _y The assertion is because it is trying to get the symbol index for the symbol _y when it is writing out the indirect symbol table. This line of code in MachObjectWriter::WriteObject() : Write32(Asm.getSymbolData(*it->Symbol).getIndex()); And while there is a symbol _y it does not have any getSymbolData set which is only done in MachObjectWriter::BindIndirectSymbols() for pointer sections or stub sections. I added a check and an error in there to catch this in case something slips through. But to get a better error the parser should detect when a .indirect_symbol directive is used and it is not in a pointer section or stub section. To make that work I moved the handling of the indirect symbol out of the target independent AsmParser code into the DarwinAsmParser code that can check for the proper Mach-O section types. rdar://14825505 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189497 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/MC/MachO/bad-indirect-symbols.s | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/MC/MachO/bad-indirect-symbols.s (limited to 'test/MC/MachO') diff --git a/test/MC/MachO/bad-indirect-symbols.s b/test/MC/MachO/bad-indirect-symbols.s new file mode 100644 index 0000000000..7c16e90522 --- /dev/null +++ b/test/MC/MachO/bad-indirect-symbols.s @@ -0,0 +1,5 @@ +// RUN: not llvm-mc -triple x86_64-apple-darwin10 %s -filetype=obj -o - 2> %t.err > %t +// RUN: FileCheck --check-prefix=CHECK-ERROR < %t.err %s + +x: .indirect_symbol _y +// CHECK-ERROR: 4:4: error: indirect symbol not in a symbol pointer or stub section -- cgit v1.2.3