[PATCH] D76920: [llvm-readobj] - Improve test of --elf-hash-histogram option.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 27 05:56:34 PDT 2020


grimar created this revision.
grimar added reviewers: jhenderson, MaskRay.
Herald added subscribers: rupprecht, emaste.
Herald added a reviewer: espindola.

This test missed the check of histograms printed for .hash sections.
It was removed by mistake in D71606 <https://reviews.llvm.org/D71606> where I tried to get rid of precompiled objects
and seems did not realize that time that both SHT_GNU_HASH and SHT_HASH sections
were tested and not just GNU version.

Also it never tested aliases for the --elf-hash-histogram option.


https://reviews.llvm.org/D76920

Files:
  llvm/test/tools/llvm-readobj/ELF/hash-histogram.test


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76920.253091.patch
Type: text/x-patch
Size: 3230 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200327/5fd2b51c/attachment.bin>


More information about the llvm-commits mailing list