summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2014-04-15 01:17:45 +0000
committerQuentin Colombet <qcolombet@apple.com>2014-04-15 01:17:45 +0000
commit97c05b52b404cac38eea383b55821e324e5abbac (patch)
treeb388c619c7ad09dbaf2d3588d150afbd963dd51a
parentc396019837ae5b27c3b9d3f0410eeaf590d47841 (diff)
downloadbcm5719-llvm-97c05b52b404cac38eea383b55821e324e5abbac.tar.gz
bcm5719-llvm-97c05b52b404cac38eea383b55821e324e5abbac.zip
[MC] Emit an error if cfi_startproc is used before a symbol is defined.
Currently, we bind those directives with the last symbol, so if none has been defined, this would lead to a crash of the compiler. <rdar://problem/15939159> llvm-svn: 206236
-rw-r--r--llvm/lib/MC/MCStreamer.cpp4
-rw-r--r--llvm/test/MC/ARM/dwarf-cfi-initial-state.s1
-rw-r--r--llvm/test/MC/AsmParser/cfi-invalid-startproc.s16
-rw-r--r--llvm/test/MC/MachO/debug_frame.s1
-rw-r--r--llvm/test/MC/PowerPC/ppc64-initial-cfa.s1
5 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index 17e0541b225..f85f7d3210c 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -278,6 +278,10 @@ void MCStreamer::EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
}
void MCStreamer::RecordProcStart(MCDwarfFrameInfo &Frame) {
+ // Report an error if we haven't seen a symbol yet where we'd bind
+ // .cfi_startproc.
+ if (!LastSymbol)
+ report_fatal_error("No symbol to start a frame");
Frame.Function = LastSymbol;
// We need to create a local symbol to avoid relocations.
Frame.Begin = getContext().CreateTempSymbol();
diff --git a/llvm/test/MC/ARM/dwarf-cfi-initial-state.s b/llvm/test/MC/ARM/dwarf-cfi-initial-state.s
index 2d638e9c4b2..0d1c08af728 100644
--- a/llvm/test/MC/ARM/dwarf-cfi-initial-state.s
+++ b/llvm/test/MC/ARM/dwarf-cfi-initial-state.s
@@ -1,6 +1,7 @@
# RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o - \
# RUN: | llvm-dwarfdump - | FileCheck %s
+_proc:
.cfi_sections .debug_frame
.cfi_startproc
bx lr
diff --git a/llvm/test/MC/AsmParser/cfi-invalid-startproc.s b/llvm/test/MC/AsmParser/cfi-invalid-startproc.s
new file mode 100644
index 00000000000..57ded13d0f7
--- /dev/null
+++ b/llvm/test/MC/AsmParser/cfi-invalid-startproc.s
@@ -0,0 +1,16 @@
+# RUN: not llvm-mc -triple=x86_64-apple-macosx10.8 -filetype=obj -o %t %s 2>&1 | FileCheck %s
+# Check that the cfi_startproc is declared after the beginning of
+# a procedure, otherwise it will reference an invalid symbol for
+# emitting the relocation.
+# <rdar://problem/15939159>
+
+# CHECK: No symbol to start a frame
+.text
+.cfi_startproc
+.globl _someFunction
+_someFunction:
+.cfi_def_cfa_offset 16
+.cfi_offset %rbp, -16
+.cfi_def_cfa_register rbp
+ ret
+.cfi_endproc
diff --git a/llvm/test/MC/MachO/debug_frame.s b/llvm/test/MC/MachO/debug_frame.s
index 20bfd8dde2e..247347d252a 100644
--- a/llvm/test/MC/MachO/debug_frame.s
+++ b/llvm/test/MC/MachO/debug_frame.s
@@ -3,6 +3,7 @@
// Make sure MC can handle file level .cfi_startproc and .cfi_endproc that creates
// an empty frame.
// rdar://10017184
+_proc:
.cfi_startproc
.cfi_endproc
diff --git a/llvm/test/MC/PowerPC/ppc64-initial-cfa.s b/llvm/test/MC/PowerPC/ppc64-initial-cfa.s
index b890b30ba03..ca97e1b96b0 100644
--- a/llvm/test/MC/PowerPC/ppc64-initial-cfa.s
+++ b/llvm/test/MC/PowerPC/ppc64-initial-cfa.s
@@ -7,6 +7,7 @@
# RUN: llvm-mc -triple=powerpc64le-unknown-linux-gnu -filetype=obj -relocation-model=pic %s | \
# RUN: llvm-readobj -s -sr -sd | FileCheck %s -check-prefix=PIC -check-prefix=PIC-LE
+_proc:
.cfi_startproc
nop
.cfi_endproc
OpenPOWER on IntegriCloud