vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit e343e2fd97397f206ed7e20d189ef6eb94033176 parent 0ff7af63dce9665f6ae12d32123e9c82330e91e0 Author: Marc André Tanner <mat@brain-dump.org> Date: Tue, 26 Apr 2016 08:20:20 +0200 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:
| M | GNUmakefile | | | 2 | ++ |
| M | configure | | | 10 | +++++++--- |
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/GNUmakefile b/GNUmakefile @@ -51,6 +51,8 @@ dependency/build/libmusl-extract: dependency/sources/$(LIBMUSL).tar.gz | depende touch $@ dependency/build/libmusl-configure: dependency/build/libmusl-extract + # tweak musl gcc wrapper/spec file to support static PIE linking + sed -i 's#%{pie:S}crt1.o#%{pie:%{static:rcrt1.o%s;:Scrt1.o%s};:crt1.o%s}#' $(dir $<)/$(LIBMUSL)/tools/musl-gcc.specs.sh cd $(dir $<)/$(LIBMUSL) && ./configure --prefix=$(DEPS_PREFIX) --syslibdir=$(DEPS_PREFIX)/lib touch $@ diff --git 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