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 <[email protected]>
---
 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


Reply via email to