[llvm-branch-commits] [llvm] [llvm-readobj, ELF] Support reading binary with more than PN_XNUM segments. (PR #165278)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Feb 24 09:16:35 PST 2026


================
@@ -0,0 +1,29 @@
+## Here we simulate an object with more than ~65k segments and check how we dump it.
+## When an ELF object has PN_XNUM (0xffff) or more sections, its e_phnum field
+## should be PN_XNUM and sh_info of the section header at index 0 is used
+## to store the value.
+
+# RUN: yaml2obj --docnum=1 %s -o %t1
+# RUN: llvm-readelf --headers %t1 | FileCheck %s --check-prefix=GNU
+## The ELF header should have e_phnum == PN_XNUM
+# GNU:         Number of program headers: 65535 (2)
----------------
aokblast wrote:

```
x86_64-unknown-freebsd16.0-readelf --file-header /home/blast/Gits/llvm-project/build/test/tools/llvm-readobj/ELF/Output/many-segments.test.tmp1
```

Output:

```
  Number of program headers:         65535 (2)
```

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


More information about the llvm-branch-commits mailing list