[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);
----------------
jh7370 wrote:

This should probably be using `Obj.getPhNum()`, as we discussed in the other review that clients should avoid referencing `e_phnum` directly (although I acknowledge that the check versus `PN_XNUM` is still needed in this context).

https://github.com/llvm/llvm-project/pull/165278


More information about the llvm-branch-commits mailing list