[llvm] [Object,ELF] Implement PN_XNUM extension for program headers (PR #162288)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 27 02:10:03 PDT 2025


================
@@ -278,9 +278,45 @@ class ELFFile {
   std::vector<Elf_Shdr> FakeSections;
   SmallString<0> FakeSectionStrings;
 
+  // When the number of program headers is >= 0xffff, the actual number is
+  // contained in the sh_info field of the section header at index 0.
+  std::optional<uint32_t> RealPhNum;
+  // When the number of section headers is >= 0xff00, the actual number is
+  // contained in the sh_size field of the section header at index 0.
+  std::optional<uint64_t> RealShNum;
+  // When the index of str section is >= 0xff00, the actual number is
----------------
jh7370 wrote:

Missed this one earlier. The "str section" isn't an unambiguous term (there can be lots of string sections in the ELF). Instead, let's do:

"When the section index of the section name table is >= SHN_LORESERVE ..."

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


More information about the llvm-commits mailing list