mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 2/3] kvx: select DEAD_CODE_DATA_ELIMINATION
Date: Thu,  6 Aug 2026 13:28:02 +0200	[thread overview]
Message-ID: <20260806112845.3822400-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20260806112845.3822400-1-a.fatoum@pengutronix.de>

We have code that depends on unreferenced functions being dropped,
because otherwise they would lead to linker errors as they themself
reference functions that aren't included in the build.

To make such code not break the kvx build, enable linker garbage
collection for it.

To make this work two changes are needed in addition:

- exact .text, .data and .bss matches changed to prefix matches
  as we want to merge the new subsections

- kvx_start is identified as the entry point, so linker garbage
  collection knows from where to check reachability

A search for `section' in arch/kvx and drivers/soc/kvx shows that the
only custom sections are .exception and .startup, so we should have all
our bases covered.

It has been verified that barebox running in QEMU still reaches its shell
with this change applied.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/kvx/Kconfig           | 1 +
 arch/kvx/cpu/barebox.lds.S | 7 ++++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/kvx/Kconfig b/arch/kvx/Kconfig
index bbbec6471f06..14109c3cfcb7 100644
--- a/arch/kvx/Kconfig
+++ b/arch/kvx/Kconfig
@@ -22,6 +22,7 @@ config KVX
 	select OFDEVICE
 	select PARTITION
 	select RESET_SOURCE
+	select LD_DEAD_CODE_DATA_ELIMINATION
 	default y
 
 config 64BIT
diff --git a/arch/kvx/cpu/barebox.lds.S b/arch/kvx/cpu/barebox.lds.S
index b05c1f36e595..99a73ea0f7cc 100644
--- a/arch/kvx/cpu/barebox.lds.S
+++ b/arch/kvx/cpu/barebox.lds.S
@@ -8,6 +8,7 @@
 #include <asm/barebox.lds.h>
 
 OUTPUT_FORMAT("elf64-kvx")
+ENTRY(kvx_start)
 
 SECTIONS
 {
@@ -15,7 +16,7 @@ SECTIONS
 	.text ALIGN(4) : {
 		*(.startup);
 		_stext = .;
-		*(.text)
+		*(.text*)
 	}
 
 	/* Exception vector must be aligned on a huge frontier */
@@ -59,7 +60,7 @@ SECTIONS
 	.data ALIGN(4): {
 		sdata = .;
 		_sdata = .;
-		*(.data)
+		*(.data*)
 		. = ALIGN(8);
 		__stack_end = .;
 		. += CONFIG_STACK_SIZE;
@@ -79,7 +80,7 @@ SECTIONS
 	.bss ALIGN(16):
 	{
 		__bss_start = .;
-		*(.bss)
+		*(.bss*)
 		. = ALIGN(16);
 		__bss_stop = .;
 	}
-- 
2.47.3




  reply	other threads:[~2026-08-06 11:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 11:28 [PATCH master 1/3] test: kvx: add Labgrid env YAML for generic_defconfig Ahmad Fatoum
2026-08-06 11:28 ` Ahmad Fatoum [this message]
2026-08-06 11:28 ` [PATCH master 3/3] dma: fix dma_realloc_coherent compile-time error on kvx Ahmad Fatoum
2026-08-06 13:08 ` [PATCH master 1/3] test: kvx: add Labgrid env YAML for generic_defconfig Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260806112845.3822400-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox