summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2013-08-12 22:45:44 +0000
committerKevin Enderby <enderby@apple.com>2013-08-12 22:45:44 +0000
commitb03f3fe4e8d7181b26d5b53c6dd786f4a68b5f4b (patch)
tree33d26208f1ad820ddd1884731b45b3546631d2b6 /llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
parent8d642de16968e2d3302c3900a0141750bf99145e (diff)
downloadbcm5719-llvm-b03f3fe4e8d7181b26d5b53c6dd786f4a68b5f4b.tar.gz
bcm5719-llvm-b03f3fe4e8d7181b26d5b53c6dd786f4a68b5f4b.zip
Fix a crash with X86 Mach-O and a subtraction expression where both symbols are
undefined and produce an error message instead as this is a non-relocatable expression with X86 Mach-O. rdar://8920876 llvm-svn: 188218
Diffstat (limited to 'llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp')
-rw-r--r--llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
index 64f005c469b..6eff224e261 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
@@ -175,6 +175,11 @@ void X86MachObjectWriter::RecordX86_64Relocation(MachObjectWriter *Writer,
if (A_Base == B_Base && A_Base)
report_fatal_error("unsupported relocation with identical base");
+ // A subtraction expression where both symbols are undefined is a
+ // non-relocatable expression.
+ if (A->isUndefined() && B->isUndefined())
+ report_fatal_error("unsupported relocation with subtraction expression");
+
Value += Writer->getSymbolAddress(&A_SD, Layout) -
(A_Base == NULL ? 0 : Writer->getSymbolAddress(A_Base, Layout));
Value -= Writer->getSymbolAddress(&B_SD, Layout) -
OpenPOWER on IntegriCloud