[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 20 01:02:50 PST 2026
================
@@ -0,0 +1,45 @@
+# RUN: yaml2obj --docnum=1 %s -o %t.o
+
+# RUN: llvm-readobj --headers %t.o 2>&1 | FileCheck %s -DFILE=%t.o --check-prefix=CASE-INVALID
+
+# CASE-INVALID: SectionHeaderOffset: 0x0
+# CASE-INVALID: ProgramHeaderEntrySize: 56
+# CASE-INVALID-NEXT: warning: '[[FILE]]': invalid section index: 0
+# CASE-INVALID-NEXT: ProgramHeaderCount: <?>
+# CASE-INVALID-NEXT: SectionHeaderEntrySize: 64
+# CASE-INVALID-NEXT: SectionHeaderCount: 0
+# CASE-INVALID-NEXT: StringTableSectionIndex: 65535 (corrupt: out of range)
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+ EPhNum: 65535
+ EShNum: 0
+ EShStrNdx: 0xffff
+ EShOff: 0
+ProgramHeaders:
+ - Type: PT_LOAD
+
+# RUN: yaml2obj --docnum=2 %s -o %t2.o
+
+# RUN: llvm-readobj --headers %t2.o 2>&1 | FileCheck %s --check-prefix=CASE-VALID
----------------
jh7370 wrote:
It's probably best to be explicit about which headers you're dumping - you want to dump both program headers and the file header, but you don't need other headers.
I'd also add `--implicit-check-not=warning:` to the FileCheck invocation, to show there are no other warnings produced.
Also, why is this case being tested in this file and not in `many-segments.test`?
https://github.com/llvm/llvm-project/pull/165278
More information about the llvm-branch-commits
mailing list