[llvm] [llvm-objdump] Fix lma display issue for non-bss sections (PR #72141)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 13 16:04:26 PST 2023
================
@@ -4507,43 +4507,6 @@ static bool checkTLSSections(const typename ELFT::Phdr &Phdr,
return Phdr.p_type != ELF::PT_TLS;
}
-template <class ELFT>
-static bool checkOffsets(const typename ELFT::Phdr &Phdr,
- const typename ELFT::Shdr &Sec) {
- // SHT_NOBITS sections don't need to have an offset inside the segment.
- if (Sec.sh_type == ELF::SHT_NOBITS)
- return true;
-
- if (Sec.sh_offset < Phdr.p_offset)
- return false;
-
- // Only non-empty sections can be at the end of a segment.
- if (Sec.sh_size == 0)
- return (Sec.sh_offset + 1 <= Phdr.p_offset + Phdr.p_filesz);
- return Sec.sh_offset + Sec.sh_size <= Phdr.p_offset + Phdr.p_filesz;
-}
-
-// Check that an allocatable section belongs to a virtual address
-// space of a segment.
-template <class ELFT>
-static bool checkVMA(const typename ELFT::Phdr &Phdr,
- const typename ELFT::Shdr &Sec) {
- if (!(Sec.sh_flags & ELF::SHF_ALLOC))
- return true;
-
- if (Sec.sh_addr < Phdr.p_vaddr)
- return false;
-
- bool IsTbss =
- (Sec.sh_type == ELF::SHT_NOBITS) && ((Sec.sh_flags & ELF::SHF_TLS) != 0);
- // .tbss is special, it only has memory in PT_TLS and has NOBITS properties.
- bool IsTbssInNonTLS = IsTbss && Phdr.p_type != ELF::PT_TLS;
- // Only non-empty sections can be at the end of a segment.
- if (Sec.sh_size == 0 || IsTbssInNonTLS)
----------------
MaskRay wrote:
If I change the condition to `if (0)`, no test will fail, which means that we don't have coverage for an empty sectio nat the end of a segment (`llvm-readelf -S`)
https://github.com/llvm/llvm-project/pull/72141
More information about the llvm-commits
mailing list