Skip to contentSkip to conversation

rockchip: make_fit_atf: ignore empty PT_LOAD segment

PATCH New Heinrich Schuchardt 3 participants 4 messages Sep 15, 2020 – Sep 16, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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.

---
 arch/arm/mach-rockchip/make_fit_atf.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/make_fit_atf.py +3 -2
index d15c32b303..f3224d2555 100755
@@ -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

#1 lore raw

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

Quoted 5 lines · Heinrich Schuchardt

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.

This also fixes the build issue I had.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200915/dc729d3b/attachment.sig>
#2 lore raw

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

In reply to Heinrich Schuchardt
Quoted 5 lines · Heinrich Schuchardt

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.

Thanks,

- Kever

Quoted 25 lines
---
  arch/arm/mach-rockchip/make_fit_atf.py | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/make_fit_atf.py +3 -3
index d15c32b303..f3224d2555 100755
@@ -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

#3 lore raw

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

Quoted 11 lines · Kever Yang
Quoted 5 lines · Heinrich Schuchardt

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.

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

Quoted 35 lines

Thanks,

- Kever

Quoted 28 lines

---
? arch/arm/mach-rockchip/make_fit_atf.py | 5 +++-- ? 1 file changed, 3 insertions(+), 2 deletions(-)

arch/arm/mach-rockchip/make_fit_atf.py +0 -0
index d15c32b303..f3224d2555 100755
@@ -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