ath25: switch default kernel to 5.15
[openwrt/openwrt.git] / target / linux / generic / hack-5.10 / 220-arm-gc_sections.patch
1 From e3d8676f5722b7622685581e06e8f53e6138e3ab Mon Sep 17 00:00:00 2001
2 From: Felix Fietkau <nbd@nbd.name>
3 Date: Sat, 15 Jul 2017 23:42:36 +0200
4 Subject: use -ffunction-sections, -fdata-sections and --gc-sections
5
6 In combination with kernel symbol export stripping this significantly reduces
7 the kernel image size. Used on both ARM and MIPS architectures.
8
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
11 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
12 ---
13 --- a/arch/arm/Kconfig
14 +++ b/arch/arm/Kconfig
15 @@ -114,6 +114,7 @@ config ARM
16 select HAVE_UID16
17 select HAVE_VIRT_CPU_ACCOUNTING_GEN
18 select IRQ_FORCED_THREADING
19 + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
20 select MODULES_USE_ELF_REL
21 select NEED_DMA_MAP_STATE
22 select OF_EARLY_FLATTREE if OF
23 --- a/arch/arm/boot/compressed/Makefile
24 +++ b/arch/arm/boot/compressed/Makefile
25 @@ -100,6 +100,7 @@ $(foreach o, $(libfdt_objs) atags_to_fdt
26 ifdef building_out_of_srctree
27 $(shell rm -f $(addprefix $(obj)/, fdt_rw.c fdt_ro.c fdt_wip.c fdt.c))
28 endif
29 +KBUILD_CFLAGS_KERNEL := $(patsubst -f%-sections,,$(KBUILD_CFLAGS_KERNEL))
30
31 targets := vmlinux vmlinux.lds piggy_data piggy.o \
32 lib1funcs.o ashldi3.o bswapsdi2.o \
33 --- a/arch/arm/kernel/vmlinux.lds.S
34 +++ b/arch/arm/kernel/vmlinux.lds.S
35 @@ -75,7 +75,7 @@ SECTIONS
36 . = ALIGN(4);
37 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
38 __start___ex_table = .;
39 - ARM_MMU_KEEP(*(__ex_table))
40 + KEEP(*(__ex_table))
41 __stop___ex_table = .;
42 }
43
44 @@ -100,24 +100,24 @@ SECTIONS
45 }
46 .init.arch.info : {
47 __arch_info_begin = .;
48 - *(.arch.info.init)
49 + KEEP(*(.arch.info.init))
50 __arch_info_end = .;
51 }
52 .init.tagtable : {
53 __tagtable_begin = .;
54 - *(.taglist.init)
55 + KEEP(*(.taglist.init))
56 __tagtable_end = .;
57 }
58 #ifdef CONFIG_SMP_ON_UP
59 .init.smpalt : {
60 __smpalt_begin = .;
61 - *(.alt.smp.init)
62 + KEEP(*(.alt.smp.init))
63 __smpalt_end = .;
64 }
65 #endif
66 .init.pv_table : {
67 __pv_table_begin = .;
68 - *(.pv_table)
69 + KEEP(*(.pv_table))
70 __pv_table_end = .;
71 }
72
73 --- a/arch/arm/include/asm/vmlinux.lds.h
74 +++ b/arch/arm/include/asm/vmlinux.lds.h
75 @@ -42,13 +42,13 @@
76 #define PROC_INFO \
77 . = ALIGN(4); \
78 __proc_info_begin = .; \
79 - *(.proc.info.init) \
80 + KEEP(*(.proc.info.init)) \
81 __proc_info_end = .;
82
83 #define IDMAP_TEXT \
84 ALIGN_FUNCTION(); \
85 __idmap_text_start = .; \
86 - *(.idmap.text) \
87 + KEEP(*(.idmap.text)) \
88 __idmap_text_end = .; \
89
90 #define ARM_DISCARD \
91 @@ -109,12 +109,12 @@
92 . = ALIGN(8); \
93 .ARM.unwind_idx : { \
94 __start_unwind_idx = .; \
95 - *(.ARM.exidx*) \
96 + KEEP(*(.ARM.exidx*)) \
97 __stop_unwind_idx = .; \
98 } \
99 .ARM.unwind_tab : { \
100 __start_unwind_tab = .; \
101 - *(.ARM.extab*) \
102 + KEEP(*(.ARM.extab*)) \
103 __stop_unwind_tab = .; \
104 }
105
106 @@ -126,7 +126,7 @@
107 __vectors_lma = .; \
108 OVERLAY 0xffff0000 : NOCROSSREFS AT(__vectors_lma) { \
109 .vectors { \
110 - *(.vectors) \
111 + KEEP(*(.vectors)) \
112 } \
113 .vectors.bhb.loop8 { \
114 *(.vectors.bhb.loop8) \
115 @@ -144,7 +144,7 @@
116 \
117 __stubs_lma = .; \
118 .stubs ADDR(.vectors) + 0x1000 : AT(__stubs_lma) { \
119 - *(.stubs) \
120 + KEEP(*(.stubs)) \
121 } \
122 ARM_LMA(__stubs, .stubs); \
123 . = __stubs_lma + SIZEOF(.stubs); \