r258698 - Pass --wrap=pthread_create to linker for -fsplit-stack.
Rafael Espindola via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 25 10:29:17 PST 2016
Author: rafael
Date: Mon Jan 25 12:29:16 2016
New Revision: 258698
URL: http://llvm.org/viewvc/llvm-project?rev=258698&view=rev
Log:
Pass --wrap=pthread_create to linker for -fsplit-stack.
From
https://gcc.gnu.org/ml/gcc-patches/2010-09/msg01807.html
-fsplit-stack should pass --wrap=pthread_create to linker for -fsplit-stack
It is needed to initialize the stack guard. This fixes PR 20148.
Patch by H.J Lu!
Added:
cfe/trunk/test/Driver/split-stack-ld.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=258698&r1=258697&r2=258698&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Jan 25 12:29:16 2016
@@ -9001,6 +9001,9 @@ void gnutools::Linker::ConstructJob(Comp
if (WantPthread && !isAndroid)
CmdArgs.push_back("-lpthread");
+ if (Args.hasArg(options::OPT_fsplit_stack))
+ CmdArgs.push_back("--wrap=pthread_create");
+
CmdArgs.push_back("-lc");
if (Args.hasArg(options::OPT_static))
Added: cfe/trunk/test/Driver/split-stack-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/split-stack-ld.c?rev=258698&view=auto
==============================================================================
--- cfe/trunk/test/Driver/split-stack-ld.c (added)
+++ cfe/trunk/test/Driver/split-stack-ld.c Mon Jan 25 12:29:16 2016
@@ -0,0 +1,17 @@
+// Test split stack ld flags.
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fsplit-stack \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LINUX-I386 %s
+//
+// CHECK-LINUX-I386: "--wrap=pthread_create"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -fsplit-stack \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LINUX-X86-64 %s
+//
+// CHECK-LINUX-X86-64: "--wrap=pthread_create"
More information about the cfe-commits
mailing list