1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[llvm-readobj] - Simplify and refine hash table tests

Now we are able to have default values for macros in YAML descriptions.
I've applied it for hash table tests and also fixed few copy-paste issues
in their comments.

Differential revision: https://reviews.llvm.org/D82870
This commit is contained in:
Georgii Rymar 2020-06-30 15:47:05 +03:00
parent a98c027f78
commit aa2b4ebf4e
3 changed files with 33 additions and 35 deletions

View File

@ -1,7 +1,7 @@
## Check how the GNU Hash section is dumped with --gnu-hash-table. ## Check how the GNU Hash section is dumped with --gnu-hash-table.
# RUN: yaml2obj --docnum=1 -DBITS=64 -DMACHINE=EM_X86_64 -D MASKWORDS=2 -D NBUCKETS=3 %s -o %t.x64 # RUN: yaml2obj --docnum=1 -DBITS=64 -DMACHINE=EM_X86_64 %s -o %t.x64
# RUN: yaml2obj --docnum=1 -DBITS=32 -DMACHINE=EM_386 %s -D MASKWORDS=2 -D NBUCKETS=3 -o %t.x32 # RUN: yaml2obj --docnum=1 -DBITS=32 -DMACHINE=EM_386 %s -o %t.x32
# RUN: llvm-readobj --gnu-hash-table %t.x64 | FileCheck %s # RUN: llvm-readobj --gnu-hash-table %t.x64 | FileCheck %s
# RUN: llvm-readelf --gnu-hash-table %t.x64 | FileCheck %s # RUN: llvm-readelf --gnu-hash-table %t.x64 | FileCheck %s
@ -33,9 +33,9 @@ Sections:
SymNdx: 0x1 SymNdx: 0x1
Shift2: 0x2 Shift2: 0x2
## The number of words in the Bloom filter. The value of 2 is no-op. ## The number of words in the Bloom filter. The value of 2 is no-op.
MaskWords: [[MASKWORDS]] MaskWords: [[MASKWORDS=2]]
## The number of hash buckets. The value of 3 is no-op. ## The number of hash buckets. The value of 3 is no-op.
NBuckets: [[NBUCKETS]] NBuckets: [[NBUCKETS=3]]
BloomFilter: [0x3, 0x4] BloomFilter: [0x3, 0x4]
HashBuckets: [0x5, 0x6, 0x7] HashBuckets: [0x5, 0x6, 0x7]
HashValues: [0x8, 0x9, 0xA, 0xB] HashValues: [0x8, 0x9, 0xA, 0xB]
@ -290,15 +290,15 @@ ProgramHeaders:
## Check we report a proper warning when a hash table goes past the end of the file. ## Check we report a proper warning when a hash table goes past the end of the file.
## Case A: the 'nbuckets' field is set so that the table goes past the end of the file. ## Case A: the 'maskwords' field is set so that the table goes past the end of the file.
# RUN: yaml2obj --docnum=1 -DBITS=64 -DMACHINE=EM_X86_64 -D MASKWORDS=4294967295 -D NBUCKETS=3 %s -o %t.err.maskwords # RUN: yaml2obj --docnum=1 -DBITS=64 -DMACHINE=EM_X86_64 -D MASKWORDS=4294967295 %s -o %t.err.maskwords
# RUN: llvm-readobj --gnu-hash-table %t.err.maskwords 2>&1 | \ # RUN: llvm-readobj --gnu-hash-table %t.err.maskwords 2>&1 | \
# RUN: FileCheck %s -DFILE=%t.err.maskwords -DMASKWORDS=4294967295 -DNBUCKETS=3 --check-prefix=ERR # RUN: FileCheck %s -DFILE=%t.err.maskwords -DMASKWORDS=4294967295 -DNBUCKETS=3 --check-prefix=ERR
# RUN: llvm-readelf --gnu-hash-table %t.err.maskwords 2>&1 | \ # RUN: llvm-readelf --gnu-hash-table %t.err.maskwords 2>&1 | \
# RUN: FileCheck %s -DFILE=%t.err.maskwords -DMASKWORDS=4294967295 -DNBUCKETS=3 --check-prefix=ERR # RUN: FileCheck %s -DFILE=%t.err.maskwords -DMASKWORDS=4294967295 -DNBUCKETS=3 --check-prefix=ERR
## Case B: the 'maskwords' field is set so that the table goes past the end of the file. ## Case B: the 'nbuckets' field is set so that the table goes past the end of the file.
# RUN: yaml2obj --docnum=1 -DBITS=64 -DMACHINE=EM_X86_64 -D MASKWORDS=2 -D NBUCKETS=4294967295 %s -o %t.err.nbuckets # RUN: yaml2obj --docnum=1 -DBITS=64 -DMACHINE=EM_X86_64 -D NBUCKETS=4294967295 %s -o %t.err.nbuckets
# RUN: llvm-readobj --gnu-hash-table %t.err.nbuckets 2>&1 | \ # RUN: llvm-readobj --gnu-hash-table %t.err.nbuckets 2>&1 | \
# RUN: FileCheck %s -DFILE=%t.err.nbuckets -DMASKWORDS=2 -DNBUCKETS=4294967295 --check-prefix=ERR # RUN: FileCheck %s -DFILE=%t.err.nbuckets -DMASKWORDS=2 -DNBUCKETS=4294967295 --check-prefix=ERR
# RUN: llvm-readelf --gnu-hash-table %t.err.nbuckets 2>&1 | \ # RUN: llvm-readelf --gnu-hash-table %t.err.nbuckets 2>&1 | \

View File

@ -211,8 +211,7 @@ ProgramHeaders:
## Check we dump a histogram for the .gnu.hash table even when the .hash table is skipped. ## Check we dump a histogram for the .gnu.hash table even when the .hash table is skipped.
## Case A: the .hash table has no data to build histogram and it is skipped. ## Case A: the .hash table has no data to build histogram and it is skipped.
## (NBUCKET == 0x2 is a no-op: it does not change the number of buckets described by the "Bucket" key). # RUN: yaml2obj --docnum=5 %s -o %t5.o
# RUN: yaml2obj --docnum=5 -DNBUCKET=0x2 %s -o %t5.o
# RUN: llvm-readelf --elf-hash-histogram %t5.o 2>&1 | \ # RUN: llvm-readelf --elf-hash-histogram %t5.o 2>&1 | \
# RUN: FileCheck %s --check-prefix=GNU-HASH --implicit-check-not="Histogram" # RUN: FileCheck %s --check-prefix=GNU-HASH --implicit-check-not="Histogram"
@ -236,7 +235,8 @@ Sections:
Type: SHT_HASH Type: SHT_HASH
Flags: [ SHF_ALLOC ] Flags: [ SHF_ALLOC ]
Bucket: [ 0 ] Bucket: [ 0 ]
NBucket: [[NBUCKET]] ## 0x2 is a no-op: it does not change the number of buckets described by the "Bucket" key
NBucket: [[NBUCKET=0x2]]
Chain: [ 0, 0 ] Chain: [ 0, 0 ]
- Name: .gnu.hash - Name: .gnu.hash
Type: SHT_GNU_HASH Type: SHT_GNU_HASH
@ -269,17 +269,15 @@ ProgramHeaders:
## Check we report a proper warning when the GNU hash table goes past the end of the file. ## Check we report a proper warning when the GNU hash table goes past the end of the file.
## Case A: the 'nbuckets' field is set so that the GNU hash table goes past the end of the file. ## Case A: the 'maskwords' field is set so that the GNU hash table goes past the end of the file.
## The value of 1 for the NBUCKETS is no-op. # RUN: yaml2obj --docnum=6 -D MASKWORDS=0x80000000 %s -o %t7
# RUN: yaml2obj --docnum=6 -D MASKWORDS=0x80000000 -D NBUCKETS=1 %s -o %t7
# RUN: llvm-readelf --elf-hash-histogram %t7 2>&1 | \ # RUN: llvm-readelf --elf-hash-histogram %t7 2>&1 | \
# RUN: FileCheck %s -DFILE=%t7 --check-prefix=ERR5 --implicit-check-not="Histogram" # RUN: FileCheck %s -DFILE=%t7 --check-prefix=ERR5 --implicit-check-not="Histogram"
# ERR5: warning: '[[FILE]]': unable to dump the SHT_GNU_HASH section at 0x78: it goes past the end of the file # ERR5: warning: '[[FILE]]': unable to dump the SHT_GNU_HASH section at 0x78: it goes past the end of the file
## Case B: the 'maskwords' field is set so that the GNU hash table goes past the end of the file. ## Case B: the 'nbuckets' field is set so that the GNU hash table goes past the end of the file.
## The value of 1 for the MASKWORDS is no-op. # RUN: yaml2obj --docnum=6 -D NBUCKETS=0x80000000 %s -o %t8
# RUN: yaml2obj --docnum=6 -D MASKWORDS=1 -D NBUCKETS=0x80000000 %s -o %t8
# RUN: llvm-readelf --elf-hash-histogram %t8 2>&1 | \ # RUN: llvm-readelf --elf-hash-histogram %t8 2>&1 | \
# RUN: FileCheck %s -DFILE=%t8 --check-prefix=ERR5 --implicit-check-not="Histogram" # RUN: FileCheck %s -DFILE=%t8 --check-prefix=ERR5 --implicit-check-not="Histogram"
@ -296,10 +294,10 @@ Sections:
Header: Header:
SymNdx: 0x0 SymNdx: 0x0
Shift2: 0x0 Shift2: 0x0
## The number of words in the Bloom filter. ## The number of words in the Bloom filter. The value of 1 is no-op.
MaskWords: [[MASKWORDS]] MaskWords: [[MASKWORDS=1]]
## The number of hash buckets. ## The number of hash buckets. The value of 1 is no-op.
NBuckets: [[NBUCKETS]] NBuckets: [[NBUCKETS=1]]
BloomFilter: [ 0x0 ] BloomFilter: [ 0x0 ]
HashBuckets: [ 0x0 ] HashBuckets: [ 0x0 ]
HashValues: [ 0x0 ] HashValues: [ 0x0 ]

View File

@ -388,7 +388,7 @@ ProgramHeaders:
## Case A.1: the hash table ends right before the EOF. We have a broken nbucket ## Case A.1: the hash table ends right before the EOF. We have a broken nbucket
## field that has a value larger than the number of buckets. ## field that has a value larger than the number of buckets.
# RUN: yaml2obj --docnum=7 %s -o %t7.1.o -DNBUCKET=0x5d -DNCHAIN=0x1 # RUN: yaml2obj --docnum=7 %s -o %t7.1.o -DNBUCKET=0x5d
# RUN: llvm-readelf --hash-symbols %t7.1.o 2>&1 | FileCheck %s --check-prefix=NOERR1 # RUN: llvm-readelf --hash-symbols %t7.1.o 2>&1 | FileCheck %s --check-prefix=NOERR1
# NOERR1: Symbol table of .hash for image: # NOERR1: Symbol table of .hash for image:
# NOERR1-NEXT: Num Buc: Value Size Type Bind Vis Ndx Name # NOERR1-NEXT: Num Buc: Value Size Type Bind Vis Ndx Name
@ -396,7 +396,7 @@ ProgramHeaders:
## Case A.2: the hash table ends 1 byte past the EOF. We have a broken nbucket ## Case A.2: the hash table ends 1 byte past the EOF. We have a broken nbucket
## field that has a value larger than the number of buckets. ## field that has a value larger than the number of buckets.
# RUN: yaml2obj --docnum=7 %s -o %t7.2.o -DNBUCKET=0x5e -DNCHAIN=0x1 # RUN: yaml2obj --docnum=7 %s -o %t7.2.o -DNBUCKET=0x5e
# RUN: llvm-readelf --hash-symbols %t7.2.o 2>&1 | FileCheck %s --check-prefix=ERR2 -DFILE=%t7.2.o # RUN: llvm-readelf --hash-symbols %t7.2.o 2>&1 | FileCheck %s --check-prefix=ERR2 -DFILE=%t7.2.o
# ERR2: Symbol table of .hash for image: # ERR2: Symbol table of .hash for image:
# ERR2-NEXT: warning: '[[FILE]]': the hash table at offset 0x54 goes past the end of the file (0x1d4), nbucket = 94, nchain = 1{{$}} # ERR2-NEXT: warning: '[[FILE]]': the hash table at offset 0x54 goes past the end of the file (0x1d4), nbucket = 94, nchain = 1{{$}}
@ -404,7 +404,7 @@ ProgramHeaders:
## Case B.1: the hash table ends right before the EOF. We have a broken nchain ## Case B.1: the hash table ends right before the EOF. We have a broken nchain
## field that has a value larger than the number of chains. ## field that has a value larger than the number of chains.
# RUN: yaml2obj --docnum=7 %s -o %t7.3.o -DNBUCKET=0x1 -DNCHAIN=0x5d # RUN: yaml2obj --docnum=7 %s -o %t7.3.o -DNCHAIN=0x5d
# RUN: llvm-readelf --hash-symbols %t7.3.o 2>&1 | \ # RUN: llvm-readelf --hash-symbols %t7.3.o 2>&1 | \
# RUN: FileCheck %s --implicit-check-not="warning:" --check-prefix=NOERR2 -DFILE=%t7.3.o # RUN: FileCheck %s --implicit-check-not="warning:" --check-prefix=NOERR2 -DFILE=%t7.3.o
# NOERR2: warning: '[[FILE]]': hash table nchain (93) differs from symbol count derived from SHT_DYNSYM section header (1) # NOERR2: warning: '[[FILE]]': hash table nchain (93) differs from symbol count derived from SHT_DYNSYM section header (1)
@ -414,7 +414,7 @@ ProgramHeaders:
## Case B.2: the hash table ends 1 byte past the EOF. We have a broken nchain ## Case B.2: the hash table ends 1 byte past the EOF. We have a broken nchain
## field that has a value larger than the number of chains. ## field that has a value larger than the number of chains.
# RUN: yaml2obj --docnum=7 %s -o %t7.4.o -DNBUCKET=0x1 -DNCHAIN=0x5e # RUN: yaml2obj --docnum=7 %s -o %t7.4.o -DNCHAIN=0x5e
# RUN: llvm-readelf --hash-symbols %t7.4.o 2>&1 | FileCheck %s --check-prefix=ERR3 -DFILE=%t7.4.o # RUN: llvm-readelf --hash-symbols %t7.4.o 2>&1 | FileCheck %s --check-prefix=ERR3 -DFILE=%t7.4.o
# ERR3: Symbol table of .hash for image: # ERR3: Symbol table of .hash for image:
# ERR3-NEXT: warning: '[[FILE]]': the hash table at offset 0x54 goes past the end of the file (0x1d4), nbucket = 1, nchain = 94{{$}} # ERR3-NEXT: warning: '[[FILE]]': the hash table at offset 0x54 goes past the end of the file (0x1d4), nbucket = 1, nchain = 94{{$}}
@ -431,9 +431,9 @@ Sections:
Type: SHT_HASH Type: SHT_HASH
Flags: [ SHF_ALLOC ] Flags: [ SHF_ALLOC ]
Bucket: [ 0 ] Bucket: [ 0 ]
NBucket: [[NBUCKET]] NBucket: [[NBUCKET=1]]
Chain: [ 0 ] Chain: [ 0 ]
NChain: [[NCHAIN]] NChain: [[NCHAIN=1]]
- Name: .dynamic - Name: .dynamic
Type: SHT_DYNAMIC Type: SHT_DYNAMIC
Flags: [ SHF_WRITE, SHF_ALLOC ] Flags: [ SHF_WRITE, SHF_ALLOC ]
@ -451,19 +451,19 @@ ProgramHeaders:
## Check we report a proper warning when a GNU hash table goes past the end of the file. ## Check we report a proper warning when a GNU hash table goes past the end of the file.
## Case A: the 'nbuckets' field is set so that the table goes past the end of the file. ## Case A: the 'maskwords' field is set so that the table goes past the end of the file.
# RUN: yaml2obj --docnum=8 -D MASKWORDS=4294967295 -D NBUCKETS=3 %s -o %t.err.maskwords # RUN: yaml2obj --docnum=8 -D MASKWORDS=4294967295 %s -o %t.err.maskwords
# RUN: llvm-readelf --hash-symbols %t.err.maskwords 2>&1 | \ # RUN: llvm-readelf --hash-symbols %t.err.maskwords 2>&1 | \
# RUN: FileCheck %s -DFILE=%t.err.maskwords -DMASKWORDS=4294967295 -DNBUCKETS=3 --check-prefix=ERR4 # RUN: FileCheck %s -DFILE=%t.err.maskwords --check-prefix=ERR4
# ERR4: Symbol table of .gnu.hash for image: # ERR4: Symbol table of .gnu.hash for image:
# ERR4-NEXT: Num Buc: Value Size Type Bind Vis Ndx Name # ERR4-NEXT: Num Buc: Value Size Type Bind Vis Ndx Name
# ERR4-NEXT: warning: '[[FILE]]': unable to dump the SHT_GNU_HASH section at 0x78: it goes past the end of the file # ERR4-NEXT: warning: '[[FILE]]': unable to dump the SHT_GNU_HASH section at 0x78: it goes past the end of the file
## Case B: the 'maskwords' field is set so that the table goes past the end of the file. ## Case B: the 'nbuckets' field is set so that the table goes past the end of the file.
# RUN: yaml2obj --docnum=8 -D MASKWORDS=2 -D NBUCKETS=4294967295 %s -o %t.err.nbuckets # RUN: yaml2obj --docnum=8 -D NBUCKETS=4294967295 %s -o %t.err.nbuckets
# RUN: llvm-readelf --hash-symbols %t.err.nbuckets 2>&1 | \ # RUN: llvm-readelf --hash-symbols %t.err.nbuckets 2>&1 | \
# RUN: FileCheck %s -DFILE=%t.err.nbuckets -DMASKWORDS=2 -DNBUCKETS=4294967295 --check-prefix=ERR4 # RUN: FileCheck %s -DFILE=%t.err.nbuckets --check-prefix=ERR4
--- !ELF --- !ELF
FileHeader: FileHeader:
@ -479,9 +479,9 @@ Sections:
SymNdx: 0x1 SymNdx: 0x1
Shift2: 0x2 Shift2: 0x2
## The number of words in the Bloom filter. The value of 2 is no-op. ## The number of words in the Bloom filter. The value of 2 is no-op.
MaskWords: [[MASKWORDS]] MaskWords: [[MASKWORDS=2]]
## The number of hash buckets. The value of 3 is no-op. ## The number of hash buckets. The value of 3 is no-op.
NBuckets: [[NBUCKETS]] NBuckets: [[NBUCKETS=3]]
BloomFilter: [0x3, 0x4] BloomFilter: [0x3, 0x4]
HashBuckets: [0x5, 0x6, 0x7] HashBuckets: [0x5, 0x6, 0x7]
HashValues: [0x8, 0x9, 0xA, 0xB] HashValues: [0x8, 0x9, 0xA, 0xB]