[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 Feb 27 01:13:49 PST 2026


================
@@ -0,0 +1,45 @@
+## 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 --file-headers %t1 | FileCheck %s --check-prefix=VALID-GNU
+## The ELF header should have e_phnum == PN_XNUM
+# VALID-GNU:         Number of program headers: 65535 (2)
+# RUN: llvm-readobj --file-headers %t1 | FileCheck %s --check-prefix=VALID-LLVM
+# VALID-LLVM:        ProgramHeaderCount: 65535 (2)
----------------
jh7370 wrote:

I'd reorder these to put the CHECKS after the RUN lines, with a blank line separating them. It makes it easier to read:

```
# RUN: yaml2obj ...
# RUN: llvm-readelf ...
# RUN: llvm-readobj ...

# VALID-GNU: ...
# VALID-LLVM: ...

---! ELF
etc
```

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


More information about the llvm-branch-commits mailing list