summaryrefslogtreecommitdiff
path: root/common/spl/spl.c
diff options
context:
space:
mode:
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>2022-06-18 15:13:06 +0300
committerSimon Glass <sjg@chromium.org>2022-06-28 05:09:52 +0300
commitd7f071725287a5462c57242bf04a752cd5ddfff1 (patch)
treea28644d326f59b6e53b3554344415455ad581e97 /common/spl/spl.c
parentd4462ba0443d4ea7de290b2ccf90b2a1c0122b93 (diff)
downloadu-boot-d7f071725287a5462c57242bf04a752cd5ddfff1.tar.xz
spl: binman: Fix use of undeclared u_boot_any symbols
Some SPL functions directly use the binman 'u_boot_any' symbols to get U-Boot's binman image position. These symbols are declared by the SPL/TPL_BINMAN_SYMBOLS configs, but they are accessed by macros defined by just CONFIG_BINMAN. So when BINMAN is enabled and BINMAN_SYMBOLS is disabled, the code tries to use undeclared symbols and we get an error. Therefore, any use of 'u_boot_any' symbols in the code is an implicit dependency on SPL/TPL_BINMAN_SYMBOLS. However, in the current uses they are meant to be the next phase's values, where that happens to be U-Boot. In the meantime, helper funcions spl_get_image_pos/size() were introduced to get these values. Convert all uses of u_boot_any symbols to these functions, so we only access these symbols at one place. Make sure they will not use these symbols when the BINMAN_SYMBOLS configs are disabled, by returning early in those cases. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Diffstat (limited to 'common/spl/spl.c')
-rw-r--r--common/spl/spl.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/common/spl/spl.c b/common/spl/spl.c
index dff4eef707..7505165624 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -150,9 +150,11 @@ void spl_fixup_fdt(void *fdt_blob)
#endif
}
-#if CONFIG_IS_ENABLED(BINMAN_SYMBOLS)
ulong spl_get_image_pos(void)
{
+ if (!CONFIG_IS_ENABLED(BINMAN_SYMBOLS))
+ return BINMAN_SYM_MISSING;
+
#ifdef CONFIG_VPL
if (spl_next_phase() == PHASE_VPL)
return binman_sym(ulong, u_boot_vpl, image_pos);
@@ -164,6 +166,9 @@ ulong spl_get_image_pos(void)
ulong spl_get_image_size(void)
{
+ if (!CONFIG_IS_ENABLED(BINMAN_SYMBOLS))
+ return BINMAN_SYM_MISSING;
+
#ifdef CONFIG_VPL
if (spl_next_phase() == PHASE_VPL)
return binman_sym(ulong, u_boot_vpl, size);
@@ -172,7 +177,6 @@ ulong spl_get_image_size(void)
binman_sym(ulong, u_boot_spl, size) :
binman_sym(ulong, u_boot_any, size);
}
-#endif /* BINMAN_SYMBOLS */
ulong spl_get_image_text_base(void)
{
@@ -223,7 +227,7 @@ __weak struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
void spl_set_header_raw_uboot(struct spl_image_info *spl_image)
{
- ulong u_boot_pos = binman_sym(ulong, u_boot_any, image_pos);
+ ulong u_boot_pos = spl_get_image_pos();
spl_image->size = CONFIG_SYS_MONITOR_LEN;