[llvm] 1af309d - [ifs] Add the invalid STRSZ test to llvm-ifs

Haowei Wu via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 16 09:58:39 PST 2022


Author: Haowei Wu
Date: 2022-02-16T09:58:27-08:00
New Revision: 1af309d0c2efd1dcd9e54a8306145d0bc731d874

URL: https://github.com/llvm/llvm-project/commit/1af309d0c2efd1dcd9e54a8306145d0bc731d874
DIFF: https://github.com/llvm/llvm-project/commit/1af309d0c2efd1dcd9e54a8306145d0bc731d874.diff

LOG: [ifs] Add the invalid STRSZ test to llvm-ifs

This patch adds an addition test to test llvm-ifs's behavior when
DT_STRSZ value from .dynamic is invalid

Differential Revision: https://reviews.llvm.org/D119741

Added: 
    

Modified: 
    llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test b/llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test
index e9c0cf0ec0b86..905dcae329448 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test
@@ -1,5 +1,13 @@
-# RUN: yaml2obj %s -o %t
-# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe %t 2>&1 | FileCheck %s
+## Check bad DT_STRTAB address.
+
+# RUN: yaml2obj %s -DSTRSZ_VALUE=0x0000000000000001 -DSTRTAB_ADDR=0x0000000000000260 -o %t
+# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe %t 2>&1 | FileCheck %s -DERR_ADDR=0x260
+
+
+## Check bad DT_STRSZ size.
+
+# RUN: yaml2obj %s -DSTRSZ_VALUE=0x0000000000001000 -DSTRTAB_ADDR=0x0000000000001000 -o %t
+# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe %t 2>&1 | FileCheck %s -DERR_ADDR=0x2000
 
 !ELF
 FileHeader:
@@ -24,9 +32,9 @@ Sections:
       - Tag:             DT_SONAME
         Value:           0x0000000000000000
       - Tag:             DT_STRSZ
-        Value:           0x0000000000000001
+        Value:           [[STRSZ_VALUE]]
       - Tag:             DT_STRTAB
-        Value:           0x0000000000000260 # Bad vaddr (no PT_LOAD for 0x0000 to 0x0FFF)
+        Value:           [[STRTAB_ADDR]]
       - Tag:             DT_SYMTAB
         Value:           0x0000000000001000
       - Tag:             DT_NULL
@@ -44,4 +52,4 @@ ProgramHeaders:
     FirstSec: .dynamic
     LastSec:  .dynamic
 
-# CHECK: virtual address is not in any segment: 0x260 when locating dynamic string table section contents
+# CHECK: virtual address is not in any segment: [[ERR_ADDR]] when locating dynamic string table section contents


        


More information about the llvm-commits mailing list