Skip to content

Commit 17a256b

Browse files
committed
cmd/go: -buildmode=pie for android/arm
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 <[email protected]> Run-TryBot: David Crawshaw <[email protected]>
1 parent 26205cb commit 17a256b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/cmd/go/build.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,28 @@ func buildModeInit() {
353353
}
354354
ldBuildmode = "c-shared"
355355
case "default":
356-
ldBuildmode = "exe"
356+
switch platform {
357+
case "android/arm":
358+
codegenArg = "-shared"
359+
ldBuildmode = "pie"
360+
default:
361+
ldBuildmode = "exe"
362+
}
357363
case "exe":
358364
pkgsFilter = pkgsMain
359365
ldBuildmode = "exe"
366+
case "pie":
367+
if gccgo {
368+
fatalf("-buildmode=pie not supported by gccgo")
369+
} else {
370+
switch platform {
371+
case "android/arm":
372+
codegenArg = "-shared"
373+
default:
374+
fatalf("-buildmode=pie not supported on %s\n", platform)
375+
}
376+
}
377+
ldBuildmode = "pie"
360378
case "shared":
361379
pkgsFilter = pkgsNotMain
362380
if gccgo {

0 commit comments

Comments
 (0)