[PATCH] D79038: [objdump][ELF] Handle sections not contained in PT_LOAD segments
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 30 10:08:26 PDT 2020
MaskRay added a comment.
In D79038#2013052 <https://reviews.llvm.org/D79038#2013052>, @LemonBoy wrote:
> > What is actually the difference between them here?
>
> The difference doesn't really matter here as the segment PAddr and VAddr are zero, the test case passes by simply avoiding the `Sec.Addr` assigment for sections with non-PT_LOAD segments, that's why it's been suggested to patch `setParentSegment` and keep the old logic.
> The added logic takes into account one more edge case, as explained by this comment in BFD:
>
> /* We used to use the same adjustment for SEC_LOAD
> sections, but that doesn't work if the segment
> is packed with code from multiple VMAs.
> Instead we calculate the section LMA based on
> the segment LMA. It is assumed that the
> segment will contain sections with contiguous
> LMAs, even if the VMAs are not. */
>
>
> If you prefer a less-invasive patch I can simply go for the `setParentSegment` route.
I did some shallow analysis of bfd/elf.c's rules related to bfd_section::lma/file offset/etc. They are overly complex and I am pretty sure we can do better than them. Their distinction of PT_LOAD ver non-PT_LOAD is artificial and can really be simplified if they don't do that. I second to James that we should not make PT_LOAD different.
Unfortunately, the PT_GNU_RELRO use case (p_vaddr=p_paddr=0, large p_memsz) means we still have to specialize something. It seems that we can simply treat PT_GNU_RELRO as an (ugly) exception.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79038/new/
https://reviews.llvm.org/D79038
More information about the llvm-commits
mailing list