[llvm-branch-commits] [llvm] [llvm-readobj, ELF] Support reading binary with more than PN_XNUM segments. (PR #165278)
James Henderson via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Feb 27 01:13:49 PST 2026
================
@@ -4853,10 +4873,17 @@ template <class ELFT> void GNUELFDumper<ELFT>::printProgramHeaders() {
const Elf_Ehdr &Header = this->Obj.getHeader();
Field Fields[8] = {2, 17, 26, 37 + Bias,
48 + Bias, 56 + Bias, 64 + Bias, 68 + Bias};
+ uint32_t PhNum = 0;
+ Expected<uint32_t> PhNumOrErr = this->Obj.getPhNum();
+ if (PhNumOrErr)
+ PhNum = *PhNumOrErr;
+ else
+ this->reportUniqueWarning(PhNumOrErr.takeError());
+
OS << "\nElf file type is "
<< enumToString(Header.e_type, ArrayRef(ElfObjectFileType)) << "\n"
<< "Entry point " << format_hex(Header.e_entry, 3) << "\n"
- << "There are " << Header.e_phnum << " program headers,"
+ << "There are " << PhNum << " program headers,"
----------------
jh7370 wrote:
I'd expect to see test coverage for this behaviour with `>= PN_XNUM` program headers. Also test coverage for this code executing when there's a problem with reading the program header count.
https://github.com/llvm/llvm-project/pull/165278
More information about the llvm-branch-commits
mailing list