diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-04 11:28:24 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-04 11:28:24 +0000 |
commit | 1da86d2f40f304d78b2ae4aac3b590b19adc7ce3 (patch) | |
tree | 6f2a87934ad24c0e640c6313d56d2e28d1e81185 /Makefile.flags | |
parent | 1e93f3c5859aeebcca7c0480de2bd038defe8b1c (diff) | |
download | busybox-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.flags | 20 |
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) | |||
50 | CFLAGS += $(call cc-option,-g) | 50 | CFLAGS += $(call cc-option,-g) |
51 | endif | 51 | endif |
52 | 52 | ||
53 | # If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)... | ||
54 | ARCH_FPIC ?= -fpic | ||
55 | ARCH_FPIE ?= -fpie | ||
56 | ARCH_PIE ?= -pie | ||
57 | |||
53 | ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y) | 58 | ifeq ($(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) |
56 | CFLAGS += -fpic | 61 | CFLAGS += $(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) |
59 | CFLAGS += $(call cc-option,-fvisibility=hidden) | 64 | CFLAGS += $(call cc-option,-fvisibility=hidden) |
60 | endif | 65 | endif |
61 | 66 | ||
62 | ifeq ($(CONFIG_STATIC),y) | 67 | ifeq ($(CONFIG_STATIC),y) |
63 | LDFLAGS += -static | 68 | CFLAGS_busybox += -static |
69 | endif | ||
70 | |||
71 | ifeq ($(CONFIG_PIE),y) | ||
72 | CFLAGS_busybox += $(ARCH_PIE) | ||
73 | CFLAGS += $(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) | ||
77 | CFLAGS += $(call cc-option,-fno-jump-tables) | ||
64 | endif | 78 | endif |
65 | 79 | ||
66 | LDLIBS += m crypt | 80 | LDLIBS += m crypt |
@@ -81,8 +95,6 @@ ifeq ($(CONFIG_DMALLOC),y) | |||
81 | LDLIBS += dmalloc | 95 | LDLIBS += dmalloc |
82 | endif | 96 | endif |
83 | 97 | ||
84 | #LDFLAGS += -nostdlib | ||
85 | |||
86 | LDFLAGS_ELF2FLT = -Wl,-elf2flt | 98 | LDFLAGS_ELF2FLT = -Wl,-elf2flt |
87 | ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS))) | 99 | ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS))) |
88 | SKIP_STRIP = y | 100 | SKIP_STRIP = y |