From: Rahul Chaudhry Date: Fri, 27 Feb 2015 18:46:42 +0000 (-0800) Subject: build: run cgo tests with -pie if the external linker supports it. X-Git-Tag: go1.5beta1~1767 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=612dd6c26274d7183b21d38120bc98c45dcf2736;p=gostls13.git build: run cgo tests with -pie if the external linker supports it. PIE binaries can be built by the Go compiler in external link mode with extldflags="-pie". These binaries support ASLR (address space layout randomization) when executed on systems with appropriate kernel/dynamic linker support. This CL enables some cgo tests to run with -pie as a sanity check (in addition to the other linker flag combinations they already test). I have tested this functionality more thoroughly by building the full compiler testsuite (test/...) and standard library tests with -pie and executing them remotely on ChromeOS devices for all three linux architectures (linux_amd64, linux_386, and linux_arm). Change-Id: I3f644a72e94c3341f3360dfee58db5ec3a591e26 Reviewed-on: https://go-review.googlesource.com/6280 Reviewed-by: Ian Lance Taylor --- diff --git a/src/run.bash b/src/run.bash index 4177124e1b..90afaaa4e6 100755 --- a/src/run.bash +++ b/src/run.bash @@ -158,6 +158,13 @@ android-arm | dragonfly-386 | dragonfly-amd64 | freebsd-386 | freebsd-amd64 | fr go test -ldflags '-linkmode=external' ../nocgo || exit 1 go test -ldflags '-linkmode=external -extldflags "-static -pthread"' ../nocgo || exit 1 fi + if ! $CC -xc -o /dev/null -pie - 2>/dev/null <<<'int main() {}' ; then + echo "No support for -pie found, skip cgo PIE test." + else + go test -ldflags '-linkmode=external -extldflags "-pie"' || exit 1 + go test -ldflags '-linkmode=external -extldflags "-pie"' ../testtls || exit 1 + go test -ldflags '-linkmode=external -extldflags "-pie"' ../nocgo || exit 1 + fi ;; esac ;;