r207520 - Pass -pie to linker when generating executable on Android

Alexey Volkov avolkov.intel at gmail.com
Tue Apr 29 03:25:20 PDT 2014


Author: volkalex
Date: Tue Apr 29 05:25:20 2014
New Revision: 207520

URL: http://llvm.org/viewvc/llvm-project?rev=207520&view=rev
Log:
Pass -pie to linker when generating executable on Android
This fixes problem with LTO on Android.

Differential Revision: http://reviews.llvm.org/D2668

Modified:
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/gold-lto.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=207520&r1=207519&r2=207520&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Apr 29 05:25:20 2014
@@ -6917,7 +6917,10 @@ void gnutools::Link::ConstructJob(Compil
     ToolChain.getTriple().getEnvironment() == llvm::Triple::Android;
   const bool IsPIE =
     !Args.hasArg(options::OPT_shared) &&
-    (Args.hasArg(options::OPT_pie) || ToolChain.isPIEDefault());
+    !Args.hasArg(options::OPT_static) &&
+    (Args.hasArg(options::OPT_pie) || ToolChain.isPIEDefault() ||
+     // On Android every code is PIC so every executable is PIE
+     isAndroid);
 
   ArgStringList CmdArgs;
 

Modified: cfe/trunk/test/Driver/gold-lto.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gold-lto.c?rev=207520&r1=207519&r2=207520&view=diff
==============================================================================
--- cfe/trunk/test/Driver/gold-lto.c (original)
+++ cfe/trunk/test/Driver/gold-lto.c Tue Apr 29 05:25:20 2014
@@ -19,3 +19,8 @@
 // CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.so"
 // CHECK-ARM-V7A: "-plugin-opt=mcpu=cortex-a8"
 // CHECK-ARM-V7A: "-plugin-opt=foo"
+//
+// RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
+// RUN:     | FileCheck %s --check-prefix=CHECK-X86-ANDROID
+// CHECK-X86-ANDROID: "-pie"
+// CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so"





More information about the cfe-commits mailing list