Skip to content

Commit

Permalink
Merge pull request JuliaLang#19472 from JuliaLang/vc/ssp
Browse files Browse the repository at this point in the history
Fixes for LLVM 3.9 and Win64
  • Loading branch information
vchuravy committed Dec 2, 2016
2 parents e61118b + 6a1c2b6 commit bf012f8
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ $(eval $(call LLVM_PATCH,llvm-D25865-cmakeshlib))
$(eval $(call LLVM_PATCH,llvm-3.9.0_threads))
$(eval $(call LLVM_PATCH,llvm-3.9.0_cygwin)) # R283427, Remove for 4.0
$(eval $(call LLVM_PATCH,llvm-3.9.0_win64-reloc-dwarf))
$(eval $(call LLVM_PATCH,llvm-3.9.0_D27296-libssp))
endif # LLVM_VER

ifeq ($(LLVM_VER),3.7.1)
Expand Down
47 changes: 47 additions & 0 deletions deps/patches/llvm-3.9.0_D27296-libssp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
From e95516f77127ca534775d5f8d8cbb6e2e9c3f993 Mon Sep 17 00:00:00 2001
From: Valentin Churavy <[email protected]>
Date: Thu, 1 Dec 2016 18:48:30 +0900
Subject: [PATCH] Don't assume mingw is providing SSP functions

Summary:
Mingw is indirectly targeting msvcrt*.dll and we can't guarantee that
these functions will be available during JIT'ing.

Differential Revision: https://reviews.llvm.org/D27296
---
lib/Target/X86/X86ISelLowering.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp
index 44eae35..a932792 100644
--- a/lib/Target/X86/X86ISelLowering.cpp
+++ b/lib/Target/X86/X86ISelLowering.cpp
@@ -2016,7 +2016,7 @@ Value *X86TargetLowering::getIRStackGuard(IRBuilder<> &IRB) const {

void X86TargetLowering::insertSSPDeclarations(Module &M) const {
// MSVC CRT provides functionalities for stack protection.
- if (Subtarget.getTargetTriple().isOSMSVCRT()) {
+ if (Subtarget.getTargetTriple().isWindowsMSVCEnvironment()) {
// MSVC CRT has a global variable holding security cookie.
M.getOrInsertGlobal("__security_cookie",
Type::getInt8PtrTy(M.getContext()));
@@ -2038,14 +2038,14 @@ void X86TargetLowering::insertSSPDeclarations(Module &M) const {

Value *X86TargetLowering::getSDagStackGuard(const Module &M) const {
// MSVC CRT has a global variable holding security cookie.
- if (Subtarget.getTargetTriple().isOSMSVCRT())
+ if (Subtarget.getTargetTriple().isWindowsMSVCEnvironment())
return M.getGlobalVariable("__security_cookie");
return TargetLowering::getSDagStackGuard(M);
}

Value *X86TargetLowering::getSSPStackGuardCheck(const Module &M) const {
// MSVC CRT has a function to validate security cookie.
- if (Subtarget.getTargetTriple().isOSMSVCRT())
+ if (Subtarget.getTargetTriple().isWindowsMSVCEnvironment())
return M.getFunction("__security_check_cookie");
return TargetLowering::getSSPStackGuardCheck(M);
}
--
2.10.2

0 comments on commit bf012f8

Please sign in to comment.