[PATCH] D79038: [objcopy][ELF] Handle sections not contained in PT_LOAD segments

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 1 17:17:47 PDT 2020


MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.

The test does not make sense: .bss is not covered by a PT_LOAD.

  Section Headers:
    [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
    [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
    [ 1] .text             PROGBITS        0000000000008000 0000b0 000008 00  AX  0   0  8
    [ 2] .bss              NOBITS          0000000000008008 0000b8 000004 00  WA  0   0  1
  
  Program Headers:
    Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
    LOAD           0x0000b0 0x0000000000008000 0x0000000000008000 0x000008 0x000008 R E 0x8
    GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x1000000 RW  0

If we extend the existing PT_LOAD to cover `.bss`, then we can apply D74755 <https://reviews.llvm.org/D74755> instead. We don't need the special case for PT_GNU_STACK.

The description is also wrong now. I may say something like:

  A PT_GNU_STACK segment can have very large p_memsz (specified by ld -z stack-size=)
   and zero p_vaddr/p_paddr.
   
   `sectionWithinSegment` prefers assigning the parent segment of a section
   to the PT_GNU_STACK over a PT_LOAD. In the test, this causes .bss to have a large LMA and make the output much larger.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79038/new/

https://reviews.llvm.org/D79038





More information about the llvm-commits mailing list