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 #define KERNEL_DTB() \
98 VMLINUX_SYMBOL(__dtb_start) = .; \
99 - *(.dtb.init.rodata) \
100 + KEEP(*(.dtb.init.rodata)) \
101 VMLINUX_SYMBOL(__dtb_end) = .;
104 @@ -200,15 +200,16 @@
105 /* implement dynamic printk debug */ \
107 VMLINUX_SYMBOL(__start___jump_table) = .; \
109 + KEEP(*(__jump_table)) \
110 VMLINUX_SYMBOL(__stop___jump_table) = .; \
112 VMLINUX_SYMBOL(__start___verbose) = .; \
114 + KEEP(*(__verbose)) \
115 VMLINUX_SYMBOL(__stop___verbose) = .; \
120 + *(.data.[a-zA-Z_]*)
123 * Data section helpers
124 @@ -262,39 +263,39 @@
126 .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \
127 VMLINUX_SYMBOL(__start_pci_fixups_early) = .; \
128 - *(.pci_fixup_early) \
129 + KEEP(*(.pci_fixup_early)) \
130 VMLINUX_SYMBOL(__end_pci_fixups_early) = .; \
131 VMLINUX_SYMBOL(__start_pci_fixups_header) = .; \
132 - *(.pci_fixup_header) \
133 + KEEP(*(.pci_fixup_header)) \
134 VMLINUX_SYMBOL(__end_pci_fixups_header) = .; \
135 VMLINUX_SYMBOL(__start_pci_fixups_final) = .; \
136 - *(.pci_fixup_final) \
137 + KEEP(*(.pci_fixup_final)) \
138 VMLINUX_SYMBOL(__end_pci_fixups_final) = .; \
139 VMLINUX_SYMBOL(__start_pci_fixups_enable) = .; \
140 - *(.pci_fixup_enable) \
141 + KEEP(*(.pci_fixup_enable)) \
142 VMLINUX_SYMBOL(__end_pci_fixups_enable) = .; \
143 VMLINUX_SYMBOL(__start_pci_fixups_resume) = .; \
144 - *(.pci_fixup_resume) \
145 + KEEP(*(.pci_fixup_resume)) \
146 VMLINUX_SYMBOL(__end_pci_fixups_resume) = .; \
147 VMLINUX_SYMBOL(__start_pci_fixups_resume_early) = .; \
148 - *(.pci_fixup_resume_early) \
149 + KEEP(*(.pci_fixup_resume_early)) \
150 VMLINUX_SYMBOL(__end_pci_fixups_resume_early) = .; \
151 VMLINUX_SYMBOL(__start_pci_fixups_suspend) = .; \
152 - *(.pci_fixup_suspend) \
153 + KEEP(*(.pci_fixup_suspend)) \
154 VMLINUX_SYMBOL(__end_pci_fixups_suspend) = .; \
157 /* Built-in firmware blobs */ \
158 .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) { \
159 VMLINUX_SYMBOL(__start_builtin_fw) = .; \
161 + KEEP(*(.builtin_fw)) \
162 VMLINUX_SYMBOL(__end_builtin_fw) = .; \
165 /* RapidIO route ops */ \
166 .rio_ops : AT(ADDR(.rio_ops) - LOAD_OFFSET) { \
167 VMLINUX_SYMBOL(__start_rio_switch_ops) = .; \
168 - *(.rio_switch_ops) \
169 + KEEP(*(.rio_switch_ops)) \
170 VMLINUX_SYMBOL(__end_rio_switch_ops) = .; \
173 @@ -303,49 +304,49 @@
174 /* Kernel symbol table: Normal symbols */ \
175 __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
176 VMLINUX_SYMBOL(__start___ksymtab) = .; \
177 - *(SORT(___ksymtab+*)) \
178 + KEEP(*(SORT(___ksymtab+*))) \
179 VMLINUX_SYMBOL(__stop___ksymtab) = .; \
182 /* Kernel symbol table: GPL-only symbols */ \
183 __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
184 VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
185 - *(SORT(___ksymtab_gpl+*)) \
186 + KEEP(*(SORT(___ksymtab_gpl+*))) \
187 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
190 /* Kernel symbol table: Normal unused symbols */ \
191 __ksymtab_unused : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) { \
192 VMLINUX_SYMBOL(__start___ksymtab_unused) = .; \
193 - *(SORT(___ksymtab_unused+*)) \
194 + KEEP(*(SORT(___ksymtab_unused+*))) \
195 VMLINUX_SYMBOL(__stop___ksymtab_unused) = .; \
198 /* Kernel symbol table: GPL-only unused symbols */ \
199 __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \
200 VMLINUX_SYMBOL(__start___ksymtab_unused_gpl) = .; \
201 - *(SORT(___ksymtab_unused_gpl+*)) \
202 + KEEP(*(SORT(___ksymtab_unused_gpl+*))) \
203 VMLINUX_SYMBOL(__stop___ksymtab_unused_gpl) = .; \
206 /* Kernel symbol table: GPL-future-only symbols */ \
207 __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
208 VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .; \
209 - *(SORT(___ksymtab_gpl_future+*)) \
210 + KEEP(*(SORT(___ksymtab_gpl_future+*))) \
211 VMLINUX_SYMBOL(__stop___ksymtab_gpl_future) = .; \
214 /* Kernel symbol table: Normal symbols */ \
215 __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
216 VMLINUX_SYMBOL(__start___kcrctab) = .; \
217 - *(SORT(___kcrctab+*)) \
218 + KEEP(*(SORT(___kcrctab+*))) \
219 VMLINUX_SYMBOL(__stop___kcrctab) = .; \
222 /* Kernel symbol table: GPL-only symbols */ \
223 __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \
224 VMLINUX_SYMBOL(__start___kcrctab_gpl) = .; \
225 - *(SORT(___kcrctab_gpl+*)) \
226 + KEEP(*(SORT(___kcrctab_gpl+*))) \
227 VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \
230 @@ -359,14 +360,14 @@
231 /* Kernel symbol table: GPL-only unused symbols */ \
232 __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - LOAD_OFFSET) { \
233 VMLINUX_SYMBOL(__start___kcrctab_unused_gpl) = .; \
234 - *(SORT(___kcrctab_unused_gpl+*)) \
235 + KEEP(*(SORT(___kcrctab_unused_gpl+*))) \
236 VMLINUX_SYMBOL(__stop___kcrctab_unused_gpl) = .; \
239 /* Kernel symbol table: GPL-future-only symbols */ \
240 __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \
241 VMLINUX_SYMBOL(__start___kcrctab_gpl_future) = .; \
242 - *(SORT(___kcrctab_gpl_future+*)) \
243 + KEEP(*(SORT(___kcrctab_gpl_future+*))) \
244 VMLINUX_SYMBOL(__stop___kcrctab_gpl_future) = .; \
247 @@ -389,14 +390,14 @@
248 /* Built-in module parameters. */ \
249 __param : AT(ADDR(__param) - LOAD_OFFSET) { \
250 VMLINUX_SYMBOL(__start___param) = .; \
253 VMLINUX_SYMBOL(__stop___param) = .; \
256 /* Built-in module versions. */ \
257 __modver : AT(ADDR(__modver) - LOAD_OFFSET) { \
258 VMLINUX_SYMBOL(__start___modver) = .; \
260 + KEEP(*(__modver)) \
261 VMLINUX_SYMBOL(__stop___modver) = .; \
262 . = ALIGN((align)); \
263 VMLINUX_SYMBOL(__end_rodata) = .; \
267 VMLINUX_SYMBOL(__entry_text_start) = .; \
269 + KEEP(*(.entry.text)) \
270 VMLINUX_SYMBOL(__entry_text_end) = .;
272 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
275 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \
276 VMLINUX_SYMBOL(__start___ex_table) = .; \
278 + KEEP(*(__ex_table)) \
279 VMLINUX_SYMBOL(__stop___ex_table) = .; \
283 #ifdef CONFIG_CONSTRUCTORS
284 #define KERNEL_CTORS() . = ALIGN(8); \
285 VMLINUX_SYMBOL(__ctors_start) = .; \
288 VMLINUX_SYMBOL(__ctors_end) = .;
290 #define KERNEL_CTORS()
292 #define SBSS(sbss_align) \
293 . = ALIGN(sbss_align); \
294 .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
302 *(.bss..page_aligned) \
311 __bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) { \
312 VMLINUX_SYMBOL(__start___bug_table) = .; \
314 + KEEP(*(__bug_table)) \
315 VMLINUX_SYMBOL(__stop___bug_table) = .; \
320 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { \
321 VMLINUX_SYMBOL(__tracedata_start) = .; \
323 + KEEP(*(.tracedata)) \
324 VMLINUX_SYMBOL(__tracedata_end) = .; \
327 @@ -652,17 +653,17 @@
328 #define INIT_SETUP(initsetup_align) \
329 . = ALIGN(initsetup_align); \
330 VMLINUX_SYMBOL(__setup_start) = .; \
332 + KEEP(*(.init.setup)) \
333 VMLINUX_SYMBOL(__setup_end) = .;
335 #define INIT_CALLS_LEVEL(level) \
336 VMLINUX_SYMBOL(__initcall##level##_start) = .; \
337 - *(.initcall##level##.init) \
338 - *(.initcall##level##s.init) \
339 + KEEP(*(.initcall##level##.init)) \
340 + KEEP(*(.initcall##level##s.init)) \
343 VMLINUX_SYMBOL(__initcall_start) = .; \
344 - *(.initcallearly.init) \
345 + KEEP(*(.initcallearly.init)) \
346 INIT_CALLS_LEVEL(0) \
347 INIT_CALLS_LEVEL(1) \
348 INIT_CALLS_LEVEL(2) \
349 @@ -676,21 +677,21 @@
351 #define CON_INITCALL \
352 VMLINUX_SYMBOL(__con_initcall_start) = .; \
353 - *(.con_initcall.init) \
354 + KEEP(*(.con_initcall.init)) \
355 VMLINUX_SYMBOL(__con_initcall_end) = .;
357 #define SECURITY_INITCALL \
358 VMLINUX_SYMBOL(__security_initcall_start) = .; \
359 - *(.security_initcall.init) \
360 + KEEP(*(.security_initcall.init)) \
361 VMLINUX_SYMBOL(__security_initcall_end) = .;
363 #ifdef CONFIG_BLK_DEV_INITRD
364 #define INIT_RAM_FS \
366 VMLINUX_SYMBOL(__initramfs_start) = .; \
368 + KEEP(*(.init.ramfs)) \
370 - *(.init.ramfs.info)
371 + KEEP(*(.init.ramfs.info))
375 --- a/arch/arm/Makefile
376 +++ b/arch/arm/Makefile
377 @@ -17,11 +17,16 @@ LDFLAGS_vmlinux :=-p --no-undefined -X
378 ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
379 LDFLAGS_vmlinux += --be8
381 +LDFLAGS_vmlinux += --gc-sections
383 OBJCOPYFLAGS :=-O binary -R .comment -S
385 #KBUILD_CFLAGS +=-pipe
387 +ifndef CONFIG_FUNCTION_TRACER
388 +KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
391 # Never generate .eh_frame
392 KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
394 --- a/arch/arm/kernel/vmlinux.lds.S
395 +++ b/arch/arm/kernel/vmlinux.lds.S
399 VMLINUX_SYMBOL(__proc_info_begin) = .; \
400 - *(.proc.info.init) \
401 + KEEP(*(.proc.info.init)) \
402 VMLINUX_SYMBOL(__proc_info_end) = .;
406 VMLINUX_SYMBOL(__idmap_text_start) = .; \
408 + KEEP(*(.idmap.text)) \
409 VMLINUX_SYMBOL(__idmap_text_end) = .; \
411 VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \
412 @@ -97,7 +97,7 @@ SECTIONS
413 .text : { /* Real text segment */
414 _stext = .; /* Text and read-only data */
415 __exception_text_start = .;
417 + KEEP(*(.exception.text))
418 __exception_text_end = .;
421 @@ -122,7 +122,7 @@ SECTIONS
422 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
423 __start___ex_table = .;
426 + KEEP(*(__ex_table))
428 __stop___ex_table = .;
430 @@ -134,12 +134,12 @@ SECTIONS
433 __start_unwind_idx = .;
435 + KEEP(*(.ARM.exidx*))
436 __stop_unwind_idx = .;
439 __start_unwind_tab = .;
441 + KEEP(*(.ARM.extab*))
442 __stop_unwind_tab = .;
445 @@ -162,24 +162,24 @@ SECTIONS
448 __arch_info_begin = .;
450 + KEEP(*(.arch.info.init))
454 __tagtable_begin = .;
456 + KEEP(*(.taglist.init))
459 #ifdef CONFIG_SMP_ON_UP
463 + KEEP(*(.alt.smp.init))
468 __pv_table_begin = .;
474 --- a/arch/arm/boot/compressed/Makefile
475 +++ b/arch/arm/boot/compressed/Makefile
476 @@ -119,6 +119,7 @@ ifeq ($(CONFIG_FUNCTION_TRACER),y)
477 ORIG_CFLAGS := $(KBUILD_CFLAGS)
478 KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
480 +KBUILD_CFLAGS_KERNEL := $(patsubst -f%-sections,,$(KBUILD_CFLAGS_KERNEL))
482 ccflags-y := -fpic -fno-builtin -I$(obj)
483 asflags-y := -Wa,-march=all -DZIMAGE