[llvm-branch-commits] [llvm] 351f736 - [llvm-readelf] - Report unique warnings when dumping hash symbols/histogram.

Georgii Rymar via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Dec 3 03:09:58 PST 2020


Author: Georgii Rymar
Date: 2020-12-03T14:05:04+03:00
New Revision: 351f736368842cb7e961791fb7e3a3065a260c51

URL: https://github.com/llvm/llvm-project/commit/351f736368842cb7e961791fb7e3a3065a260c51
DIFF: https://github.com/llvm/llvm-project/commit/351f736368842cb7e961791fb7e3a3065a260c51.diff

LOG: [llvm-readelf] - Report unique warnings when dumping hash symbols/histogram.

This converts 2 more places to use `reportUniqueWarning` and adds tests.

Differential revision: https://reviews.llvm.org/D92551

Added: 
    

Modified: 
    llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
    llvm/test/tools/llvm-readobj/ELF/hash-symbols.test
    llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-readobj/ELF/hash-histogram.test b/llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
index cc187f477aa0..f4db2d8ad7d7 100644
--- a/llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
+++ b/llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
@@ -71,13 +71,14 @@ ProgramHeaders:
 ## the bucket array pointing to a cycle.
 
 # RUN: yaml2obj --docnum=2 %s -o %t2.o
-# RUN: llvm-readelf --elf-hash-histogram 2>&1 %t2.o | FileCheck -DFILE=%t2.o %s --check-prefix=BROKEN
+# RUN: llvm-readelf --elf-hash-histogram 2>&1 %t2.o | \
+# RUN:   FileCheck -DFILE=%t2.o %s --check-prefix=BROKEN --implicit-check-not=warning:
 
 # 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)
+# BROKEN:       Histogram for bucket list length (total of 2 buckets)
 # BROKEN-NEXT:  Length  Number     % of total  Coverage
 # BROKEN-NEXT:       0  0          (  0.0%)       0.0%
-# BROKEN-NEXT:       1  1          (100.0%)     100.0%
+# BROKEN-NEXT:       1  2          (100.0%)     100.0%
 
 --- !ELF
 FileHeader:
@@ -88,7 +89,7 @@ Sections:
   - Name:   .hash
     Type:   SHT_HASH
     Link:   .dynsym
-    Bucket: [ 1 ]
+    Bucket: [ 1, 1 ]
     Chain:  [ 0, 1 ]
   - Name:  .dynamic
     Type:  SHT_DYNAMIC

diff  --git a/llvm/test/tools/llvm-readobj/ELF/hash-symbols.test b/llvm/test/tools/llvm-readobj/ELF/hash-symbols.test
index 49db87e04ddb..e0ee9cec893a 100644
--- a/llvm/test/tools/llvm-readobj/ELF/hash-symbols.test
+++ b/llvm/test/tools/llvm-readobj/ELF/hash-symbols.test
@@ -328,12 +328,15 @@ ProgramHeaders:
 ## the bucket array pointing to a cycle.
 
 # RUN: yaml2obj --docnum=5 %s -o %t5.so
-# RUN: llvm-readelf --hash-symbols %t5.so 2>&1 | FileCheck %s -DFILE=%t5.so --check-prefix=BROKEN
+# RUN: llvm-readelf --hash-symbols %t5.so 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t5.so --check-prefix=BROKEN --implicit-check-not=warning:
 
 # BROKEN:      Symbol table of .hash for image:
 # BROKEN-NEXT:  Num Buc:    Value  Size   Type   Bind Vis      Ndx Name
 # BROKEN-NEXT:    1   0: 00000000     0 NOTYPE  LOCAL  DEFAULT UND aaa
 # BROKEN: warning: '[[FILE]]': .hash section is invalid: bucket 1: a cycle was detected in the linked chain
+# BROKEN-NEXT:    1   1: 00000000     0 NOTYPE  LOCAL  DEFAULT UND aaa
+# BROKEN-NOT: {{.}}
 
 --- !ELF
 FileHeader:
@@ -344,7 +347,7 @@ Sections:
   - Name:    .hash
     Type:    SHT_HASH
     Link:    .dynsym
-    Bucket:  [ 1 ]
+    Bucket:  [ 1, 1 ]
     Chain:   [ 1, 1 ]
   - Name:  .dynamic
     Type:  SHT_DYNAMIC
@@ -355,8 +358,7 @@ Sections:
       - Tag:   DT_HASH
         Value: 0x0
 DynamicSymbols:
-  - Name:    aaa
-  - Name:    bbb
+  - Name: aaa
 ProgramHeaders:
   - Type:     PT_LOAD
     FirstSec: .hash

diff  --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 646616f6649d..ebcad74808ab 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -4124,10 +4124,9 @@ void GNUStyle<ELFT>::printHashTableSymbols(const Elf_Hash &SysVHash) {
         break;
 
       if (Visited[Ch]) {
-        reportWarning(createError(".hash section is invalid: bucket " +
+        this->reportUniqueWarning(".hash section is invalid: bucket " +
                                   Twine(Ch) +
-                                  ": a cycle was detected in the linked chain"),
-                      this->FileName);
+                                  ": a cycle was detected in the linked chain");
         break;
       }
 
@@ -4868,10 +4867,9 @@ void GNUStyle<ELFT>::printHashHistogram(const Elf_Hash &HashTable) {
       if (C == ELF::STN_UNDEF)
         break;
       if (Visited[C]) {
-        reportWarning(createError(".hash section is invalid: bucket " +
+        this->reportUniqueWarning(".hash section is invalid: bucket " +
                                   Twine(C) +
-                                  ": a cycle was detected in the linked chain"),
-                      this->FileName);
+                                  ": a cycle was detected in the linked chain");
         break;
       }
       Visited[C] = true;


        


More information about the llvm-branch-commits mailing list