[llvm-branch-commits] [llvm] 5c650d3 - [llvm-readobj] - Report unique warnings in printProgramHeaders.
Georgii Rymar via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Dec 4 02:46:42 PST 2020
Author: Georgii Rymar
Date: 2020-12-04T13:35:44+03:00
New Revision: 5c650d3d9b03a59fa547a0414fbd3a6942c25395
URL: https://github.com/llvm/llvm-project/commit/5c650d3d9b03a59fa547a0414fbd3a6942c25395
DIFF: https://github.com/llvm/llvm-project/commit/5c650d3d9b03a59fa547a0414fbd3a6942c25395.diff
LOG: [llvm-readobj] - Report unique warnings in printProgramHeaders.
This converts `reportWarning` -> `reportUniqueWarning`
Differential revision: https://reviews.llvm.org/D92568
Added:
Modified:
llvm/test/tools/llvm-readobj/ELF/program-headers.test
llvm/tools/llvm-readobj/ELFDumper.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-readobj/ELF/program-headers.test b/llvm/test/tools/llvm-readobj/ELF/program-headers.test
index d876a239ba68..3a0fb1e462d3 100644
--- a/llvm/test/tools/llvm-readobj/ELF/program-headers.test
+++ b/llvm/test/tools/llvm-readobj/ELF/program-headers.test
@@ -607,16 +607,16 @@ ProgramHeaders:
## Show the size of the output produced. It is used in the YAML below.
# RUN: wc -c < %t.err | FileCheck %s --check-prefix=SIZE
-# SIZE: 560
+# SIZE: 616
## Write the additional 'C', '\0, 'C' bytes to the end.
# RUN: echo -n -e "C\x00C" >> %t.err
# RUN: llvm-readelf --program-headers %t.err 2>&1 | \
-# RUN: FileCheck %s -DFILE=%t.err --check-prefix=ERROR-INTERP
+# RUN: FileCheck %s -DFILE=%t.err --check-prefix=ERROR-INTERP --implicit-check-not=warning:
# ERROR-INTERP: Type Offset
-# ERROR-INTERP-NEXT: INTERP 0x000[[#%x,OFFSET:0x230]]
+# ERROR-INTERP-NEXT: INTERP 0x000[[#%x,OFFSET:0x268]]
# ERROR-INTERP-NEXT: [Requesting program interpreter: C]
# ERROR-INTERP-NEXT: INTERP 0x000[[#OFFSET + 1]]
# ERROR-INTERP-NEXT: [Requesting program interpreter: ]
@@ -626,6 +626,7 @@ ProgramHeaders:
# ERROR-INTERP-NEXT: warning: '[[FILE]]': unable to read program interpreter name at offset 0x[[#OFFSET+3]]: it goes past the end of the file (0x[[#OFFSET + 3]])
# ERROR-INTERP-NEXT: INTERP 0xaabbccddeeff1122
# ERROR-INTERP-NEXT: warning: '[[FILE]]': unable to read program interpreter name at offset 0xaabbccddeeff1122: it goes past the end of the file (0x[[#OFFSET + 3]])
+# ERROR-INTERP-NEXT: INTERP 0xaabbccddeeff1122
--- !ELF
FileHeader:
@@ -635,21 +636,25 @@ FileHeader:
ProgramHeaders:
## Case 1: the offset points to the first additional byte.
- Type: PT_INTERP
- Offset: 560
+ Offset: 616
## Case 1: the offset points to the second additional byte,
## which is a null byte.
- Type: PT_INTERP
- Offset: 561
+ Offset: 617
## Case 3: the offset points to the third additional
## byte, which is the last byte in the file.
- Type: PT_INTERP
- Offset: 562
+ Offset: 618
## Case 4: the offset goes 1 byte past the end of the file.
- Type: PT_INTERP
- Offset: 563
+ Offset: 619
## Case 5: an arbitrary large offset that goes past the end of the file.
- Type: PT_INTERP
Offset: 0xAABBCCDDEEFF1122
+## Case 6: the same as case 5. Used to demonstrate that we don't report
+## the same warning twice.
+ - Type: PT_INTERP
+ Offset: 0xAABBCCDDEEFF1122
## Check we report a warning when we are unable to read program headers.
## Case A: the e_phentsize field is invalid.
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 13d053179356..e682581684e9 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -4473,10 +4473,9 @@ template <class ELFT> void GNUStyle<ELFT>::printProgramHeaders() {
if (Phdr.p_type == ELF::PT_INTERP) {
OS << "\n";
auto ReportBadInterp = [&](const Twine &Msg) {
- reportWarning(
- createError("unable to read program interpreter name at offset 0x" +
- Twine::utohexstr(Phdr.p_offset) + ": " + Msg),
- this->FileName);
+ this->reportUniqueWarning(
+ "unable to read program interpreter name at offset 0x" +
+ Twine::utohexstr(Phdr.p_offset) + ": " + Msg);
};
if (Phdr.p_offset >= this->Obj.getBufSize()) {
More information about the llvm-branch-commits
mailing list