]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: -buildmode=pie for android/arm
authorDavid Crawshaw <crawshaw@golang.org>
Mon, 19 Oct 2015 16:54:38 +0000 (12:54 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Mon, 19 Oct 2015 18:02:08 +0000 (18:02 +0000)
Also make PIE executables the default build mode, as PIE executables
are required as of Android L.

For #10807

Change-Id: I86b7556b9792105cd2531df1b8f3c8f7a8c5d25c
Reviewed-on: https://go-review.googlesource.com/16055
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>

src/cmd/go/build.go

index 677e34c2b10b4563508705a804684ea33c350bf8..d4aeb705e76aa8855d817c54b077c96951f821fa 100644 (file)
@@ -353,10 +353,28 @@ func buildModeInit() {
                }
                ldBuildmode = "c-shared"
        case "default":
-               ldBuildmode = "exe"
+               switch platform {
+               case "android/arm":
+                       codegenArg = "-shared"
+                       ldBuildmode = "pie"
+               default:
+                       ldBuildmode = "exe"
+               }
        case "exe":
                pkgsFilter = pkgsMain
                ldBuildmode = "exe"
+       case "pie":
+               if gccgo {
+                       fatalf("-buildmode=pie not supported by gccgo")
+               } else {
+                       switch platform {
+                       case "android/arm":
+                               codegenArg = "-shared"
+                       default:
+                               fatalf("-buildmode=pie not supported on %s\n", platform)
+                       }
+               }
+               ldBuildmode = "pie"
        case "shared":
                pkgsFilter = pkgsNotMain
                if gccgo {