Index: llvm/test/tools/llvm-readobj/ELF/hash-histogram.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/hash-histogram.test +++ llvm/test/tools/llvm-readobj/ELF/hash-histogram.test @@ -1,20 +1,28 @@ ## Here we test the --elf-hash-histogram command line option. -## This test case checks how we built a histogram for a GNU hash section. -## We check both 32-bit and 64-bit inputs. +## This test case checks how we built histograms for hash sections. -# RUN: yaml2obj --docnum=1 -D BITS=32 %s -o %t1-32.o -# RUN: llvm-readelf --elf-hash-histogram %t1-32.o | FileCheck %s --check-prefix=GNU-HASH +# RUN: yaml2obj --docnum=1 -D BITS=32 -D DTHASH=0x30 %s -o %t1-32.o +# RUN: llvm-readelf --elf-hash-histogram %t1-32.o | FileCheck %s --check-prefix=HIST +## Test --histogram and -I aliases. +# RUN: llvm-readelf --histogram %t1-32.o | FileCheck %s --check-prefix=HIST +# RUN: llvm-readelf -I %t1-32.o | FileCheck %s --check-prefix=HIST -# RUN: yaml2obj --docnum=1 -D BITS=64 %s -o %t1-64.o -# RUN: llvm-readelf --elf-hash-histogram %t1-64.o | FileCheck %s --check-prefix=GNU-HASH +# RUN: yaml2obj --docnum=1 -D BITS=64 -D DTHASH=0x34 %s -o %t1-64.o +# RUN: llvm-readelf --elf-hash-histogram %t1-64.o | FileCheck %s --check-prefix=HIST -# GNU-HASH: Histogram for `.gnu.hash' bucket list length (total of 3 buckets) -# GNU-HASH-NEXT: Length Number % of total Coverage -# GNU-HASH-NEXT: 0 1 ( 33.3%) 0.0% -# GNU-HASH-NEXT: 1 1 ( 33.3%) 25.0% -# GNU-HASH-NEXT: 2 0 ( 0.0%) 25.0% -# GNU-HASH-NEXT: 3 1 ( 33.3%) 100.0% +# HIST: Histogram for bucket list length (total of 3 buckets) +# HIST-NEXT: Length Number % of total Coverage +# HIST-NEXT: 0 2 ( 66.7%) 0.0% +# HIST-NEXT: 1 0 ( 0.0%) 0.0% +# HIST-NEXT: 2 0 ( 0.0%) 0.0% +# HIST-NEXT: 3 1 ( 33.3%) 100.0% +# HIST: Histogram for `.gnu.hash' bucket list length (total of 3 buckets) +# HIST-NEXT: Length Number % of total Coverage +# HIST-NEXT: 0 1 ( 33.3%) 0.0% +# HIST-NEXT: 1 1 ( 33.3%) 25.0% +# HIST-NEXT: 2 0 ( 0.0%) 25.0% +# HIST-NEXT: 3 1 ( 33.3%) 100.0% --- !ELF FileHeader: @@ -32,12 +40,20 @@ BloomFilter: [ 0x0 ] HashBuckets: [ 0x00000001, 0x00000004, 0x00000000 ] HashValues: [ 0x0B887388, 0xECD54542, 0x7C92E3BB, 0x1C5871D9 ] + - Name: .hash + Type: SHT_HASH + Flags: [ SHF_ALLOC ] + Bucket: [ 6, 4, 5 ] + Chain: [ 0, 0, 1, 0, 2 ] - Name: .dynamic Type: SHT_DYNAMIC Flags: [ SHF_WRITE, SHF_ALLOC ] Entries: - Tag: DT_GNU_HASH Value: 0x0 + - Tag: DT_HASH +## The value of DT_HASH must be equal to the size of the .gnu.hash section. + Value: [[DTHASH]] - Tag: DT_NULL Value: 0x0 DynamicSymbols: @@ -49,6 +65,7 @@ - Type: PT_LOAD Sections: - Section: .gnu.hash + - Section: .hash - Section: .dynamic ## Show that we report a warning for a hash table which contains an entry of