* [PATCH v2 1/2] powerpc: fix vmlinux.lds to build with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
@ 2018-04-18 13:36 Christophe Leroy
2018-04-18 13:36 ` [PATCH v2 2/2] powerpc: Allow selection of CONFIG_LD_DEAD_CODE_DATA_ELIMINATION Christophe Leroy
0 siblings, 1 reply; 2+ messages in thread
From: Christophe Leroy @ 2018-04-18 13:36 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Arnd Bergmann
Cc: linux-kernel, linuxppc-dev, linux-arch
This patch fixes vmlinux.lds script to build properly with
CONFIG_LD_DEAD_CODE_DATA_ELIMINATION enabled
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/kernel/vmlinux.lds.S | 4 ++--
include/asm-generic/vmlinux.lds.h | 6 +++++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index c8af90ff49f0..afff03e9be39 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -98,7 +98,7 @@ SECTIONS
ALIGN_FUNCTION();
#endif
/* careful! __ftr_alt_* sections need to be close to .text */
- *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
+ *(.text.hot TEXT_MAIN .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
SCHED_TEXT
CPUIDLE_TEXT
LOCK_TEXT
@@ -274,7 +274,7 @@ SECTIONS
.data : AT(ADDR(.data) - LOAD_OFFSET) {
DATA_DATA
*(.data.rel*)
- *(.sdata)
+ *(SDATA_MAIN)
*(.sdata2)
*(.got.plt) *(.got)
*(.plt)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 278841c75b97..5549be081931 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -68,11 +68,15 @@
#ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
#define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
#define DATA_MAIN .data .data.[0-9a-zA-Z_]*
+#define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]*
+#define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]*
#else
#define TEXT_MAIN .text
#define DATA_MAIN .data
+#define SDATA_MAIN .sdata
#define BSS_MAIN .bss
+#define SBSS_MAIN .sbss
#endif
/*
@@ -629,7 +633,7 @@
. = ALIGN(sbss_align); \
.sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
*(.dynsbss) \
- *(.sbss) \
+ *(SBSS_MAIN) \
*(.scommon) \
}
--
2.13.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v2 2/2] powerpc: Allow selection of CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
2018-04-18 13:36 [PATCH v2 1/2] powerpc: fix vmlinux.lds to build with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION Christophe Leroy
@ 2018-04-18 13:36 ` Christophe Leroy
0 siblings, 0 replies; 2+ messages in thread
From: Christophe Leroy @ 2018-04-18 13:36 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
This option does dead code and data elimination with the linker by
compiling with -ffunction-sections -fdata-sections and linking with
--gc-sections.
By selecting this option on mpc885_ads_defconfig,
vmlinux LOAD segment size gets reduced by 10%
Program Header before the patch:
LOAD off 0x00010000 vaddr 0xc0000000 paddr 0x00000000 align 2**16
filesz 0x0036eda4 memsz 0x0038de04 flags rwx
Program Header after the patch:
LOAD off 0x00010000 vaddr 0xc0000000 paddr 0x00000000 align 2**16
filesz 0x00316da4 memsz 0x00334268 flags rwx
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/Kconfig | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 8fe4353be5e3..e1fac49cf465 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -888,6 +888,14 @@ config PPC_MEM_KEYS
If unsure, say y.
+config PPC_UNUSED_ELIMINATION
+ bool "Eliminate unused functions and data from vmlinux"
+ default n
+ select LD_DEAD_CODE_DATA_ELIMINATION
+ help
+ Select this to do dead code and data elimination with the linker
+ by compiling with -ffunction-sections -fdata-sections and linking
+ with --gc-sections.
endmenu
config ISA_DMA_API
--
2.13.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-04-18 13:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-18 13:36 [PATCH v2 1/2] powerpc: fix vmlinux.lds to build with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION Christophe Leroy
2018-04-18 13:36 ` [PATCH v2 2/2] powerpc: Allow selection of CONFIG_LD_DEAD_CODE_DATA_ELIMINATION Christophe Leroy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).