Skip to contentSkip to conversation

ARM: remove unused constructor support

PATCH Applied Ahmad Fatoum 2 participants 2 messages Jan 5 – Jan 6

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: remove unused constructor support

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.

---
 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(-)
arch/arm/lib32/barebox.lds.S +1 -3
index 2d08b95758b7..c704dd6d70f3 100644
@@ -59,9 +59,7 @@ SECTIONS
 	_sdata = .;
 
 	. = ALIGN(4);
-	.data : { *(.data*)
-		CONSTRUCTORS
-	}
+	.data : { *(.data*) }
 
 	. = .;
 
common/startup.c +0 -15
index 81a3ae1513c2..6730b6c49220 100644
@@ -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);
include/asm-generic/barebox.lds.h +0 -12
index 092dbc6dffa6..12082d567a4d 100644
@@ -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				\
lib/Kconfig +0 -3
index 58993bc5d3c9..9b8e0c2fa77d 100644
@@ -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
 
lib/kasan/Kconfig +0 -1
index 532412953ba5..62645ba8ea95 100644
@@ -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,
Signature · 1 line
2.47.3
Applied
#1 lore raw
Quoted 11 lines · Ahmad Fatoum

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.

[...]

Applied, thanks!

[1/1] ARM: remove unused constructor support
https://git.pengutronix.de/cgit/barebox/commit/?id=cb64ad3ea11b (link may not be stable)

Best regards,

Signature · 1 line
Sascha Hauer <[email protected]>