[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
Fri Feb 27 08:12:07 PST 2026


================
@@ -222,14 +224,32 @@ Sections:
 ## Check we don't dump anything except the file header when the section header table can't be read.
 
 # RUN: not llvm-readobj -a %t.invalid1 2>&1 \
-# RUN:  | FileCheck %s -DFILE=%t.invalid1 -DSECHDRCOUNT=8192 -DSECHDRSTRTABINDEX=12288 --check-prefix=INVALID-LLVM
+# RUN:  | FileCheck %s -DFILE=%t.invalid1 -DSECHDROFF=0x1000 -DPHDRCOUNT="0" -DSECHDRCOUNT=8192 -DSECHDRSTRTABINDEX=12288 --check-prefix=INVALID-LLVM
 # RUN: not llvm-readelf -a %t.invalid1 2>&1 \
-# RUN:  | FileCheck %s -DFILE=%t.invalid1 -DSECHDRCOUNT=8192 -DSECHDRSTRTABINDEX=12288 --check-prefix=INVALID-GNU
+# RUN:  | FileCheck %s -DFILE=%t.invalid1 -DSECHDROFF=4096 -DPHDRCOUNT="0" -DSECHDRCOUNT=8192 -DSECHDRSTRTABINDEX=12288 --check-prefix=INVALID-GNU
 
 ## Check what we print when e_shnum == 0, e_shstrndx == SHN_XINDEX and the section header table can't be read.
+## TODO: We should not report LLVM-BAD-PHDR and GNU-BAD-PHDR in the future since these are duplicate errors.
----------------
aokblast wrote:

This is a little bit weird now... We used to have duplicate error since it is reported from reading PhNum. But now we ignore the error when we are not reading the field. (if the error cause by shnum but we are reading phnum, we ignore it). 

The duplication is still there but not happens now because we only adopt new interface for phnum (we don't use getShNum() and getShStrNdx()).
Should we remove this line?

The phnum won't have duplicate error since it is not used for initContent().

Now, I use LLVM-BAD-PHDR and LLVM-BAD-PHDR2 to distinguish between invalid testcase 3 and 4

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


More information about the llvm-branch-commits mailing list