[PATCH 4/4] startup: set barebox_main in data section

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Dec 16 03:36:40 PST 2024


By initializing barebox_main in start_barebox(), we preclude changing
barebox_main before start_barebox() is called.

This can be useful, at least in sandbox. Therefore, let's initialize
barebox_main statically.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/startup.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/common/startup.c b/common/startup.c
index 4cb9cfcdaa49..898bef6d22e4 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -355,16 +355,15 @@ static void do_ctors(void)
 #endif
 }
 
-int (*barebox_main)(void);
+int (*barebox_main)(void)
+	= !IS_ENABLED(CONFIG_SHELL_NONE) &&
+           IS_ENABLED(CONFIG_COMMAND_SUPPORT) ? run_init : NULL;
 
 void __noreturn start_barebox(void)
 {
 	initcall_t *initcall;
 	int result;
 
-	if (!IS_ENABLED(CONFIG_SHELL_NONE) && IS_ENABLED(CONFIG_COMMAND_SUPPORT))
-		barebox_main = run_init;
-
 	do_ctors();
 
 	for (initcall = __barebox_initcalls_start;
-- 
2.39.5




More information about the barebox mailing list