From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] ARM: remove unused constructor support
Date: Mon, 5 Jan 2026 09:46:01 +0100 [thread overview]
Message-ID: <20260105084604.3288407-1-a.fatoum@barebox.org> (raw)
CONFIG_CONSTRUCTORS was added alongside KASAN support, but it appears to
be unused and not necessary for KASAN to work.
While at it, we also remove the legacy CONSTRUCTORS directive that only
exists in the 32-bit, but not 64-bit ARM linker script.
I suspect that in Linux, constructors are needed for external modules,
but in barebox, we don't currently make use of it, so it should be safe
to drop.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
arch/arm/lib32/barebox.lds.S | 4 +---
common/startup.c | 15 ---------------
include/asm-generic/barebox.lds.h | 12 ------------
lib/Kconfig | 3 ---
lib/kasan/Kconfig | 1 -
5 files changed, 1 insertion(+), 34 deletions(-)
diff --git a/arch/arm/lib32/barebox.lds.S b/arch/arm/lib32/barebox.lds.S
index 2d08b95758b7..c704dd6d70f3 100644
--- a/arch/arm/lib32/barebox.lds.S
+++ b/arch/arm/lib32/barebox.lds.S
@@ -59,9 +59,7 @@ SECTIONS
_sdata = .;
. = ALIGN(4);
- .data : { *(.data*)
- CONSTRUCTORS
- }
+ .data : { *(.data*) }
. = .;
diff --git a/common/startup.c b/common/startup.c
index 81a3ae1513c2..6730b6c49220 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -396,19 +396,6 @@ static int run_init(void)
hang();
}
-typedef void (*ctor_fn_t)(void);
-
-/* Call all constructor functions linked into the kernel. */
-static void do_ctors(void)
-{
-#ifdef CONFIG_CONSTRUCTORS
- ctor_fn_t *fn = (ctor_fn_t *) __ctors_start;
-
- for (; fn < (ctor_fn_t *) __ctors_end; fn++)
- (*fn)();
-#endif
-}
-
int (*barebox_main)(void)
= !IS_ENABLED(CONFIG_SHELL_NONE) &&
IS_ENABLED(CONFIG_COMMAND_SUPPORT) ? run_init : NULL;
@@ -418,8 +405,6 @@ void __noreturn start_barebox(void)
initcall_t *initcall;
int result;
- do_ctors();
-
for (initcall = __barebox_initcalls_start;
initcall < __barebox_initcalls_end; initcall++) {
pr_debug("initcall-> %pS\n", *initcall);
diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h
index 092dbc6dffa6..12082d567a4d 100644
--- a/include/asm-generic/barebox.lds.h
+++ b/include/asm-generic/barebox.lds.h
@@ -129,24 +129,12 @@
#endif
-#ifdef CONFIG_CONSTRUCTORS
-#define KERNEL_CTORS() . = ALIGN(8); \
- __ctors_start = .; \
- KEEP(*(.ctors)) \
- KEEP(*(SORT(.init_array.*))) \
- KEEP(*(.init_array)) \
- __ctors_end = .;
-#else
-#define KERNEL_CTORS()
-#endif
-
#define RO_DATA_SECTION \
BAREBOX_INITCALLS \
BAREBOX_EXITCALLS \
BAREBOX_CMDS \
BAREBOX_RATP_CMDS \
BAREBOX_SYMS \
- KERNEL_CTORS() \
BAREBOX_MAGICVARS \
BAREBOX_CLK_TABLE \
BAREBOX_DTB \
diff --git a/lib/Kconfig b/lib/Kconfig
index 58993bc5d3c9..9b8e0c2fa77d 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -80,9 +80,6 @@ config REED_SOLOMON
config BASE64
bool "include base64 encode/decode support"
-config CONSTRUCTORS
- bool
-
config GENERIC_FIND_NEXT_BIT
def_bool n
diff --git a/lib/kasan/Kconfig b/lib/kasan/Kconfig
index 532412953ba5..62645ba8ea95 100644
--- a/lib/kasan/Kconfig
+++ b/lib/kasan/Kconfig
@@ -7,7 +7,6 @@ config KASAN
bool "KASAN: runtime memory debugger"
depends on (HAVE_ARCH_KASAN && CC_HAS_KASAN_GENERIC)
depends on MALLOC_TLSF
- select CONSTRUCTORS
select PRINTF_HEXSTR
help
Enables KASAN (KernelAddressSANitizer) - runtime memory debugger,
--
2.47.3
next reply other threads:[~2026-01-05 8:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-05 8:46 Ahmad Fatoum [this message]
2026-01-06 7:38 ` 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=20260105084604.3288407-1-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--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