Build non-static binaries with PIE buildmode

We now add the `-buildmode pie` flag when building non-static binaries,
which enables the ASLR security mechanism.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
This commit is contained in:
Sascha Grunert 2021-05-26 09:45:44 +02:00
parent 6db6c80656
commit 39d9e98a6f
No known key found for this signature in database
GPG Key ID: 09D97D153EF94D93

View File

@ -412,6 +412,10 @@ kube::golang::set_platform_envs() {
export CGO_ENABLED=1
export CC=${KUBE_LINUX_AMD64_CC:-x86_64-linux-gnu-gcc}
;;
"linux/386")
export CGO_ENABLED=1
export CC=${KUBE_LINUX_386_CC:-i686-linux-gnu-gcc}
;;
"linux/arm")
export CGO_ENABLED=1
export CC=${KUBE_LINUX_ARM_CC:-arm-linux-gnueabihf-gcc}
@ -721,6 +725,7 @@ kube::golang::build_binaries_for_platform() {
-gcflags "${gogcflags:-}"
-asmflags "${goasmflags:-}"
-ldflags "${goldflags:-}"
-buildmode pie
-tags "${gotags:-}"
)
kube::golang::build_some_binaries "${nonstatics[@]}"