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>
This commit is contained in:
parent
379729b497
commit
e15b584961
1 changed files with 15 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue