summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAristo Chen <aristo.chen@canonical.com>2026-07-31 00:13:37 +0000
committerTom Rini <trini@konsulko.com>2026-08-14 10:33:22 -0600
commit4a65f3eb67f43201df5834dea776aec15b6b64f1 (patch)
treef2e488f59fb99790e6353883f4b0e31d9acc2dc6
parent6ac5492d596dd28aa53c16106abae4a743cb5651 (diff)
downloadu-boot-4a65f3eb67f43201df5834dea776aec15b6b64f1.tar.gz
u-boot-4a65f3eb67f43201df5834dea776aec15b6b64f1.zip
binman: Fix FIT image overlap issues for testFitSplitElf
testFitSplitElf builds both the ATF and TEE test images from the same elf_sections binary, so the split-elf nodes generated for the two images end up with identical load addresses and overlap in memory. An upcoming commit teaches mkimage to validate whether the memory regions referenced by a configuration overlap, which makes this test fail. Update the test to use a non-overlapping memory layout so the two images no longer collide: 1. Add elf_sections_tee.lds, which mirrors elf_sections.lds with the section addresses shifted up by 0x100000 for the TEE image. 2. Build an elf_sections_tee binary from it in the test Makefile. 3. Update ftest.py to use the separate ELF file for the TEE component in split-elf operations. Signed-off-by: Aristo Chen <aristo.chen@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--tools/binman/ftest.py2
-rw-r--r--tools/binman/test/Makefile8
l---------tools/binman/test/elf_sections_tee.c1
-rw-r--r--tools/binman/test/elf_sections_tee.lds35
4 files changed, 43 insertions, 3 deletions
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index b5e56707c83..3c391361a6a 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -253,7 +253,7 @@ class TestFunctional(unittest.TestCase):
TestFunctional._MakeInputFile('bl31.elf',
tools.read_file(cls.ElfTestFile('elf_sections')))
TestFunctional.tee_elf_path = TestFunctional._MakeInputFile('tee.elf',
- tools.read_file(cls.ElfTestFile('elf_sections')))
+ tools.read_file(cls.ElfTestFile('elf_sections_tee')))
# Newer OP_TEE file in v1 binary format
cls.make_tee_bin('tee.bin')
diff --git a/tools/binman/test/Makefile b/tools/binman/test/Makefile
index 6b42db6559f..783bb4f62cd 100644
--- a/tools/binman/test/Makefile
+++ b/tools/binman/test/Makefile
@@ -30,13 +30,14 @@ LDS_BINMAN_BAD := -T $(SRC)u_boot_binman_syms_bad.lds
LDS_BINMAN_X86 := -T $(SRC)u_boot_binman_syms_x86.lds
LDS_BINMAN_EMBED := -T $(SRC)u_boot_binman_embed.lds
LDS_EFL_SECTIONS := -T $(SRC)elf_sections.lds
+LDS_EFL_SECTIONS_TEE := -T $(SRC)elf_sections_tee.lds
LDS_BLOB := -T $(SRC)blob_syms.lds
TARGETS = u_boot_ucode_ptr u_boot_no_ucode_ptr bss_data bss_data_zero \
u_boot_binman_syms u_boot_binman_syms.bin u_boot_binman_syms_bad \
u_boot_binman_syms_size u_boot_binman_syms_x86 embed_data \
- u_boot_binman_embed u_boot_binman_embed_sm elf_sections blob_syms.bin \
- dummy-rsa-engine.so
+ u_boot_binman_embed u_boot_binman_embed_sm elf_sections \
+ elf_sections_tee blob_syms.bin dummy-rsa-engine.so
all: $(TARGETS)
@@ -85,6 +86,9 @@ blob_syms: blob_syms.c
elf_sections: CFLAGS += $(LDS_EFL_SECTIONS)
elf_sections: elf_sections.c
+elf_sections_tee: CFLAGS += $(LDS_EFL_SECTIONS_TEE)
+elf_sections_tee: elf_sections_tee.c
+
dummy-rsa-engine.so: $(SRC)fit/dummy-rsa-engine.c
$(CC) -fPIC -shared -lcrypto -lssl -o $@ $<
diff --git a/tools/binman/test/elf_sections_tee.c b/tools/binman/test/elf_sections_tee.c
new file mode 120000
index 00000000000..01b200a365e
--- /dev/null
+++ b/tools/binman/test/elf_sections_tee.c
@@ -0,0 +1 @@
+elf_sections.c \ No newline at end of file
diff --git a/tools/binman/test/elf_sections_tee.lds b/tools/binman/test/elf_sections_tee.lds
new file mode 100644
index 00000000000..6074b45a1f9
--- /dev/null
+++ b/tools/binman/test/elf_sections_tee.lds
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2016 Google, Inc
+ * Copyright (c) 2026 Canonical Ltd.
+ *
+ * Mirrors elf_sections.lds with the addresses shifted up by 0x100000 so
+ * the TEE image does not overlap the ATF image; keep the two in sync.
+ */
+
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+ENTRY(_start)
+
+SECTIONS
+{
+ . = 0x00100010;
+ _start = .;
+
+ . = ALIGN(4);
+ .text :
+ {
+ *(.text*)
+ }
+
+ . = 0x00101000;
+ .sram :
+ {
+ *(.sram*)
+ }
+
+ /DISCARD/ : {
+ *(.comment)
+ *(.dyn*)
+ }
+}