[PATCH v2 6/8] spl: binman: Check at runtime if binman symbols were filled in
Simon Glass
sjg at chromium.org
Tue Jun 28 15:37:41 CEST 2022
Binman lets us declare symbols in SPL/TPL that refer to other entries in
the same binman image as them. These symbols are filled in with the
correct values while binman assembles the images, but this is done
in-memory only. Symbols marked as optional can be filled with
BINMAN_SYM_MISSING as an error value if their referred entry is missing.
However, the unmodified SPL/TPL binaries are still available on disk,
and can be used by people. For these files, nothing ensures that the
symbols are set to this error value, and they will be considered valid
when they are not.
Empirically, all symbols show up as zero in a sandbox_vpl build when we
run e.g. tpl/u-boot-tpl directly. On the other hand, zero is a perfectly
fine value for a binman-written symbol, so we cannot say the symbols
have wrong values based on that.
Declare a magic symbol that binman always fills in with a fixed value.
Check this value as an indicator that symbols were filled in correctly.
Return the error value for all symbols when this magic symbol has the
wrong value.
For binman tests, we need to make room for the new symbol in the mocked
SPL/TPL data by extending them by four bytes. This messes up some test
image layouts. Fix the affected values, and check the magic symbol
wherever it makes sense.
Signed-off-by: Alper Nebi Yasak <alpernebiyasak at gmail.com>
---
(no changes since v1)
common/spl/spl.c | 1 +
include/binman_sym.h | 45 ++++++++++++++++++++-
tools/binman/elf.py | 12 ++++--
tools/binman/elf_test.py | 12 +++---
tools/binman/ftest.py | 33 +++++++--------
tools/binman/test/021_image_pad.dts | 2 +-
tools/binman/test/024_sorted.dts | 2 +-
tools/binman/test/028_pack_4gb_outside.dts | 2 +-
tools/binman/test/029_x86_rom.dts | 6 +--
tools/binman/test/053_symbols.dts | 2 +-
tools/binman/test/149_symbols_tpl.dts | 4 +-
tools/binman/test/155_symbols_tpl_x86.dts | 4 +-
tools/binman/test/187_symbols_sub.dts | 2 +-
tools/binman/test/u_boot_binman_syms.c | 4 ++
tools/binman/test/u_boot_binman_syms_size.c | 4 ++
15 files changed, 97 insertions(+), 38 deletions(-)
Applied to u-boot-dm, thanks!
More information about the U-Boot
mailing list