Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/84140?usp=email )
Change subject: util/cbfstool: Make sure to only compare PT_LOAD stages ......................................................................
util/cbfstool: Make sure to only compare PT_LOAD stages
When parsing XIP stages only compare PT_LOAD phdrs. Currently coreboot stages only use PT_LOAD phdrs.
However using non PT_LOAD phdrs can be used for further improvements.
Segments can however be used as constraints: e.g. you could have a CAR segment and then the linker automatically checks that the car section fits in that segment, removing the need for handcrafted asserts in that code.
Change-Id: I305b25032a3c4a9fdefc76cad77fafdb862a604c Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M util/cbfstool/cbfs-mkstage.c 1 file changed, 7 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/40/84140/1
diff --git a/util/cbfstool/cbfs-mkstage.c b/util/cbfstool/cbfs-mkstage.c index 8129f0b..84a746b 100644 --- a/util/cbfstool/cbfs-mkstage.c +++ b/util/cbfstool/cbfs-mkstage.c @@ -292,13 +292,16 @@ * loadable segments were found or if two consecutive segments are not * consecutive in their physical address space. */ -static Elf64_Phdr **find_loadable_segments(struct parsed_elf *pelf) +static Elf64_Phdr **xip_find_loadable_segments(struct parsed_elf *pelf) { Elf64_Phdr **phdrs = NULL; - Elf64_Phdr *prev = NULL, *cur; + Elf64_Phdr *prev = NULL, *cur = NULL; size_t size = 1, i;
- for (i = 0; i < pelf->ehdr.e_phnum; i++, prev = cur) { + for (i = 0; i < pelf->ehdr.e_phnum; i++) { + if (cur && cur->p_type == PT_LOAD) + prev = cur; + cur = &pelf->phdr[i];
if (cur->p_type != PT_LOAD || cur->p_memsz == 0) @@ -366,7 +369,7 @@ if (rmodule_collect_relocations(rmodctx, &filter)) goto out;
- toload = find_loadable_segments(pelf); + toload = xip_find_loadable_segments(pelf); if (!toload) goto out;