[PATCH v1 1/7] DCE: add debug support

Zhangjin Wu falcon at tinylab.org
Mon Sep 25 15:35:11 PDT 2023


Enable --print-gc-sections for --gc-sections to monitor which sections
are really eliminated.

Signed-off-by: Zhangjin Wu <falcon at tinylab.org>
---
 Makefile     | 3 +++
 init/Kconfig | 7 +++++++
 2 files changed, 10 insertions(+)

diff --git a/Makefile b/Makefile
index 57698d048e2c..a4e522b747cb 100644
--- a/Makefile
+++ b/Makefile
@@ -938,6 +938,9 @@ ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
 KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
 KBUILD_RUSTFLAGS_KERNEL += -Zfunction-sections=y
 LDFLAGS_vmlinux += --gc-sections
+ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION_DEBUG
+LDFLAGS_vmlinux += --print-gc-sections
+endif
 endif
 
 ifdef CONFIG_SHADOW_CALL_STACK
diff --git a/init/Kconfig b/init/Kconfig
index 6d35728b94b2..4350d8ba7db4 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1404,6 +1404,13 @@ config LD_DEAD_CODE_DATA_ELIMINATION
 	  present. This option is not well tested yet, so use at your
 	  own risk.
 
+config LD_DEAD_CODE_DATA_ELIMINATION_DEBUG
+	bool "Debug dead code and data elimination (EXPERIMENTAL)"
+	depends on LD_DEAD_CODE_DATA_ELIMINATION
+	default n
+	help
+	  Enable --print-gc-sections for --gc-sections
+
 config LD_ORPHAN_WARN
 	def_bool y
 	depends on ARCH_WANT_LD_ORPHAN_WARN
-- 
2.25.1




More information about the linux-riscv mailing list