Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753528AbdCOQwL (ORCPT ); Wed, 15 Mar 2017 12:52:11 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:61321 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753311AbdCOQwE (ORCPT ); Wed, 15 Mar 2017 12:52:04 -0400 From: Arnd Bergmann Cc: Arnd Bergmann , Nicolas Pitre , Nicholas Piggin , Alan Modra , Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] [EXPERIMENTAL, v2] enable thin archives and --gc-sections on ARM Date: Wed, 15 Mar 2017 17:50:00 +0100 Message-Id: <20170315165109.3451216-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:3EQpXvskeu1j+1WkT8bu/PTei4DJt1GiQbIT51/uKNiRCF/TTon 8GtKgftU6dODBsRD8gSnu49P6U+tSb43d4r7EnUGwt4Z/KbAKQOpVM7H6LqvbWHvguqykEM q1iElucjec1dZH3tVcbtuArehqvbzVB4yagiMfu5nEy1rp3p0CMEfiNuLcpkoOokmWr5LPo CDuuiO1yQ59mU+ZH8lpsg== X-UI-Out-Filterresults: notjunk:1;V01:K0:h1uGZrP2AwA=:KlOzlgMchecEfQhowAZq7S 04cLIYurSpGA/O39wiDabn0f3jc3uOuBqWpzvdgyZDy+X39HVq0tECyAAOIJ55nnyVYfF4Cgj tHbSWY4AAE8fMwonquZmzUioA6sY/BBNZ8cL85rP4MoWW2a4IBVmbg2+fF669biF5KUVr6k4o yqSh7L5VfNz8BjYiav7O/Afrk0CPWAaZ5TArdBVLVAYrOhAQOu9YHnZvpr5nvGDxSdkQZren/ U0B7/sx1v45b4EvQx4TN2Wk8MHfBYrXyb7CLgomAnVbDLUWi7407P+yvYEoKS+BEMYhP3En56 ft7Z6BjO+9l3MRCjscA+Eg3RDzm+19+hQjf2YzE5OLOZAfdGGEoFjuO18E2Tu6SO2azGJS2zV mrbu9n4xeqctgBdQpvBQOVArxKcm4UNsJ9e+3AvY6H9p4DUZDTtnUjQ/GOP7DVoqm9+F0a9mX XiQfQ/W+vA2gnaAbe86eIAh6Yn8bzKQDcAq0e3oEfdXptqw+15Y1b9+A6bvukn2NwUOOHizjk 8UpDfo6eZ6KJu/ZrhAvV810vQBwJXxgieUJJx5WQuLN9LH4qVQwCf5KMyCz/6IlPcU86xktWa yrl8+1zwMM9RdEnHFWEkDt14sZiACCG2NC8clQZl45ZzqZsP93en/ys61cucsjCVPhu44Yv0n EluhExHjxDM792DSTOFs3wvTJqqeNA7GODvUgAgrcLws1krJQayBYqPkwuDQYj7oy+tQ= To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6122 Lines: 236 I'm still build testing with an experimental change to enable thin architeves and --gc-sections on ARM, which should bring multiple benefits - improve build times - allow 'allyesconfig' to succeed without exceeding the section size when linking drivers/built-in.o - reduce the kernel image size However, I have now run into a build error binutils commit f02cb05 ("Always descend into output section statements in lang_do_assignments") in binutils-2.28 and later: no __ex_table in file: vmlinux Any idea what's going wrong here? Cc: Nicolas Pitre Cc: Nicholas Piggin Cc: Alan Modra Signed-off-by: Arnd Bergmann --- arch/arm/Kconfig | 2 ++ arch/arm/kernel/Makefile | 3 +++ arch/arm/kernel/vmlinux-xip.lds.S | 32 +++++++++++++++++++++----------- arch/arm/kernel/vmlinux.lds.S | 22 ++++++++++++++++------ 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 27e738b82e45..333a1f685abb 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -89,6 +89,7 @@ config ARM select HAVE_UID16 select HAVE_VIRT_CPU_ACCOUNTING_GEN select IRQ_FORCED_THREADING + select LD_DEAD_CODE_DATA_ELIMINATION select MODULES_USE_ELF_REL select NO_BOOTMEM select OF_EARLY_FLATTREE if OF @@ -98,6 +99,7 @@ config ARM select PERF_USE_VMALLOC select RTC_LIB select SYS_SUPPORTS_APM_EMULATION + select THIN_ARCHIVES # Above selects are sorted alphabetically; please add new ones # according to that. Thanks. help diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index d1b06cd79b23..469b78f5f529 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -13,6 +13,9 @@ endif CFLAGS_REMOVE_return_address.o = -pg +ccflags-y += -fno-function-sections -fno-data-sections +subdir-ccflags-y += -fno-function-sections -fno-data-sections + # Object file lists. obj-y := elf.o entry-common.o irq.o opcodes.o \ diff --git a/arch/arm/kernel/vmlinux-xip.lds.S b/arch/arm/kernel/vmlinux-xip.lds.S index 2e5b5f0dbadf..bf900f5421a1 100644 --- a/arch/arm/kernel/vmlinux-xip.lds.S +++ b/arch/arm/kernel/vmlinux-xip.lds.S @@ -18,17 +18,17 @@ #define PROC_INFO \ . = ALIGN(4); \ VMLINUX_SYMBOL(__proc_info_begin) = .; \ - *(.proc.info.init) \ + KEEP(*(.proc.info.init)) \ VMLINUX_SYMBOL(__proc_info_end) = .; #define IDMAP_TEXT \ ALIGN_FUNCTION(); \ VMLINUX_SYMBOL(__idmap_text_start) = .; \ - *(.idmap.text) \ + KEEP(*(.idmap.text)) \ VMLINUX_SYMBOL(__idmap_text_end) = .; \ . = ALIGN(PAGE_SIZE); \ VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \ - *(.hyp.idmap.text) \ + KEEP(*(.hyp.idmap.text)) \ VMLINUX_SYMBOL(__hyp_idmap_text_end) = .; #ifdef CONFIG_HOTPLUG_CPU @@ -48,6 +48,16 @@ #define ARM_EXIT_DISCARD(x) x #endif +#undef TEXT_TEXT +#define TEXT_TEXT \ + ALIGN_FUNCTION(); \ + *(.text.hot .text.hot.*) \ + *(.text.unlikely .text.unlikely.*) \ + *(.text .text.*) \ + *(.ref.text) \ + MEM_KEEP(init.text) \ + MEM_KEEP(exit.text) \ + OUTPUT_ARCH(arm) ENTRY(stext) @@ -121,7 +131,7 @@ SECTIONS __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { __start___ex_table = .; #ifdef CONFIG_MMU - *(__ex_table) + KEEP(*(__ex_table)) #endif __stop___ex_table = .; } @@ -133,12 +143,12 @@ SECTIONS . = ALIGN(8); .ARM.unwind_idx : { __start_unwind_idx = .; - *(.ARM.exidx*) + KEEP(*(.ARM.exidx*)) __stop_unwind_idx = .; } .ARM.unwind_tab : { __start_unwind_tab = .; - *(.ARM.extab*) + KEEP(*(.ARM.extab*)) __stop_unwind_tab = .; } #endif @@ -153,7 +163,7 @@ SECTIONS */ __vectors_start = .; .vectors 0xffff0000 : AT(__vectors_start) { - *(.vectors) + KEEP(*(.vectors)) } . = __vectors_start + SIZEOF(.vectors); __vectors_end = .; @@ -176,24 +186,24 @@ SECTIONS } .init.arch.info : { __arch_info_begin = .; - *(.arch.info.init) + KEEP(*(.arch.info.init)) __arch_info_end = .; } .init.tagtable : { __tagtable_begin = .; - *(.taglist.init) + KEEP(*(.taglist.init)) __tagtable_end = .; } #ifdef CONFIG_SMP_ON_UP .init.smpalt : { __smpalt_begin = .; - *(.alt.smp.init) + KEEP(*(.alt.smp.init)) __smpalt_end = .; } #endif .init.pv_table : { __pv_table_begin = .; - *(.pv_table) + KEEP(*(.pv_table)) __pv_table_end = .; } .init.data : { diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S index 30f04ce52dde..5f2c8c90beac 100644 --- a/arch/arm/kernel/vmlinux.lds.S +++ b/arch/arm/kernel/vmlinux.lds.S @@ -17,7 +17,7 @@ #define PROC_INFO \ . = ALIGN(4); \ VMLINUX_SYMBOL(__proc_info_begin) = .; \ - *(.proc.info.init) \ + KEEP(*(.proc.info.init)) \ VMLINUX_SYMBOL(__proc_info_end) = .; #define HYPERVISOR_TEXT \ @@ -35,6 +35,16 @@ *(.hyp.idmap.text) \ VMLINUX_SYMBOL(__hyp_idmap_text_end) = .; +#undef TEXT_TEXT +#define TEXT_TEXT \ + ALIGN_FUNCTION(); \ + *(.text.hot .text.hot.*) \ + *(.text.unlikely .text.unlikely.*) \ + *(.text .text.*) \ + *(.ref.text) \ + MEM_KEEP(init.text) \ + MEM_KEEP(exit.text) \ + #ifdef CONFIG_HOTPLUG_CPU #define ARM_CPU_DISCARD(x) #define ARM_CPU_KEEP(x) x @@ -170,7 +180,7 @@ SECTIONS */ __vectors_start = .; .vectors 0xffff0000 : AT(__vectors_start) { - *(.vectors) + KEEP(*(.vectors)) } . = __vectors_start + SIZEOF(.vectors); __vectors_end = .; @@ -193,24 +203,24 @@ SECTIONS } .init.arch.info : { __arch_info_begin = .; - *(.arch.info.init) + KEEP(*(.arch.info.init)) __arch_info_end = .; } .init.tagtable : { __tagtable_begin = .; - *(.taglist.init) + KEEP(*(.taglist.init)) __tagtable_end = .; } #ifdef CONFIG_SMP_ON_UP .init.smpalt : { __smpalt_begin = .; - *(.alt.smp.init) + KEEP(*(.alt.smp.init)) __smpalt_end = .; } #endif .init.pv_table : { __pv_table_begin = .; - *(.pv_table) + KEEP(*(.pv_table)) __pv_table_end = .; } .init.data : { -- 2.9.0