[llvm] [Object,ELF] Implement PN_XNUM extension for program headers (PR #162288)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 17 02:12:00 PDT 2025
================
@@ -889,7 +887,31 @@ Expected<uint64_t> ELFFile<ELFT>::getDynSymtabSize() const {
return 0;
}
-template <class ELFT> ELFFile<ELFT>::ELFFile(StringRef Object) : Buf(Object) {}
+template <class ELFT> ELFFile<ELFT>::ELFFile(StringRef Object) : Buf(Object) {
+ const Elf_Ehdr &Header = getHeader();
+ RealPhNum = Header.e_phnum;
+ RealShNum = Header.e_shnum;
+ RealShStrNdx = Header.e_shstrndx;
+ if (!Header.hasPhdrNumExtension())
+ return;
+
+ // An ELF binary may report `hasExtendedHeader` as true but not actually
+ // include an extended header. For example, a core dump can contain 65,535
----------------
aokblast wrote:
What is the better choice for us?
According to [gabi](https://gabi.xinuos.com/v42/elf/02-eheader.html), they don't provide special term for this condition. Also, extended header is used in LLDB which also provides mechanism to parse special section 0.
Should we call hasSection0Header? Or something else?
https://github.com/llvm/llvm-project/pull/162288
More information about the llvm-commits
mailing list