diff --git a/Make.inc b/Make.inc index 9be382c5424bb..c7bbe0139f92a 100644 --- a/Make.inc +++ b/Make.inc @@ -62,6 +62,9 @@ endif # libc++ is standard on OS X 10.9, but not for earlier releases USE_LIBCPP = 0 +# assume we don't have LIBSSP support in our compiler, will enable later if likely true +HAVE_SSP = 0 + # Prevent picking up $ARCH from the environment variables ARCH= @@ -355,16 +358,16 @@ CPP = $(CC) -E AR := $(CROSS_COMPILE)ar AS := $(CROSS_COMPILE)as LD := $(CROSS_COMPILE)ld -else +else #USEMSVC CPP = $(CC) -EP AR := lib ifeq ($(ARCH),x86_64) AS := ml64 else AS := ml -endif +endif #ARCH LD := link -endif +endif #USEMSVC RANLIB := $(CROSS_COMPILE)ranlib @@ -674,17 +677,19 @@ OSLIBS += -ldl -Wl,-w -framework CoreFoundation -framework CoreServices $(LIBUNW WHOLE_ARCHIVE = -Xlinker -all_load NO_WHOLE_ARCHIVE = JLDFLAGS = +HAVE_SSP = 1 endif ifeq ($(OS), WINNT) ifneq ($(USEMSVC), 1) +HAVE_SSP = 1 OSLIBS += -Wl,--export-all-symbols -Wl,--version-script=$(JULIAHOME)/src/julia.expmap \ $(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp JLDFLAGS = -Wl,--stack,8388608 ifeq ($(ARCH),i686) JLDFLAGS += -Wl,--large-address-aware endif -else +else #USEMSVC OSLIBS += kernel32.lib ws2_32.lib psapi.lib advapi32.lib iphlpapi.lib shell32.lib winmm.lib JLDFLAGS = -stack:8388608 endif @@ -734,6 +739,13 @@ LIBFFTWNAME = libmkl_rt LIBFFTWFNAME = libmkl_rt endif +ifeq ($(HAVE_SSP),1) +JCPPFLAGS += -DHAVE_SSP=1 +ifeq ($(USEGCC),1) +OSLIBS += -lssp +endif +endif + # ATLAS # ATLAS must have been previously built with "make -C deps compile-atlas" (without -jN), diff --git a/deps/Versions.make b/deps/Versions.make index e7ae4335db7a6..33be1e945eef7 100644 --- a/deps/Versions.make +++ b/deps/Versions.make @@ -1,4 +1,4 @@ -LLVM_VER = 3.3 +LLVM_VER = 3.5.0 LLVM_LIB_SUFFIX = PCRE_VER = 8.36 DSFMT_VER = 2.2 diff --git a/doc/juliadoc b/doc/juliadoc new file mode 160000 index 0000000000000..bab3c6ba9e613 --- /dev/null +++ b/doc/juliadoc @@ -0,0 +1 @@ +Subproject commit bab3c6ba9e613da94001e1d71f994143814a1422 diff --git a/doc/manual/embedding.rst b/doc/manual/embedding.rst index c8bd5900025c7..fc6085429b221 100644 --- a/doc/manual/embedding.rst +++ b/doc/manual/embedding.rst @@ -18,10 +18,6 @@ We start with a simple C program that initializes Julia and calls some Julia cod int main(int argc, char *argv[]) { - /* optional: randomize the stack guard */ - char a=255, b='\n', c=0; - SWAP_STACK_CHK_GUARD(a,b,c); - /* required: setup the julia context */ jl_init(NULL); @@ -34,9 +30,6 @@ We start with a simple C program that initializes Julia and calls some Julia cod and run all finalizers */ jl_atexit_hook(); - - /* if the stack guard is set: reset the stack guard */ - SWAP_STACK_CHK_GUARD(a,b,c); return 0; } diff --git a/examples/embedding.c b/examples/embedding.c index 4d7f3d29cf90e..6c4b4b0cee1e1 100644 --- a/examples/embedding.c +++ b/examples/embedding.c @@ -9,8 +9,6 @@ double my_c_sqrt(double x) int main() { - char a=255, b='\n', c=0; - SWAP_STACK_CHK_GUARD(a,b,c); jl_init(NULL); { @@ -97,6 +95,5 @@ int main() } jl_atexit_hook(); - SWAP_STACK_CHK_GUARD(a,b,c); return 0; } diff --git a/src/codegen.cpp b/src/codegen.cpp index 28b5f080701be..bd952f83e677b 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -121,7 +121,11 @@ extern "C" { #include "builtin_proto.h" -extern void *__stack_chk_guard; +#ifdef HAVE_SSP +extern uintptr_t __stack_chk_guard; +extern void __stack_chk_fail(); +#else +uintptr_t __stack_chk_guard = (uintptr_t)0xBAD57ACCBAD67ACC; // 0xBADSTACKBADSTACK #if defined(_OS_WINDOWS_) && !defined(_COMPILER_MINGW_) void __stack_chk_fail() #else @@ -132,6 +136,7 @@ void __attribute__(()) __stack_chk_fail() fprintf(stderr, "fatal error: stack corruption detected\n"); abort(); // end with abort, since the compiler destroyed the stack upon entry to this function } +#endif #ifdef _OS_WINDOWS_ #if defined(_CPU_X86_64_) diff --git a/src/init.c b/src/init.c index 54a0618c653d6..41c99e47b4a54 100644 --- a/src/init.c +++ b/src/init.c @@ -104,10 +104,6 @@ jl_compileropts_t jl_compileropts = { NULL, // julia_home int jl_boot_file_loaded = 0; int exit_on_sigint = 0; -void *__stack_chk_guard = NULL; -DLLEXPORT unsigned char *jl_stack_chk_guard = - (unsigned char *)&__stack_chk_guard; - char *jl_stack_lo; char *jl_stack_hi; size_t jl_page_size; diff --git a/src/julia.h b/src/julia.h index 2423e327d4754..cfff3af879c2c 100644 --- a/src/julia.h +++ b/src/julia.h @@ -1347,23 +1347,6 @@ extern DLLEXPORT jl_compileropts_t jl_compileropts; #define JL_COMPILEROPT_DUMPBITCODE_ON 1 #define JL_COMPILEROPT_DUMPBITCODE_OFF 2 -/* If you have the ability to generate random numbers -* in your kernel then they should be used here */ -DLLEXPORT extern unsigned char *jl_stack_chk_guard; -#define SWAP_STACK_CHK_GUARD(a,b,c) do { \ - a ^= jl_stack_chk_guard[sizeof(void*)-1]; \ - jl_stack_chk_guard[sizeof(void*)-1] ^= a; \ - a ^= jl_stack_chk_guard[sizeof(void*)-1]; \ - \ - b ^= jl_stack_chk_guard[sizeof(void*)-2]; \ - jl_stack_chk_guard[sizeof(void*)-2] ^= b; \ - b ^= jl_stack_chk_guard[sizeof(void*)-2]; \ - \ - c ^= jl_stack_chk_guard[0]; \ - jl_stack_chk_guard[0] ^= c; \ - c ^= jl_stack_chk_guard[0]; \ - } while (0) - #ifdef __cplusplus } #endif diff --git a/ui/repl.c b/ui/repl.c index 298f891742f84..4cf6e3230ad55 100644 --- a/ui/repl.c +++ b/ui/repl.c @@ -330,8 +330,6 @@ int wmain(int argc, wchar_t *argv[], wchar_t *envp[]) argv[i] = (wchar_t*)arg; } #endif - char a=255,b='\n',c=0; - SWAP_STACK_CHK_GUARD(a,b,c); libsupport_init(); parse_opts(&argc, (char***)&argv); if (lisp_prompt) { @@ -342,7 +340,6 @@ int wmain(int argc, wchar_t *argv[], wchar_t *envp[]) int ret = true_main(argc, (char**)argv); jl_atexit_hook(); julia_save(); - SWAP_STACK_CHK_GUARD(a,b,c); return ret; }