From 16b9c64caf900a9ce4623090e8263a7da2746998 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 7 Aug 2024 16:47:26 -0600 Subject: [PATCH] sandbox: Set up global_data earlier It is possible for U-Boot functions such as printf() to be called within state_init(). This can end up checking gd->flags (e.g. in putc()) before global_data is set up. Move the setup earlier to avoid this. This fixes the suppression of some debug output in memory allocation (when enabled). Signed-off-by: Simon Glass --- arch/sandbox/cpu/start.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index dce8041652..0920ed5596 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -483,6 +483,9 @@ int sandbox_main(int argc, char *argv[]) text_base = os_find_text_base(); + memset(&data, '\0', sizeof(data)); + gd = &data; + /* * This must be the first invocation of os_malloc() to have * state->ram_buf in the low 4 GiB. @@ -501,8 +504,6 @@ int sandbox_main(int argc, char *argv[]) os_exit(1); memcpy(os_argv, argv, size); - memset(&data, '\0', sizeof(data)); - gd = &data; gd->arch.text_base = text_base; state = state_get_current(); -- 2.39.5