From e8b6f34ad12938dd58b7896d11ec543258ae7167 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 3 May 2016 21:38:14 +0200 Subject: fix compiler and linker flags and produce binaries with full RELRO --- Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 411a4f8..568d247 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,18 @@ # nullshell - do nothing but print asterisks, can be used for login shell PREFIX := /usr -CP := cp + +# commands CC := gcc -MD := markdown +CP := cp INSTALL := install +MD := markdown RM := rm -CFLAGS += -std=c11 -O2 -Wall -Werror + +# flags +CFLAGS += -std=c11 -O2 -fPIC -Wall -Werror +LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie + # this is just a fallback in case you do not use git but downloaded # a release tarball... VERSION := 0.0.6 @@ -14,7 +20,7 @@ VERSION := 0.0.6 all: nullshell README.html nullshell: nullshell.c config.h version.h - $(CC) $(CFLAGS) $(LDFLAGS) nullshell.c -o nullshell + $(CC) $(CFLAGS) $(LDFLAGS) -o nullshell nullshell.c version.h: $(wildcard .git/HEAD .git/index .git/refs/tags/*) Makefile echo "#ifndef VERSION" > $@ -- cgit v1.2.3-54-g00ecf