Skip to content

BE(?) broken since 0.15.0 #663

Description

@fda77

I can't use new version of patchelf since a long time, last working version is 0.15.0,
bad versions are 0.16.0 - 0.19.1
readelf -l shows Error: the PHDR segment is not covered by a LOAD segment

git-bisect shows this is the bad commit Rework file shifting to avoid sections crossing multiple segments

Freetz-NG supports various architectures, only BE are affected

  • fail: 7390-MIPS(BE) + 6360-ARMEB
  • okay: 7170-MISPEL + 4040-ARM(LE) + 6430-Ix86 + 5690XGS-AARCH64(LE)

AI told me the different PT_LOAD.p_align could be the cause .. i dont know:

  • ARM LE 0x1000
  • ARM BE 0x8000
  • but MIPS xE 0x10000

only error output:

for x in source/target-*/busybox-*/busybox; do
  echo "##### $x"
  cp "$x" ./busybox
  patchelf ./busybox --set-interpreter /usr/lib/freetz/ld-uClibc.so.1
  readelf -l ./busybox >/dev/null
done

##### source/target-aarch64_gcc-13.4.0_uClibc-1.0.59-nptl_kernel-5.4/busybox-1.38.0/busybox
##### source/target-armeb_gcc-4.7.4_uClibc-0.9.32.1-nptl/busybox-1.27.2/busybox
readelf: Error: the PHDR segment is not covered by a LOAD segment
##### source/target-arm_gcc-13.4.0_uClibc-1.0.59-nptl_kernel-4.4/busybox-1.38.0/busybox
##### source/target-i686_gcc-5.5.0_uClibc-1.0.14-nptl/busybox-1.27.2/busybox
##### source/target-mipsel_gcc-4.6.4_uClibc-0.9.28/busybox-1.27.2/busybox
##### source/target-mips_gcc-13.4.0_uClibc-1.0.59-nptl_kernel-4.9/busybox-1.38.0/busybox
readelf: Error: the PHDR segment is not covered by a LOAD segment
##### source/target-mips_gcc-4.8.5_uClibc-0.9.33.2-nptl/busybox-1.27.2/busybox
readelf: Error: the PHDR segment is not covered by a LOAD segment

full readelf output of:

for x in source/target-*/busybox-*/busybox; do
  echo "##### $x"
  cp "$x" ./busybox
  patchelf ./busybox --set-interpreter /usr/lib/freetz/ld-uClibc.so.1
  readelf -l ./busybox #>/dev/null
done
##### source/target-aarch64_gcc-13.4.0_uClibc-1.0.59-nptl_kernel-5.4/busybox-1.38.0/busybox

Elf file type is EXEC (Executable file)
Entry point 0x406c98
There are 9 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x00000000003e0040 0x00000000003e0040
                 0x00000000000001f8 0x00000000000001f8  R      0x8
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     0x10
  LOAD           0x0000000000000000 0x00000000003e0000 0x00000000003e0000
                 0x0000000000000258 0x0000000000000258  RW     0x10000
  INTERP         0x0000000000000238 0x00000000003e0238 0x00000000003e0238
                 0x000000000000001f 0x000000000000001f  R      0x1
      [Requesting program interpreter: /usr/lib/freetz/ld-uClibc.so.1]
  LOAD           0x0000000000020218 0x0000000000400218 0x0000000000400218
                 0x00000000000c212c 0x00000000000c212c  R E    0x10000
  GNU_EH_FRAME   0x00000000000e2290 0x00000000004c2290 0x00000000004c2290
                 0x000000000000002c 0x000000000000002c  R      0x4
  LOAD           0x00000000000efdf0 0x00000000004dfdf0 0x00000000004dfdf0
                 0x0000000000000c4d 0x00000000000012f8  RW     0x10000
  GNU_RELRO      0x00000000000efdf0 0x00000000004dfdf0 0x00000000004dfdf0
                 0x0000000000000210 0x0000000000000210  R      0x1
  DYNAMIC        0x00000000000efe00 0x00000000004dfe00 0x00000000004dfe00
                 0x00000000000001c0 0x00000000000001c0  RW     0x8

 Section to Segment mapping:
  Segment Sections...
   00
   01
   02     .interp
   03     .interp
   04     .hash .gnu.hash .dynsym .dynstr .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame
   05     .eh_frame_hdr
   06     .init_array .fini_array .dynamic .got .got.plt .data .bss
   07     .init_array .fini_array .dynamic .got
   08     .dynamic
##### source/target-armeb_gcc-4.7.4_uClibc-0.9.32.1-nptl/busybox-1.27.2/busybox

Elf file type is EXEC (Executable file)
Entry point 0xc004
There are 8 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x00006034 0x00006034 0x00100 0x00100 R E 0x4
readelf: Error: the PHDR segment is not covered by a LOAD segment
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x4
  INTERP         0x000134 0x00006134 0x00006134 0x0001f 0x0001f R   0x1
      [Requesting program interpreter: /usr/lib/freetz/ld-uClibc.so.1]
  LOAD           0x002128 0x00008128 0x00008128 0x9c59c 0x9c59c R E 0x1000
  ARM_EXIDX      0x09e5f0 0x000a45f0 0x000a45f0 0x000d0 0x000d0 R   0x4
  LOAD           0x09f000 0x000ad000 0x000ad000 0x005cd 0x00bf0 RW  0x1000
  DYNAMIC        0x09f00c 0x000ad00c 0x000ad00c 0x000d8 0x000d8 RW  0x4
  LOAD           0x2820ded8 0x2880ded8 0x2880ded8 0x00154 0x00154 RW  0x1000

 Section to Segment mapping:
  Segment Sections...
   00
   01
   02     .interp
   03     .hash .dynsym .dynstr .rel.dyn .rel.plt .init .plt .text .fini .rodata .ARM.extab .ARM.exidx .eh_frame
   04     .ARM.exidx
   05     .init_array .fini_array .jcr .dynamic .got .data .bss
   06     .dynamic
   07
##### source/target-arm_gcc-13.4.0_uClibc-1.0.59-nptl_kernel-4.4/busybox-1.38.0/busybox

Elf file type is EXEC (Executable file)
Entry point 0x2bdd8
There are 9 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x0000e034 0x0000e034 0x00120 0x00120 R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10
  LOAD           0x000000 0x0000e000 0x0000e000 0x00174 0x00174 RW  0x1000
  INTERP         0x000154 0x0000e154 0x0000e154 0x0001f 0x0001f R   0x1
      [Requesting program interpreter: /usr/lib/freetz/ld-uClibc.so.1]
  LOAD           0x002148 0x00010148 0x00010148 0xc949c 0xc949c R E 0x1000
  ARM_EXIDX      0x0cb5d8 0x000d95d8 0x000d95d8 0x00008 0x00008 R   0x4
  LOAD           0x0cbf18 0x000daf18 0x000daf18 0x00611 0x00ba0 RW  0x1000
  GNU_RELRO      0x0cbf18 0x000daf18 0x000daf18 0x000e8 0x000e8 R   0x1
  DYNAMIC        0x0cbf20 0x000daf20 0x000daf20 0x000e0 0x000e0 RW  0x4

 Section to Segment mapping:
  Segment Sections...
   00
   01
   02     .interp
   03     .interp
   04     .hash .gnu.hash .dynsym .dynstr .rel.dyn .rel.plt .init .plt .text .fini .rodata .ARM.exidx .eh_frame
   05     .ARM.exidx
   06     .init_array .fini_array .dynamic .got .data .bss
   07     .init_array .fini_array .dynamic
   08     .dynamic
##### source/target-i686_gcc-5.5.0_uClibc-1.0.14-nptl/busybox-1.27.2/busybox

Elf file type is EXEC (Executable file)
Entry point 0x809c598
There are 8 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x08046034 0x08046034 0x00100 0x00100 R E 0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10
  LOAD           0x000000 0x08046000 0x08046000 0x00154 0x00154 RW  0x1000
  INTERP         0x000134 0x08046134 0x08046134 0x0001f 0x0001f R   0x1
      [Requesting program interpreter: /usr/lib/freetz/ld-uClibc.so.1]
  LOAD           0x002128 0x08048128 0x08048128 0xa4814 0xa4814 R E 0x1000
  GNU_EH_FRAME   0x0a67f4 0x080ec7f4 0x080ec7f4 0x0003c 0x0003c R   0x4
  LOAD           0x0a7000 0x080ed000 0x080ed000 0x0059f 0x00bd4 RW  0x1000
  DYNAMIC        0x0a7014 0x080ed014 0x080ed014 0x000b8 0x000b8 RW  0x4

 Section to Segment mapping:
  Segment Sections...
   00
   01
   02     .interp
   03     .interp
   04     .hash .dynsym .dynstr .rel.dyn .rel.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame
   05     .eh_frame_hdr
   06     .ctors .dtors .jcr .dynamic .got.plt .data .bss
   07     .dynamic
##### source/target-mipsel_gcc-4.6.4_uClibc-0.9.28/busybox-1.27.2/busybox

Elf file type is EXEC (Executable file)
Entry point 0x404a20
There are 8 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x003e0034 0x003e0034 0x00100 0x00100 R E 0x4
  NULL           0x000000 0x00000000 0x00000000 0x00000 0x00000     0x4
  LOAD           0x000000 0x003e0000 0x003e0000 0x00154 0x00154 RW  0x10000
  INTERP         0x000134 0x003e0134 0x003e0134 0x0001f 0x0001f R   0x1
      [Requesting program interpreter: /usr/lib/freetz/ld-uClibc.so.1]
  LOAD           0x020128 0x00400128 0x00400128 0xa4e00 0xa4e00 R E 0x10000
  DYNAMIC        0x020128 0x00400128 0x00400128 0x00100 0x00100 RWE 0x4
  GNU_EH_FRAME   0x0c4eb0 0x004a4eb0 0x004a4eb0 0x00024 0x00024 R   0x4
  LOAD           0x0c5000 0x004b5000 0x004b5000 0x006a8 0x00ef0 RW  0x10000

 Section to Segment mapping:
  Segment Sections...
   00
   01
   02     .interp
   03     .interp
   04     .dynamic .hash .dynsym .dynstr .rel.dyn .rel.plt .init .plt .text .MIPS.stubs .fini .rodata .eh_frame_hdr .eh_frame
   05     .dynamic
   06     .eh_frame_hdr
   07     .ctors .dtors .jcr .data .rld_map .got.plt .got .sbss .bss
##### source/target-mips_gcc-13.4.0_uClibc-1.0.59-nptl_kernel-4.9/busybox-1.38.0/busybox

Elf file type is EXEC (Executable file)
Entry point 0x4036a0
There are 10 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x003e0034 0x003e0034 0x00140 0x00140 R   0x4
readelf: Error: the PHDR segment is not covered by a LOAD segment
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10
  NULL           0x000000 0x00000000 0x00000000 0x00000 0x00000     0x4
  INTERP         0x000174 0x003e0174 0x003e0174 0x0001f 0x0001f R   0x1
      [Requesting program interpreter: /usr/lib/freetz/ld-uClibc.so.1]
  ABIFLAGS       0x020168 0x00400168 0x00400168 0x00018 0x00018 R   0x8
  LOAD           0x020168 0x00400168 0x00400168 0xe5438 0xe5438 R E 0x10000
  DYNAMIC        0x020180 0x00400180 0x00400180 0x00108 0x00108 R   0x4
  GNU_EH_FRAME   0x1040c4 0x004e40c4 0x004e40c4 0x0002c 0x0002c R   0x4
  LOAD           0x106000 0x004f6000 0x004f6000 0x0054c 0x00abc RW  0x10000
  LOAD           0x67ff0098 0x67ff3e98 0x67ff3e98 0x00194 0x00194 RW  0x10000

 Section to Segment mapping:
  Segment Sections...
   00
   01
   02
   03     .interp
   04     .MIPS.abiflags
   05     .MIPS.abiflags .dynamic .hash .dynsym .dynstr .rel.dyn .rel.plt .init .text .fini .rodata .eh_frame_hdr .eh_frame .plt
   06     .dynamic
   07     .eh_frame_hdr
   08     .ctors .dtors .got.plt .data .rld_map .got .bss
   09
##### source/target-mips_gcc-4.8.5_uClibc-0.9.33.2-nptl/busybox-1.27.2/busybox

Elf file type is EXEC (Executable file)
Entry point 0x404750
There are 9 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x003e0034 0x003e0034 0x00120 0x00120 R E 0x4
readelf: Error: the PHDR segment is not covered by a LOAD segment
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
  NULL           0x000000 0x00000000 0x00000000 0x00000 0x00000     0x4
  INTERP         0x000154 0x003e0154 0x003e0154 0x0001f 0x0001f R   0x1
      [Requesting program interpreter: /usr/lib/freetz/ld-uClibc.so.1]
  LOAD           0x020148 0x00400148 0x00400148 0xb45b0 0xb45b0 R E 0x10000
  DYNAMIC        0x020148 0x00400148 0x00400148 0x00100 0x00100 RWE 0x4
  GNU_EH_FRAME   0x0d4664 0x004b4664 0x004b4664 0x0002c 0x0002c R   0x4
  LOAD           0x0d5000 0x004c5000 0x004c5000 0x00564 0x00b90 RW  0x10000
  LOAD           0x47ff00b8 0x47ff3eb8 0x47ff3eb8 0x00174 0x00174 RW  0x10000

 Section to Segment mapping:
  Segment Sections...
   00
   01
   02
   03     .interp
   04     .dynamic .hash .dynsym .dynstr .rel.dyn .rel.plt .init .plt .text .MIPS.stubs .fini .rodata .eh_frame_hdr .eh_frame
   05     .dynamic
   06     .eh_frame_hdr
   07     .ctors .dtors .jcr .data .rld_map .got.plt .got .sdata .sbss .bss
   08

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions