Menu

#524 elfcopy unconditionally sets PhysAddr to VirtAddr

RELEASE_1_0
closed
Kai Wang
None
2016-04-07
2016-03-21
Ed Maste
No

After [r1295] which added the --change-section-lma option the phdr p_paddr and p_vaddr are both set to the same address.

This breaks the FreeBSD Xen build as described in the thread at https://lists.freebsd.org/pipermail/freebsd-virtualization/2016-March/004243.html

With GNU objcopy:

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

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flg    Align
  PHDR           0x0000000000000040 0xffffffff80200040 0x0000000000200040
                 0x0000000000000150 0x0000000000000150  R E    0x8
  INTERP         0x0000000000000190 0xffffffff80200190 0x0000000000200190
                 0x000000000000000d 0x000000000000000d  R      0x1
      [Requesting program interpreter: /red/herring]
  LOAD           0x0000000000000000 0xffffffff80200000 0x0000000000200000
                 0x000000000147b978 0x000000000147b978  R E    0x200000
  LOAD           0x000000000147b978 0xffffffff8187b978 0x000000000187b978
                 0x0000000000134e40 0x000000000056e448  RW     0x200000
  DYNAMIC        0x000000000147b978 0xffffffff8187b978 0x000000000187b978
                 0x00000000000000d0 0x00000000000000d0  RW     0x8
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RWE    0x8

With elfcopy:

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

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flg    Align
  PHDR           0x0000000000000040 0xffffffff80200040 0xffffffff80200040
                 0x0000000000000150 0x0000000000000150  R E    0x8
  INTERP         0x0000000000000190 0xffffffff80200190 0xffffffff80200190
                 0x000000000000000d 0x000000000000000d  R      0x1
      [Requesting program interpreter: /red/herring]
  LOAD           0x0000000000000000 0xffffffff80200000 0xffffffff80200000
                 0x000000000147a418 0x000000000147a418  R E    0x200000
  LOAD           0x000000000147a418 0xffffffff8187a418 0xffffffff8187a418
                 0x0000000000134aa0 0x000000000056e0a8  RW     0x200000
  DYNAMIC        0x000000000147a418 0xffffffff8187a418 0xffffffff8187a418
                 0x00000000000000d0 0x00000000000000d0  RW     0x8
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RWE    0x8

Related

Commit: [r1295]

Discussion

  • Kai Wang

    Kai Wang - 2016-03-22
    • status: new --> accepted
    • assigned_to: Kai Wang
     
  • Kai Wang

    Kai Wang - 2016-03-22

    I'll handle it.

     
  • Kai Wang

    Kai Wang - 2016-03-22

    Might be fixed as of [r3436]. Need verify. Thanks!

     

    Related

    Commit: [r3436]

  • Ed Maste

    Ed Maste - 2016-03-23

    royger@freebsd tested and reports

    I've tried the patch and it indeed fixes the issue
    seen on the FreeBSD kernel, here's the readelf output now:

     
  • Ed Maste

    Ed Maste - 2016-04-07

    Kai do you have anything else you want to do here?

     
  • Kai Wang

    Kai Wang - 2016-04-07
    • status: accepted --> closed
     
  • Kai Wang

    Kai Wang - 2016-04-07

    Fixed.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.