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-w32-1da86d2f40f304d78b2ae4aac3b590b19adc7ce3.tar.gz
busybox-w32-1da86d2f40f304d78b2ae4aac3b590b19adc7ce3.tar.bz2
busybox-w32-1da86d2f40f304d78b2ae4aac3b590b19adc7ce3.zip
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)
50CFLAGS += $(call cc-option,-g) 50CFLAGS += $(call cc-option,-g)
51endif 51endif
52 52
53# If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)...
54ARCH_FPIC ?= -fpic
55ARCH_FPIE ?= -fpie
56ARCH_PIE ?= -pie
57
53ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y) 58ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
54# on i386: 14% smaller libbusybox.so 59# on i386: 14% smaller libbusybox.so
55# (code itself is 9% bigger, we save on relocs/PLT/GOT) 60# (code itself is 9% bigger, we save on relocs/PLT/GOT)
56CFLAGS += -fpic 61CFLAGS += $(ARCH_FPIC)
57# and another 4% reduction of libbusybox.so: 62# and another 4% reduction of libbusybox.so:
58# (external entry points must be marked EXTERNALLY_VISIBLE) 63# (external entry points must be marked EXTERNALLY_VISIBLE)
59CFLAGS += $(call cc-option,-fvisibility=hidden) 64CFLAGS += $(call cc-option,-fvisibility=hidden)
60endif 65endif
61 66
62ifeq ($(CONFIG_STATIC),y) 67ifeq ($(CONFIG_STATIC),y)
63LDFLAGS += -static 68CFLAGS_busybox += -static
69endif
70
71ifeq ($(CONFIG_PIE),y)
72CFLAGS_busybox += $(ARCH_PIE)
73CFLAGS += $(ARCH_FPIE)
74# No switch() jump tables. Code growth +1k, binary size down -12k
75# due to reduced number of code pointers.
76# (TODO: make overridable: some arches may want to not do this)
77CFLAGS += $(call cc-option,-fno-jump-tables)
64endif 78endif
65 79
66LDLIBS += m crypt 80LDLIBS += m crypt
@@ -81,8 +95,6 @@ ifeq ($(CONFIG_DMALLOC),y)
81LDLIBS += dmalloc 95LDLIBS += dmalloc
82endif 96endif
83 97
84#LDFLAGS += -nostdlib
85
86LDFLAGS_ELF2FLT = -Wl,-elf2flt 98LDFLAGS_ELF2FLT = -Wl,-elf2flt
87ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS))) 99ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
88SKIP_STRIP = y 100SKIP_STRIP = y