This converts 2 more places to use `reportUniqueWarning` and adds tests.
Differential revision: https://reviews.llvm.org/D92551
## 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:
- Name: .hash
Type: SHT_HASH
Link: .dynsym
- Bucket: [ 1 ]
+ Bucket: [ 1, 1 ]
Chain: [ 0, 1 ]
- Name: .dynamic
Type: SHT_DYNAMIC
## 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:
- Name: .hash
Type: SHT_HASH
Link: .dynsym
- Bucket: [ 1 ]
+ Bucket: [ 1, 1 ]
Chain: [ 1, 1 ]
- Name: .dynamic
Type: SHT_DYNAMIC
- Tag: DT_HASH
Value: 0x0
DynamicSymbols:
- - Name: aaa
- - Name: bbb
+ - Name: aaa
ProgramHeaders:
- Type: PT_LOAD
FirstSec: .hash
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;
}
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;