[llvm] [llvm-readobj, ELF] Support reading binary with more than PN_XNUM segments. (PR #165278)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 17 02:47:25 PST 2026
================
@@ -935,9 +935,13 @@ 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) {
+ // If e_shnum == 0 && e_shoff == 0, that means we actually have no section and
+ // thus is a valid ELF. But if the condition is still true when e_phnum ==
+ // PN_XNUM || e_shtstrndx == SHN_XINDEX and e_shoff == 0 The error will
+ // trigger when getSection() and e_shoff == 0
----------------
aokblast wrote:
Grpahite tells me to rebase this PR since this one have already created and is not a descend of my new PR (ELF.h fix only). Can I rebase it right now?
https://github.com/llvm/llvm-project/pull/165278
More information about the llvm-commits
mailing list