aboutsummaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-04-26 08:20:20 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-04-26 08:41:17 +0200
commitbef017f5fe7f65491f7efb3c6217e96823f9649e (patch)
treee4f9391d9cd63f7f7d912faf04e0d83f628eb629 /configure
parentf91bc4c7fcf3ea66f7c4e4d9ff65adf4db3de2a9 (diff)
downloadvis-bef017f5fe7f65491f7efb3c6217e96823f9649e.tar.gz
vis-bef017f5fe7f65491f7efb3c6217e96823f9649e.tar.xz
build: try to produce a statically linked position independent executable
In theory this should be as simple as: $ cc -fPIE -pie --static helloworld.c But unfortunately by default this will always add a PT_INTERP referencing the dynamic loader/linker. On latest binutils >=2.26 this can be worked around by supplying --no-dynamic-linker. Also tweak the musl-gcc wrapper to use rcrt1.o as startup file.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure10
1 files changed, 7 insertions, 3 deletions
diff --git a/configure b/configure
index 112a027..dfb8386 100755
--- a/configure
+++ b/configure
@@ -227,9 +227,13 @@ tryflag CFLAGS -fPIE
tryflag CFLAGS_AUTO -fstack-protector-all
tryldflag LDFLAGS -Wl,-z,now
tryldflag LDFLAGS -Wl,-z,relro
-# You can not link libraries with -pie (unless you add a main() function).
-# So keep this a vis-only flag.
-if test "$static" != "yes" ; then
+# in theory it should be perfectly fine to produce a staticically linked PIE
+# however in practice it is not yet properly supported by gcc:
+#
+# cc -fPIE -pie --static
+#
+# will always add a PT_INTERP referencing the dynamic loader/linker
+if test "$static" != "yes" || tryldflag LDFLAGS_AUTO -Wl,--no-dynamic-linker ; then
tryldflag LDFLAGS_AUTO -pie
fi