[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
================
@@ -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.
# RUN: yaml2obj %s -DSHNUM=0 -DSHSTRNDX=0xffff --docnum=4 -o %t.invalid2
# RUN: not llvm-readobj --file-headers %t.invalid2 2>&1 \
-# RUN: | FileCheck %s -DFILE=%t.invalid2 -DSECHDRCOUNT="<?>" -DSECHDRSTRTABINDEX="<?>" --check-prefix=INVALID-LLVM
+# RUN: | FileCheck %s -DFILE=%t.invalid2 -DSECHDROFF=0x1000 -DPHDRCOUNT="0" -DSECHDRCOUNT="<?>" -DSECHDRSTRTABINDEX="<?>" --check-prefix=INVALID-LLVM,LLVM-BAD-PHDR
# RUN: not llvm-readelf --file-headers %t.invalid2 2>&1 \
-# RUN: | FileCheck %s -DFILE=%t.invalid2 -DSECHDRCOUNT="<?>" -DSECHDRSTRTABINDEX="<?>" --check-prefix=INVALID-GNU
+# RUN: | FileCheck %s -DFILE=%t.invalid2 -DSECHDROFF=4096 -DPHDRCOUNT="0" -DSECHDRCOUNT="<?>" -DSECHDRSTRTABINDEX="<?>" --check-prefix=INVALID-GNU,GNU-BAD-PHDR
+
+# RUN: yaml2obj %s --docnum=5 -o %t.invalid3
----------------
jh7370 wrote:
Please add a comment to explain the purpose of this test case, like the other test cases in this file.
https://github.com/llvm/llvm-project/pull/165278
More information about the llvm-branch-commits
mailing list