[llvm] f31fa4f - [llvm-readobj][test] - Cleanup hash-histogram.test
Georgii Rymar via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 18 00:39:18 PST 2019
Author: Georgii Rymar
Date: 2019-12-18T11:36:49+03:00
New Revision: f31fa4f8981231ad2d32dc51979c96ec85657fe2
URL: https://github.com/llvm/llvm-project/commit/f31fa4f8981231ad2d32dc51979c96ec85657fe2
DIFF: https://github.com/llvm/llvm-project/commit/f31fa4f8981231ad2d32dc51979c96ec85657fe2.diff
LOG: [llvm-readobj][test] - Cleanup hash-histogram.test
In this test case we use 3 precompiled objects to
test how we print a histogram for an GNU hash section.
It does not make sense to use precompiled objects
for that. Also we could have 2 tests: one for 32 and
another for 64 bits target.
This patch does this change. It is not possible to remove
these precompiled objects because they are used elsewhere.
Differential revision: https://reviews.llvm.org/D71606
Added:
Modified:
llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-readobj/ELF/hash-histogram.test b/llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
index e0c29d15abca..203327ffab76 100644
--- a/llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
+++ b/llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
@@ -1,36 +1,96 @@
-# RUN: llvm-readelf --elf-hash-histogram %p/Inputs/gnuhash.so.elf-ppc64 \
-# RUN: | FileCheck %s -check-prefix PPC64GNU
-# RUN: llvm-readelf --elf-hash-histogram %p/Inputs/gnuhash.so.elf-x86_64 \
-# RUN: | FileCheck %s -check-prefix X86GNU
-# RUN: llvm-readelf --elf-hash-histogram %p/Inputs/got-plt.exe.elf-mipsel \
-# RUN: | FileCheck %s -check-prefix SYSV
+## Here we test the --elf-hash-histogram command line option.
-# PPC64GNU: Histogram for `.gnu.hash' bucket list length (total of 3 buckets)
-# PPC64GNU-NEXT: Length Number % of total Coverage
-# PPC64GNU-NEXT: 0 1 ( 33.3%) 0.0%
-# PPC64GNU-NEXT: 1 1 ( 33.3%) 25.0%
-# PPC64GNU-NEXT: 2 0 ( 0.0%) 25.0%
-# PPC64GNU-NEXT: 3 1 ( 33.3%) 100.0%
+## This test case checks how we built a histogram for a GNU hash section.
+## We check both 32-bit and 64-bit inputs.
-# X86GNU: Histogram for `.gnu.hash' bucket list length (total of 3 buckets)
-# X86GNU-NEXT: Length Number % of total Coverage
-# X86GNU-NEXT: 0 1 ( 33.3%) 0.0%
-# X86GNU-NEXT: 1 1 ( 33.3%) 25.0%
-# X86GNU-NEXT: 2 0 ( 0.0%) 25.0%
-# X86GNU-NEXT: 3 1 ( 33.3%) 100.0%
+# RUN: yaml2obj --docnum=1 %s -o %t1-32.o
+# RUN: llvm-readelf --elf-hash-histogram %t1-32.o | FileCheck %s --check-prefix=GNU-HASH
-# SYSV: Histogram for bucket list length (total of 3 buckets)
-# SYSV-NEXT: Length Number % of total Coverage
-# SYSV-NEXT: 0 0 ( 0.0%) 0.0%
-# SYSV-NEXT: 1 0 ( 0.0%) 0.0%
-# SYSV-NEXT: 2 2 ( 66.7%) 57.1%
-# SYSV-NEXT: 3 1 ( 33.3%) 100.0%
+# RUN: yaml2obj --docnum=2 %s -o %t1-64.o
+# RUN: llvm-readelf --elf-hash-histogram %t1-64.o | FileCheck %s --check-prefix=GNU-HASH
+
+# 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%
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_DYN
+ Machine: EM_386
+Sections:
+ - Name: .gnu.hash
+ Type: SHT_GNU_HASH
+ Flags: [ SHF_ALLOC ]
+ Header:
+ SymNdx: 0x1
+ Shift2: 0x0
+ BloomFilter: [ 0x0 ]
+ HashBuckets: [ 0x00000001, 0x00000004, 0x00000000 ]
+ HashValues: [ 0x0B887388, 0xECD54542, 0x7C92E3BB, 0x1C5871D9 ]
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ Entries:
+ - Tag: DT_GNU_HASH
+ Value: 0x0
+ - Tag: DT_NULL
+ Value: 0x0
+DynamicSymbols:
+ - Name: a
+ - Name: b
+ - Name: c
+ - Name: d
+ProgramHeaders:
+ - Type: PT_LOAD
+ Sections:
+ - Section: .gnu.hash
+ - Section: .dynamic
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_DYN
+ Machine: EM_X86_64
+Sections:
+ - Name: .gnu.hash
+ Type: SHT_GNU_HASH
+ Flags: [ SHF_ALLOC ]
+ Header:
+ SymNdx: 0x1
+ Shift2: 0x0
+ BloomFilter: [ 0x0 ]
+ HashBuckets: [ 0x00000001, 0x00000004, 0x00000000 ]
+ HashValues: [ 0x0B887388, 0xECD54542, 0x7C92E3BB, 0x1C5871D9 ]
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ Entries:
+ - Tag: DT_GNU_HASH
+ Value: 0x0
+ - Tag: DT_NULL
+ Value: 0x0
+DynamicSymbols:
+ - Name: a
+ - Name: b
+ - Name: c
+ - Name: d
+ProgramHeaders:
+ - Type: PT_LOAD
+ Sections:
+ - Section: .gnu.hash
+ - Section: .dynamic
## Show that we report a warning for a hash table which contains an entry of
## the bucket array pointing to a cycle.
-# RUN: yaml2obj %s -o %t.o
-# RUN: llvm-readelf --elf-hash-histogram 2>&1 %t.o | FileCheck -DFILE=%t.o %s --check-prefix BROKEN
+# RUN: yaml2obj --docnum=3 %s -o %t2.o
+# RUN: llvm-readelf --elf-hash-histogram 2>&1 %t2.o | FileCheck -DFILE=%t2.o %s --check-prefix=BROKEN
# BROKEN: warning: '[[FILE]]': .hash section is invalid: bucket 1: a cycle was detected in the linked chain
# BROKEN: Histogram for bucket list length (total of 1 buckets)
More information about the llvm-commits
mailing list