[llvm] [Object,ELF] Implement PN_XNUM extension for program headers (PR #162288)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 27 08:44:15 PDT 2025
================
@@ -891,6 +927,38 @@ Expected<uint64_t> ELFFile<ELFT>::getDynSymtabSize() const {
template <class ELFT> ELFFile<ELFT>::ELFFile(StringRef Object) : Buf(Object) {}
+template <class ELFT> Error ELFFile<ELFT>::readShdrZero() {
+ const Elf_Ehdr &Header = getHeader();
+
+ if ((Header.e_phnum == ELF::PN_XNUM || Header.e_shnum == 0 ||
+ Header.e_shstrndx == ELF::SHN_XINDEX) &&
+ Header.e_shoff != 0) {
+ // Pretend we have section 0 or sections() would call getShNum and thus
+ // become an infinite recursion.
+ if (Header.e_shnum == 0)
+ RealShNum = 1;
+ else
+ RealShNum = Header.e_shnum;
----------------
aokblast wrote:
That is fine. I just want to make sure that I fully understand your comment:).
And again, thanks for your review.
https://github.com/llvm/llvm-project/pull/162288
More information about the llvm-commits
mailing list