[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 Oct 31 02:06:25 PDT 2025
================
@@ -3572,45 +3572,62 @@ static inline void printFields(formatted_raw_ostream &OS, StringRef Str1,
OS.flush();
}
+template <class ELFT>
+static std::string getProgramHeadersNumString(const ELFFile<ELFT> &Obj,
+ StringRef FileName) {
+
+ if (Obj.getHeader().e_phnum != ELF::PN_XNUM)
+ return to_string(Obj.getHeader().e_phnum);
+
+ Expected<uint32_t> PhNumOrErr = Obj.getPhNum();
+ if (!PhNumOrErr) {
+ // In this case we can ignore an error, because we have already reported a
+ // warning about the broken section header table earlier.
----------------
jh7370 wrote:
This feels fragile and it's also not the right use-case for `consumeError`. llvm-readobj has `reportUniqueWarning` to ensure the same warning isn't printed more than once.
https://github.com/llvm/llvm-project/pull/165278
More information about the llvm-branch-commits
mailing list