From a632839e794a88ff6d7b819f118b82a538015937 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Wed, 16 Jan 2019 22:59:09 -0800 Subject: [PATCH] Added check in makefile to test for -no-pie support before using it --- makefile | 7 ++++++- meshcore/dummy.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 meshcore/dummy.c diff --git a/makefile b/makefile index 32c2810..bfc070a 100644 --- a/makefile +++ b/makefile @@ -87,7 +87,7 @@ INCDIRS = -I. -Iopenssl/include -Imicrostack -Imicroscript -Imeshcore -Imeshcons # Compiler and linker flags CFLAGS ?= -std=gnu99 -g -Wall -D_POSIX -DMICROSTACK_PROXY $(CWEBLOG) $(CWATCHDOG) -fno-strict-aliasing $(INCDIRS) -DDUK_USE_DEBUGGER_SUPPORT -DDUK_USE_INTERRUPT_COUNTER -DDUK_USE_DEBUGGER_INSPECT -DDUK_USE_DEBUGGER_PAUSE_UNCAUGHT -LDFLAGS ?= -L. -lpthread -ldl -lutil -lm -no-pie +LDFLAGS ?= -L. -lpthread -ldl -lutil -lm CEXTRA = -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -fstack-protector -fno-strict-aliasing LDEXTRA = @@ -278,6 +278,11 @@ ifeq ($(SSL_TRACE),1) CFLAGS += -DSSL_TRACE endif +GCCTEST := $(shell $(CC) meshcore/dummy.c -o /dev/null -no-pie > /dev/null 2>&1 ; echo $$? ) +ifeq ($(GCCTEST),0) +LDFLAGS += -no-pie +endif + .PHONY: all clean all: $(EXENAME) $(LIBNAME) diff --git a/meshcore/dummy.c b/meshcore/dummy.c new file mode 100644 index 0000000..1195225 --- /dev/null +++ b/meshcore/dummy.c @@ -0,0 +1,3 @@ +int main(int argc, char **argv) +{ +} \ No newline at end of file