[PATCH 1/1] rockchip: make_fit_atf: ignore empty PT_LOAD segment

The linker sometimes creates PT_LOAD segments with length (p_filesz) zero as described in https://man7.org/linux/man-pages/man5/elf.5.html. This leads to build failures. We should ignore empty segments.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- arch/arm/mach-rockchip/make_fit_atf.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-rockchip/make_fit_atf.py b/arch/arm/mach-rockchip/make_fit_atf.py index d15c32b303..f3224d2555 100755 --- a/arch/arm/mach-rockchip/make_fit_atf.py +++ b/arch/arm/mach-rockchip/make_fit_atf.py @@ -189,8 +189,9 @@ def unpack_elf(filename): p_type, p_flags, p_offset = struct.unpack_from('<LLQ', elf, offset) if p_type == 1: # PT_LOAD p_paddr, p_filesz = struct.unpack_from('<2Q', elf, offset + 0x18) - p_data = elf[p_offset:p_offset + p_filesz] - segments.append((index, e_entry, p_paddr, p_data)) + if p_filesz > 0: + p_data = elf[p_offset:p_offset + p_filesz] + segments.append((index, e_entry, p_paddr, p_data)) return segments
def main(): -- 2.28.0

On Tue, Sep 15, 2020 at 03:43:29AM +0200, Heinrich Schuchardt wrote:
The linker sometimes creates PT_LOAD segments with length (p_filesz) zero as described in https://man7.org/linux/man-pages/man5/elf.5.html. This leads to build failures. We should ignore empty segments.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
This also fixes the build issue I had.
Tested-by: Tom Rini trini@konsulko.com

On 2020/9/15 上午9:43, Heinrich Schuchardt wrote:
The linker sometimes creates PT_LOAD segments with length (p_filesz) zero as described in https://man7.org/linux/man-pages/man5/elf.5.html. This leads to build failures. We should ignore empty segments.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks,
- Kever
arch/arm/mach-rockchip/make_fit_atf.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-rockchip/make_fit_atf.py b/arch/arm/mach-rockchip/make_fit_atf.py index d15c32b303..f3224d2555 100755 --- a/arch/arm/mach-rockchip/make_fit_atf.py +++ b/arch/arm/mach-rockchip/make_fit_atf.py @@ -189,8 +189,9 @@ def unpack_elf(filename): p_type, p_flags, p_offset = struct.unpack_from('<LLQ', elf, offset) if p_type == 1: # PT_LOAD p_paddr, p_filesz = struct.unpack_from('<2Q', elf, offset + 0x18)
p_data = elf[p_offset:p_offset + p_filesz]
segments.append((index, e_entry, p_paddr, p_data))
if p_filesz > 0:
p_data = elf[p_offset:p_offset + p_filesz]
segments.append((index, e_entry, p_paddr, p_data)) return segments
def main():
-- 2.28.0

On 16.09.20 10:40, Kever Yang wrote:
On 2020/9/15 上午9:43, Heinrich Schuchardt wrote:
The linker sometimes creates PT_LOAD segments with length (p_filesz) zero as described in https://man7.org/linux/man-pages/man5/elf.5.html. This leads to build failures. We should ignore empty segments.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Hello Tom,
now that the patch has been reviewed I hope you can use it to get the efi-2020-10-rc5 pull request merged.
Best regards
Heinrich
Thanks,
- Kever
arch/arm/mach-rockchip/make_fit_atf.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-rockchip/make_fit_atf.py b/arch/arm/mach-rockchip/make_fit_atf.py index d15c32b303..f3224d2555 100755 --- a/arch/arm/mach-rockchip/make_fit_atf.py +++ b/arch/arm/mach-rockchip/make_fit_atf.py @@ -189,8 +189,9 @@ def unpack_elf(filename): p_type, p_flags, p_offset = struct.unpack_from('<LLQ', elf, offset) if p_type == 1: # PT_LOAD p_paddr, p_filesz = struct.unpack_from('<2Q', elf, offset + 0x18) - p_data = elf[p_offset:p_offset + p_filesz] - segments.append((index, e_entry, p_paddr, p_data)) + if p_filesz > 0: + p_data = elf[p_offset:p_offset + p_filesz] + segments.append((index, e_entry, p_paddr, p_data)) return segments
def main():
2.28.0
participants (3)
-
Heinrich Schuchardt
-
Kever Yang
-
Tom Rini