[lld] [llvm] [Object][ELF] Support extended header for Object Parser in ELF (PR #162288)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 9 00:24:07 PDT 2025


================
@@ -3575,9 +3575,16 @@ static inline void printFields(formatted_raw_ostream &OS, StringRef Str1,
 template <class ELFT>
 static std::string getSectionHeadersNumString(const ELFFile<ELFT> &Obj,
                                               StringRef FileName) {
-  const typename ELFT::Ehdr &ElfHeader = Obj.getHeader();
-  if (ElfHeader.e_shnum != 0)
-    return to_string(ElfHeader.e_shnum);
+  if (Obj.getHeader().e_shnum != 0) {
+    std::string Result;
+    if (Obj.getHeader().e_shnum != Obj.getShNum())
+      raw_string_ostream(Result)
+          << format("%x (%x)", static_cast<int>(Obj.getHeader().e_shnum),
----------------
MaskRay wrote:

Should cast to `uint32_t` instead of `int`

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


More information about the llvm-commits mailing list