diff options
| author | James Henderson <jh7370@my.bristol.ac.uk> | 2019-06-14 12:02:01 +0000 |
|---|---|---|
| committer | James Henderson <jh7370@my.bristol.ac.uk> | 2019-06-14 12:02:01 +0000 |
| commit | f7cfabb45d87121962be8a6e0d81009a2b8788a6 (patch) | |
| tree | e6e1897818821e3875d2a9c3b79df2e1b131b3e4 /llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test | |
| parent | 78b2cf71f5f2cdcbcbea06f069022fa4818f42a4 (diff) | |
| download | bcm5719-llvm-f7cfabb45d87121962be8a6e0d81009a2b8788a6.tar.gz bcm5719-llvm-f7cfabb45d87121962be8a6e0d81009a2b8788a6.zip | |
[llvm-readobj] Don't abort printing of dynamic table if string reference is invalid
If dynamic table is missing, output "dynamic strtab not found'. If the index is
out of range, output "Invalid Offset<..>".
https://bugs.llvm.org/show_bug.cgi?id=40807
Reviewed by: jhenderson, grimar, MaskRay
Differential Revision: https://reviews.llvm.org/D63084
Patch by Yuanfang Chen.
llvm-svn: 363374
Diffstat (limited to 'llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test')
| -rw-r--r-- | llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test b/llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test index abc0f89310c..337fedec5a5 100644 --- a/llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test +++ b/llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test @@ -68,13 +68,28 @@ ProgramHeaders: Sections: - Section: .dynamic -# Test handling of string references pointing past the end of the dynamic string table. In this case, -# we have a DT_NEEDED tag pointing at offset 1 in a 1-byte string table. +# Test handling of string references pointing past the end of the dynamic string table. # RUN: yaml2obj %s --docnum=3 -o %t.bad-string -# RUN: not llvm-readobj --dynamic-table %t.bad-string 2>&1 | FileCheck %s --check-prefix BAD-STRING -# RUN: not llvm-readelf --dynamic-table %t.bad-string 2>&1 | FileCheck %s --check-prefix BAD-STRING +# RUN: llvm-readobj --dynamic-table %t.bad-string | FileCheck %s --check-prefix BAD-STRING-LLVM +# RUN: llvm-readelf --dynamic-table %t.bad-string | FileCheck %s --check-prefix BAD-STRING-GNU -# BAD-STRING: Invalid dynamic string table reference +# BAD-STRING-LLVM: 0x000000000000000A STRSZ 1 (bytes) +# BAD-STRING-LLVM: 0x0000000000000001 NEEDED Shared library: <Invalid offset 0x1> +# BAD-STRING-LLVM: 0x000000007FFFFFFF FILTER Filter library: <Invalid offset 0x1> +# BAD-STRING-LLVM: 0x000000007FFFFFFD AUXILIARY Auxiliary library: <Invalid offset 0x1> +# BAD-STRING-LLVM: 0x000000007FFFFFFE USED Not needed object: <Invalid offset 0x1> +# BAD-STRING-LLVM: 0x000000000000000E SONAME Library soname: <Invalid offset 0x1> +# BAD-STRING-LLVM: 0x000000000000000F RPATH <Invalid offset 0x1> +# BAD-STRING-LLVM: 0x000000000000001D RUNPATH <Invalid offset 0x1> + +# BAD-STRING-GNU: 0x000000000000000a (STRSZ) 1 (bytes) +# BAD-STRING-GNU: 0x0000000000000001 (NEEDED) Shared library: <Invalid offset 0x1> +# BAD-STRING-GNU: 0x000000007fffffff (FILTER) Filter library: <Invalid offset 0x1> +# BAD-STRING-GNU: 0x000000007ffffffd (AUXILIARY) Auxiliary library: <Invalid offset 0x1> +# BAD-STRING-GNU: 0x000000007ffffffe (USED) Not needed object: <Invalid offset 0x1> +# BAD-STRING-GNU: 0x000000000000000e (SONAME) Library soname: <Invalid offset 0x1> +# BAD-STRING-GNU: 0x000000000000000f (RPATH) <Invalid offset 0x1> +# BAD-STRING-GNU: 0x000000000000001d (RUNPATH) <Invalid offset 0x1> --- !ELF FileHeader: @@ -96,6 +111,18 @@ Sections: Value: 1 - Tag: DT_NEEDED Value: 1 + - Tag: DT_FILTER + Value: 1 + - Tag: DT_AUXILIARY + Value: 1 + - Tag: DT_USED + Value: 1 + - Tag: DT_SONAME + Value: 1 + - Tag: DT_RPATH + Value: 1 + - Tag: DT_RUNPATH + Value: 1 - Tag: DT_NULL Value: 0 ProgramHeaders: @@ -111,11 +138,19 @@ ProgramHeaders: # Test handling of DT_STRTAB pointing outside the file's address space. # RUN: yaml2obj %s --docnum=4 -o %t.bad-strtab -# RUN: not llvm-readobj --dynamic-table %t.bad-strtab 2>&1 | FileCheck %s --check-prefix BAD-STRTAB -# RUN: not llvm-readelf --dynamic-table %t.bad-strtab 2>&1 | FileCheck %s --check-prefix BAD-STRTAB -# BAD-STRTAB: warning: Unable to parse DT_STRTAB: Virtual address is not in any segment -# BAD-STRTAB: error: Invalid dynamic string table reference +# RUN: llvm-readobj --dynamic-table %t.bad-strtab 2>&1 >/dev/null | FileCheck %s --check-prefix BAD-STRTAB-ERR +# RUN: llvm-readelf --dynamic-table %t.bad-strtab 2>&1 >/dev/null | FileCheck %s --check-prefix BAD-STRTAB-ERR +# BAD-STRTAB-ERR: warning: Unable to parse DT_STRTAB: Virtual address is not in any segment + +# RUN: llvm-readobj --dynamic-table --needed-libs %t.bad-strtab | FileCheck %s --check-prefixes=BAD-STRTAB,BAD-STRTAB-LLVM +# RUN: llvm-readelf --dynamic-table --needed-libs %t.bad-strtab | FileCheck %s --check-prefixes=BAD-STRTAB,BAD-STRTAB-GNU +# BAD-STRTAB-LLVM: LoadName: <Not found> +# BAD-STRTAB-LLVM: 0x0000000000000001 NEEDED Shared library: <String table is empty or was not found> +# BAD-STRTAB-GNU: 0x0000000000000001 (NEEDED) Shared library: <String table is empty or was not found> +# BAD-STRTAB: NeededLibraries [ +# BAD-STRTAB: <Library name index out of range> +# BAD-STRTAB: ] --- !ELF FileHeader: |

