1 --- a/arch/mips/Makefile
2 +++ b/arch/mips/Makefile
3 @@ -89,10 +89,14 @@ all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlin
5 cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
6 cflags-y += -msoft-float
7 -LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
8 +LDFLAGS_vmlinux += -G 0 -static -n -nostdlib --gc-sections
9 KBUILD_AFLAGS_MODULE += -mlong-calls
10 KBUILD_CFLAGS_MODULE += -mlong-calls
12 +ifndef CONFIG_FUNCTION_TRACER
13 +KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
16 cflags-y += -ffreestanding
19 --- a/arch/mips/kernel/vmlinux.lds.S
20 +++ b/arch/mips/kernel/vmlinux.lds.S
21 @@ -67,7 +67,7 @@ SECTIONS
22 /* Exception table for data bus errors */
24 __start___dbe_table = .;
26 + KEEP(*(__dbe_table))
27 __stop___dbe_table = .;
30 @@ -112,7 +112,7 @@ SECTIONS
32 .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
33 __mips_machines_start = .;
34 - *(.mips.machines.init)
35 + KEEP(*(.mips.machines.init))
36 __mips_machines_end = .;
39 --- a/include/asm-generic/vmlinux.lds.h
40 +++ b/include/asm-generic/vmlinux.lds.h
42 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
43 #define MCOUNT_REC() . = ALIGN(8); \
44 VMLINUX_SYMBOL(__start_mcount_loc) = .; \
46 + KEEP(*(__mcount_loc)) \
47 VMLINUX_SYMBOL(__stop_mcount_loc) = .;
52 #ifdef CONFIG_TRACE_BRANCH_PROFILING
53 #define LIKELY_PROFILE() VMLINUX_SYMBOL(__start_annotated_branch_profile) = .; \
54 - *(_ftrace_annotated_branch) \
55 + KEEP(*(_ftrace_annotated_branch)) \
56 VMLINUX_SYMBOL(__stop_annotated_branch_profile) = .;
58 #define LIKELY_PROFILE()
61 #ifdef CONFIG_PROFILE_ALL_BRANCHES
62 #define BRANCH_PROFILE() VMLINUX_SYMBOL(__start_branch_profile) = .; \
64 + KEEP(*(_ftrace_branch)) \
65 VMLINUX_SYMBOL(__stop_branch_profile) = .;
67 #define BRANCH_PROFILE()
69 #ifdef CONFIG_EVENT_TRACING
70 #define FTRACE_EVENTS() . = ALIGN(8); \
71 VMLINUX_SYMBOL(__start_ftrace_events) = .; \
73 + KEEP(*(_ftrace_events)) \
74 VMLINUX_SYMBOL(__stop_ftrace_events) = .;
76 #define FTRACE_EVENTS()
80 #define TRACE_PRINTKS() VMLINUX_SYMBOL(__start___trace_bprintk_fmt) = .; \
81 - *(__trace_printk_fmt) /* Trace_printk fmt' pointer */ \
82 + KEEP(*(__trace_printk_fmt)) /* Trace_printk fmt' pointer */ \
83 VMLINUX_SYMBOL(__stop___trace_bprintk_fmt) = .;
85 #define TRACE_PRINTKS()
87 #ifdef CONFIG_FTRACE_SYSCALLS
88 #define TRACE_SYSCALLS() . = ALIGN(8); \
89 VMLINUX_SYMBOL(__start_syscalls_metadata) = .; \
90 - *(__syscalls_metadata) \
91 + KEEP(*(__syscalls_metadata)) \
92 VMLINUX_SYMBOL(__stop_syscalls_metadata) = .;
94 #define TRACE_SYSCALLS()
96 #ifdef CONFIG_CLKSRC_OF
97 #define CLKSRC_OF_TABLES() . = ALIGN(8); \
98 VMLINUX_SYMBOL(__clksrc_of_table) = .; \
99 - *(__clksrc_of_table) \
100 - *(__clksrc_of_table_end)
101 + KEEP(*(__clksrc_of_table)) \
102 + KEEP(*(__clksrc_of_table_end))
104 #define CLKSRC_OF_TABLES()
107 #define IRQCHIP_OF_MATCH_TABLE() \
109 VMLINUX_SYMBOL(__irqchip_begin) = .; \
110 - *(__irqchip_of_table) \
111 - *(__irqchip_of_end)
112 + KEEP(*(__irqchip_of_table)) \
113 + KEEP(*(__irqchip_of_end))
115 #define IRQCHIP_OF_MATCH_TABLE()
118 #ifdef CONFIG_COMMON_CLK
119 #define CLK_OF_TABLES() . = ALIGN(8); \
120 VMLINUX_SYMBOL(__clk_of_table) = .; \
121 - *(__clk_of_table) \
122 - *(__clk_of_table_end)
123 + KEEP(*(__clk_of_table)) \
124 + KEEP(*(__clk_of_table_end))
126 #define CLK_OF_TABLES()
129 #define KERNEL_DTB() \
131 VMLINUX_SYMBOL(__dtb_start) = .; \
132 - *(.dtb.init.rodata) \
133 + KEEP(*(.dtb.init.rodata)) \
134 VMLINUX_SYMBOL(__dtb_end) = .;
137 @@ -200,15 +200,16 @@
138 /* implement dynamic printk debug */ \
140 VMLINUX_SYMBOL(__start___jump_table) = .; \
142 + KEEP(*(__jump_table)) \
143 VMLINUX_SYMBOL(__stop___jump_table) = .; \
145 VMLINUX_SYMBOL(__start___verbose) = .; \
147 + KEEP(*(__verbose)) \
148 VMLINUX_SYMBOL(__stop___verbose) = .; \
153 + *(.data.[a-zA-Z_]*)
156 * Data section helpers
157 @@ -262,39 +263,39 @@
159 .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \
160 VMLINUX_SYMBOL(__start_pci_fixups_early) = .; \
161 - *(.pci_fixup_early) \
162 + KEEP(*(.pci_fixup_early)) \
163 VMLINUX_SYMBOL(__end_pci_fixups_early) = .; \
164 VMLINUX_SYMBOL(__start_pci_fixups_header) = .; \
165 - *(.pci_fixup_header) \
166 + KEEP(*(.pci_fixup_header)) \
167 VMLINUX_SYMBOL(__end_pci_fixups_header) = .; \
168 VMLINUX_SYMBOL(__start_pci_fixups_final) = .; \
169 - *(.pci_fixup_final) \
170 + KEEP(*(.pci_fixup_final)) \
171 VMLINUX_SYMBOL(__end_pci_fixups_final) = .; \
172 VMLINUX_SYMBOL(__start_pci_fixups_enable) = .; \
173 - *(.pci_fixup_enable) \
174 + KEEP(*(.pci_fixup_enable)) \
175 VMLINUX_SYMBOL(__end_pci_fixups_enable) = .; \
176 VMLINUX_SYMBOL(__start_pci_fixups_resume) = .; \
177 - *(.pci_fixup_resume) \
178 + KEEP(*(.pci_fixup_resume)) \
179 VMLINUX_SYMBOL(__end_pci_fixups_resume) = .; \
180 VMLINUX_SYMBOL(__start_pci_fixups_resume_early) = .; \
181 - *(.pci_fixup_resume_early) \
182 + KEEP(*(.pci_fixup_resume_early)) \
183 VMLINUX_SYMBOL(__end_pci_fixups_resume_early) = .; \
184 VMLINUX_SYMBOL(__start_pci_fixups_suspend) = .; \
185 - *(.pci_fixup_suspend) \
186 + KEEP(*(.pci_fixup_suspend)) \
187 VMLINUX_SYMBOL(__end_pci_fixups_suspend) = .; \
190 /* Built-in firmware blobs */ \
191 .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) { \
192 VMLINUX_SYMBOL(__start_builtin_fw) = .; \
194 + KEEP(*(.builtin_fw)) \
195 VMLINUX_SYMBOL(__end_builtin_fw) = .; \
198 /* RapidIO route ops */ \
199 .rio_ops : AT(ADDR(.rio_ops) - LOAD_OFFSET) { \
200 VMLINUX_SYMBOL(__start_rio_switch_ops) = .; \
201 - *(.rio_switch_ops) \
202 + KEEP(*(.rio_switch_ops)) \
203 VMLINUX_SYMBOL(__end_rio_switch_ops) = .; \
206 @@ -303,49 +304,49 @@
207 /* Kernel symbol table: Normal symbols */ \
208 __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
209 VMLINUX_SYMBOL(__start___ksymtab) = .; \
210 - *(SORT(___ksymtab+*)) \
211 + KEEP(*(SORT(___ksymtab+*))) \
212 VMLINUX_SYMBOL(__stop___ksymtab) = .; \
215 /* Kernel symbol table: GPL-only symbols */ \
216 __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
217 VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
218 - *(SORT(___ksymtab_gpl+*)) \
219 + KEEP(*(SORT(___ksymtab_gpl+*))) \
220 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
223 /* Kernel symbol table: Normal unused symbols */ \
224 __ksymtab_unused : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) { \
225 VMLINUX_SYMBOL(__start___ksymtab_unused) = .; \
226 - *(SORT(___ksymtab_unused+*)) \
227 + KEEP(*(SORT(___ksymtab_unused+*))) \
228 VMLINUX_SYMBOL(__stop___ksymtab_unused) = .; \
231 /* Kernel symbol table: GPL-only unused symbols */ \
232 __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \
233 VMLINUX_SYMBOL(__start___ksymtab_unused_gpl) = .; \
234 - *(SORT(___ksymtab_unused_gpl+*)) \
235 + KEEP(*(SORT(___ksymtab_unused_gpl+*))) \
236 VMLINUX_SYMBOL(__stop___ksymtab_unused_gpl) = .; \
239 /* Kernel symbol table: GPL-future-only symbols */ \
240 __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
241 VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .; \
242 - *(SORT(___ksymtab_gpl_future+*)) \
243 + KEEP(*(SORT(___ksymtab_gpl_future+*))) \
244 VMLINUX_SYMBOL(__stop___ksymtab_gpl_future) = .; \
247 /* Kernel symbol table: Normal symbols */ \
248 __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
249 VMLINUX_SYMBOL(__start___kcrctab) = .; \
250 - *(SORT(___kcrctab+*)) \
251 + KEEP(*(SORT(___kcrctab+*))) \
252 VMLINUX_SYMBOL(__stop___kcrctab) = .; \
255 /* Kernel symbol table: GPL-only symbols */ \
256 __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \
257 VMLINUX_SYMBOL(__start___kcrctab_gpl) = .; \
258 - *(SORT(___kcrctab_gpl+*)) \
259 + KEEP(*(SORT(___kcrctab_gpl+*))) \
260 VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \
263 @@ -359,14 +360,14 @@
264 /* Kernel symbol table: GPL-only unused symbols */ \
265 __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - LOAD_OFFSET) { \
266 VMLINUX_SYMBOL(__start___kcrctab_unused_gpl) = .; \
267 - *(SORT(___kcrctab_unused_gpl+*)) \
268 + KEEP(*(SORT(___kcrctab_unused_gpl+*))) \
269 VMLINUX_SYMBOL(__stop___kcrctab_unused_gpl) = .; \
272 /* Kernel symbol table: GPL-future-only symbols */ \
273 __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \
274 VMLINUX_SYMBOL(__start___kcrctab_gpl_future) = .; \
275 - *(SORT(___kcrctab_gpl_future+*)) \
276 + KEEP(*(SORT(___kcrctab_gpl_future+*))) \
277 VMLINUX_SYMBOL(__stop___kcrctab_gpl_future) = .; \
280 @@ -389,14 +390,14 @@
281 /* Built-in module parameters. */ \
282 __param : AT(ADDR(__param) - LOAD_OFFSET) { \
283 VMLINUX_SYMBOL(__start___param) = .; \
286 VMLINUX_SYMBOL(__stop___param) = .; \
289 /* Built-in module versions. */ \
290 __modver : AT(ADDR(__modver) - LOAD_OFFSET) { \
291 VMLINUX_SYMBOL(__start___modver) = .; \
293 + KEEP(*(__modver)) \
294 VMLINUX_SYMBOL(__stop___modver) = .; \
295 . = ALIGN((align)); \
296 VMLINUX_SYMBOL(__end_rodata) = .; \
300 VMLINUX_SYMBOL(__entry_text_start) = .; \
302 + KEEP(*(.entry.text)) \
303 VMLINUX_SYMBOL(__entry_text_end) = .;
305 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
308 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \
309 VMLINUX_SYMBOL(__start___ex_table) = .; \
311 + KEEP(*(__ex_table)) \
312 VMLINUX_SYMBOL(__stop___ex_table) = .; \
316 #ifdef CONFIG_CONSTRUCTORS
317 #define KERNEL_CTORS() . = ALIGN(8); \
318 VMLINUX_SYMBOL(__ctors_start) = .; \
321 VMLINUX_SYMBOL(__ctors_end) = .;
323 #define KERNEL_CTORS()
325 #define SBSS(sbss_align) \
326 . = ALIGN(sbss_align); \
327 .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
335 *(.bss..page_aligned) \
344 __bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) { \
345 VMLINUX_SYMBOL(__start___bug_table) = .; \
347 + KEEP(*(__bug_table)) \
348 VMLINUX_SYMBOL(__stop___bug_table) = .; \
353 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { \
354 VMLINUX_SYMBOL(__tracedata_start) = .; \
356 + KEEP(*(.tracedata)) \
357 VMLINUX_SYMBOL(__tracedata_end) = .; \
360 @@ -652,17 +653,17 @@
361 #define INIT_SETUP(initsetup_align) \
362 . = ALIGN(initsetup_align); \
363 VMLINUX_SYMBOL(__setup_start) = .; \
365 + KEEP(*(.init.setup)) \
366 VMLINUX_SYMBOL(__setup_end) = .;
368 #define INIT_CALLS_LEVEL(level) \
369 VMLINUX_SYMBOL(__initcall##level##_start) = .; \
370 - *(.initcall##level##.init) \
371 - *(.initcall##level##s.init) \
372 + KEEP(*(.initcall##level##.init)) \
373 + KEEP(*(.initcall##level##s.init)) \
376 VMLINUX_SYMBOL(__initcall_start) = .; \
377 - *(.initcallearly.init) \
378 + KEEP(*(.initcallearly.init)) \
379 INIT_CALLS_LEVEL(0) \
380 INIT_CALLS_LEVEL(1) \
381 INIT_CALLS_LEVEL(2) \
382 @@ -676,21 +677,21 @@
384 #define CON_INITCALL \
385 VMLINUX_SYMBOL(__con_initcall_start) = .; \
386 - *(.con_initcall.init) \
387 + KEEP(*(.con_initcall.init)) \
388 VMLINUX_SYMBOL(__con_initcall_end) = .;
390 #define SECURITY_INITCALL \
391 VMLINUX_SYMBOL(__security_initcall_start) = .; \
392 - *(.security_initcall.init) \
393 + KEEP(*(.security_initcall.init)) \
394 VMLINUX_SYMBOL(__security_initcall_end) = .;
396 #ifdef CONFIG_BLK_DEV_INITRD
397 #define INIT_RAM_FS \
399 VMLINUX_SYMBOL(__initramfs_start) = .; \
401 + KEEP(*(.init.ramfs)) \
403 - *(.init.ramfs.info)
404 + KEEP(*(.init.ramfs.info))
408 --- a/arch/arm/Makefile
409 +++ b/arch/arm/Makefile
410 @@ -17,11 +17,16 @@ LDFLAGS_vmlinux :=-p --no-undefined -X
411 ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
412 LDFLAGS_vmlinux += --be8
414 +LDFLAGS_vmlinux += --gc-sections
416 OBJCOPYFLAGS :=-O binary -R .comment -S
418 #KBUILD_CFLAGS +=-pipe
420 +ifndef CONFIG_FUNCTION_TRACER
421 +KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
424 # Never generate .eh_frame
425 KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
427 --- a/arch/arm/kernel/vmlinux.lds.S
428 +++ b/arch/arm/kernel/vmlinux.lds.S
432 VMLINUX_SYMBOL(__proc_info_begin) = .; \
433 - *(.proc.info.init) \
434 + KEEP(*(.proc.info.init)) \
435 VMLINUX_SYMBOL(__proc_info_end) = .;
439 VMLINUX_SYMBOL(__idmap_text_start) = .; \
441 + KEEP(*(.idmap.text)) \
442 VMLINUX_SYMBOL(__idmap_text_end) = .; \
444 VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \
445 @@ -97,7 +97,7 @@ SECTIONS
446 .text : { /* Real text segment */
447 _stext = .; /* Text and read-only data */
448 __exception_text_start = .;
450 + KEEP(*(.exception.text))
451 __exception_text_end = .;
454 @@ -122,7 +122,7 @@ SECTIONS
455 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
456 __start___ex_table = .;
459 + KEEP(*(__ex_table))
461 __stop___ex_table = .;
463 @@ -134,12 +134,12 @@ SECTIONS
466 __start_unwind_idx = .;
468 + KEEP(*(.ARM.exidx*))
469 __stop_unwind_idx = .;
472 __start_unwind_tab = .;
474 + KEEP(*(.ARM.extab*))
475 __stop_unwind_tab = .;
478 @@ -162,24 +162,24 @@ SECTIONS
481 __arch_info_begin = .;
483 + KEEP(*(.arch.info.init))
487 __tagtable_begin = .;
489 + KEEP(*(.taglist.init))
492 #ifdef CONFIG_SMP_ON_UP
496 + KEEP(*(.alt.smp.init))
501 __pv_table_begin = .;
507 --- a/arch/arm/boot/compressed/Makefile
508 +++ b/arch/arm/boot/compressed/Makefile
509 @@ -119,6 +119,7 @@ ifeq ($(CONFIG_FUNCTION_TRACER),y)
510 ORIG_CFLAGS := $(KBUILD_CFLAGS)
511 KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
513 +KBUILD_CFLAGS_KERNEL := $(patsubst -f%-sections,,$(KBUILD_CFLAGS_KERNEL))
515 ccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj)
516 asflags-y := -DZIMAGE