summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2024-03-20 10:15:01 +0100
committerElyes Haouas <ehaouas@noos.fr>2024-11-06 04:54:22 +0000
commite15b584961e682ba73210f96dfcab8ebfc5551bb (patch)
treeb05e0352345354a668abc55d365e1e574a68dd62 /util
parent379729b497746da7bdd9d207bc4903bdb4053046 (diff)
util/cbfstool: Deal with how lld organizes loadable segments
LLD deals with loadable segments in a different manner than BFD. The MemSiz of the .text loadable section is padded till the virtaddr of the .car.data section. Since .text is not loaded in ENV_CAR this does not matter. Change-Id: I1a0541c8ea3dfbebfba83d505d84b6db12000723 Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/84043 Reviewed-by: Elyes Haouas <ehaouas@noos.fr> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'util')
-rw-r--r--util/cbfstool/cbfs-mkstage.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/util/cbfstool/cbfs-mkstage.c b/util/cbfstool/cbfs-mkstage.c
index a72b387c2b..cdd353e063 100644
--- a/util/cbfstool/cbfs-mkstage.c
+++ b/util/cbfstool/cbfs-mkstage.c
@@ -311,12 +311,21 @@ static Elf64_Phdr **find_loadable_segments(struct parsed_elf *pelf)
}
phdrs[size - 2] = cur;
- if (prev && (prev->p_paddr + prev->p_memsz != cur->p_paddr ||
- prev->p_filesz != prev->p_memsz)) {
- ERROR("Loadable segments physical addresses should "
- "be consecutive\n");
- free(phdrs);
- return NULL;
+ if (prev) {
+ const bool bfd_is_consecutive = prev->p_paddr + prev->p_memsz == cur->p_paddr
+ && prev->p_filesz == prev->p_memsz;
+ /*
+ * lld pads the memsz of the .text vaddr till the vaddr of car.data.
+ * Since we don't load XIP stages at runtime, we don't care.
+ */
+ const bool lld_is_consecutive = prev->p_vaddr + prev->p_memsz == cur->p_vaddr;
+
+ if (!bfd_is_consecutive && !lld_is_consecutive) {
+ ERROR("Loadable segments physical addresses should "
+ "be consecutive\n");
+ free(phdrs);
+ return NULL;
+ }
}
prev = cur;
}