rpcd: iwinfo plugin fixes
[openwrt.git] / include / hardening.mk
1 #
2 # Copyright (C) 2015 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 PKG_CHECK_FORMAT_SECURITY ?= 1
9 PKG_SSP ?= 1
10 PKG_FORTIFY_SOURCE ?= 1
11 PKG_RELRO ?= 1
12
13 ifdef CONFIG_PKG_CHECK_FORMAT_SECURITY
14   ifeq ($(strip $(PKG_CHECK_FORMAT_SECURITY)),1)
15     TARGET_CFLAGS += -Wformat -Werror=format-security
16   endif
17 endif
18 ifdef CONFIG_PKG_CC_STACKPROTECTOR_REGULAR
19   ifeq ($(strip $(PKG_SSP)),1)
20     TARGET_CFLAGS += -fstack-protector
21   endif
22 endif
23 ifdef CONFIG_PKG_CC_STACKPROTECTOR_STRONG
24   ifeq ($(strip $(PKG_SSP)),1)
25     TARGET_CFLAGS += -fstack-protector-strong
26   endif
27 endif
28 ifdef CONFIG_PKG_FORTIFY_SOURCE_1
29   ifeq ($(strip $(PKG_FORTIFY_SOURCE)),1)
30     TARGET_CFLAGS += -D_FORTIFY_SOURCE=1
31   endif
32 endif
33 ifdef CONFIG_PKG_FORTIFY_SOURCE_2
34   ifeq ($(strip $(PKG_FORTIFY_SOURCE)),1)
35     TARGET_CFLAGS += -D_FORTIFY_SOURCE=2
36   endif
37 endif
38 ifdef CONFIG_PKG_RELRO_PARTIAL
39   ifeq ($(strip $(PKG_RELRO)),1)
40     TARGET_CFLAGS += -Wl,-z,relro
41     TARGET_LDFLAGS += -zrelro
42   endif
43 endif
44 ifdef CONFIG_PKG_RELRO_FULL
45   ifeq ($(strip $(PKG_RELRO)),1)
46     TARGET_CFLAGS += -Wl,-z,now -Wl,-z,relro
47     TARGET_LDFLAGS += -znow -zrelro
48   endif
49 endif
50