build/toolchain/musl-host-gcc: add pie feature, disabled by default

This isn't enabled anywhere, but we should enable it for all of our
binaries.

Change-Id: I77dc163a7085c792c0b0d64e6423e9117b596ec4
Reviewed-on: https://review.monogon.dev/c/monogon/+/1838
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
Tested-by: Jenkins CI
diff --git a/build/toolchain/musl-host-gcc/musl.spec b/build/toolchain/musl-host-gcc/musl.spec
index c726fe5..49f0176 100644
--- a/build/toolchain/musl-host-gcc/musl.spec
+++ b/build/toolchain/musl-host-gcc/musl.spec
@@ -13,13 +13,13 @@
 libgcc.a%s %:if-exists(libgcc_eh.a%s)
 
 *startfile:
-%{!shared: %R/lib/Scrt1.o} %R/lib/crti.o crtbeginS.o%s
+%{static-pie: %R/lib/rcrt1.o; !shared: %R/lib/Scrt1.o} %R/lib/crti.o crtbeginS.o%s
 
 *endfile:
 crtendS.o%s %R/lib/crtn.o
 
 *link:
--no-dynamic-linker -nostdlib -static %{rdynamic:-export-dynamic}
+%{static-pie: -pie} -no-dynamic-linker -nostdlib -static %{rdynamic:-export-dynamic}
 
 *esp_link: