FROMLIST: kbuild: fix LD_DEAD_CODE_DATA_ELIMINATION
authorSami Tolvanen <samitolvanen@google.com>
Tue, 13 Feb 2018 21:59:47 +0000 (13:59 -0800)
committerSami Tolvanen <samitolvanen@google.com>
Thu, 26 Apr 2018 23:03:35 +0000 (16:03 -0700)
Don't remove .head.text or .exitcall.exit when linking with --gc-sections,
and include .init.text.* in .init.text and .init.rodata.* in .init.rodata.

Bug: 62093296
Bug: 67506682
Change-Id: Ia0f9e735d04c2322dcc8bcfc94241f0551b149c4
(am from https://patchwork.kernel.org/patch/10085773/)
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
include/asm-generic/vmlinux.lds.h

index 353f52fdc35eb8a4461b5b33e59350f49b7d5188..f4a6799cfbc5b18619610055529a97975696106d 100644 (file)
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
 #define MCOUNT_REC()   . = ALIGN(8);                           \
                        VMLINUX_SYMBOL(__start_mcount_loc) = .; \
-                       *(__mcount_loc)                         \
+                       KEEP(*(__mcount_loc))                   \
                        VMLINUX_SYMBOL(__stop_mcount_loc) = .;
 #else
 #define MCOUNT_REC()
                VMLINUX_SYMBOL(__softirqentry_text_end) = .;
 
 /* Section used for early init (in .S files) */
-#define HEAD_TEXT  *(.head.text)
+#define HEAD_TEXT  KEEP(*(.head.text))
 
 #define HEAD_TEXT_SECTION                                                      \
        .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) {               \
        MEM_DISCARD(init.data)                                          \
        KERNEL_CTORS()                                                  \
        MCOUNT_REC()                                                    \
-       *(.init.rodata)                                                 \
+       *(.init.rodata .init.rodata.*)                                  \
        FTRACE_EVENTS()                                                 \
        TRACE_SYSCALLS()                                                \
        KPROBE_BLACKLIST()                                              \
        EARLYCON_TABLE()
 
 #define INIT_TEXT                                                      \
-       *(.init.text)                                                   \
+       *(.init.text .init.text.*)                                      \
        *(.text.startup)                                                \
        MEM_DISCARD(init.text)
 
        MEM_DISCARD(exit.text)
 
 #define EXIT_CALL                                                      \
-       *(.exitcall.exit)
+       KEEP(*(.exitcall.exit))
 
 /*
  * bss (Block Started by Symbol) - uninitialized data