aboutsummaryrefslogtreecommitdiff
path: root/Makefile.flags
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-06-04 11:28:24 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-06-04 11:28:24 +0000
commit1da86d2f40f304d78b2ae4aac3b590b19adc7ce3 (patch)
tree6f2a87934ad24c0e640c6313d56d2e28d1e81185 /Makefile.flags
parent1e93f3c5859aeebcca7c0480de2bd038defe8b1c (diff)
downloadbusybox-1da86d2f40f304d78b2ae4aac3b590b19adc7ce3.tar.gz
build system: add PIE build option
Diffstat (limited to 'Makefile.flags')
-rw-r--r--Makefile.flags20
1 files changed, 16 insertions, 4 deletions
diff --git a/Makefile.flags b/Makefile.flags
index 9525889c6..1cfda26ac 100644
--- a/Makefile.flags
+++ b/Makefile.flags
@@ -50,17 +50,31 @@ ifeq ($(CONFIG_DEBUG),y)
CFLAGS += $(call cc-option,-g)
endif
+# If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)...
+ARCH_FPIC ?= -fpic
+ARCH_FPIE ?= -fpie
+ARCH_PIE ?= -pie
+
ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
# on i386: 14% smaller libbusybox.so
# (code itself is 9% bigger, we save on relocs/PLT/GOT)
-CFLAGS += -fpic
+CFLAGS += $(ARCH_FPIC)
# and another 4% reduction of libbusybox.so:
# (external entry points must be marked EXTERNALLY_VISIBLE)
CFLAGS += $(call cc-option,-fvisibility=hidden)
endif
ifeq ($(CONFIG_STATIC),y)
-LDFLAGS += -static
+CFLAGS_busybox += -static
+endif
+
+ifeq ($(CONFIG_PIE),y)
+CFLAGS_busybox += $(ARCH_PIE)
+CFLAGS += $(ARCH_FPIE)
+# No switch() jump tables. Code growth +1k, binary size down -12k
+# due to reduced number of code pointers.
+# (TODO: make overridable: some arches may want to not do this)
+CFLAGS += $(call cc-option,-fno-jump-tables)
endif
LDLIBS += m crypt
@@ -81,8 +95,6 @@ ifeq ($(CONFIG_DMALLOC),y)
LDLIBS += dmalloc
endif
-#LDFLAGS += -nostdlib
-
LDFLAGS_ELF2FLT = -Wl,-elf2flt
ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
SKIP_STRIP = y