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

LemonBoy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 00:29:49 PDT 2020


LemonBoy added a comment.

> I don't understand the issue here personally

As explained by @MaskRay you can create a segment with zero starting address and arbitrarily large memsize by using the `-z stack-size=` switch, the libc interprets that value as the minimum size for new threads. The segment acts as a catch-all parent segment for many sections, such as the `.bss` in the test case, and causes problems in the LMA calculation code.

> Sec.Addr isn't really well defined at that point in the code

There's an unfortunate typo in the patch, the equation is meant to simply rebase the `sh_addr` by subtracting the phdr vaddr and adding its paddr.

> this seems to suggest that we should patch template <class ELFT> void ELFBuilder<ELFT>::setParentSegment(Segment &Child) to take into account this case

I decided against that because I couldn't find any definition of what makes a segment eligible to be a parent. If we use the same logic that `readelf` uses then the PT_STACK_SIZE is indeed a parent for `.bss`

  Section to Segment mapping:
   Segment Sections...
    00     .text 
    01     .bss 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79038





More information about the llvm-commits mailing list