[llvm-branch-commits] [llvm] 21b6c04 - [llvm-readelf/obj] - Report unique warnings in `parseDynamicTable`.
Georgii Rymar via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Dec 2 01:58:45 PST 2020
Author: Georgii Rymar
Date: 2020-12-02T12:52:42+03:00
New Revision: 21b6c04e3a02d67cebb3e3bc3d43d3e9311ea915
URL: https://github.com/llvm/llvm-project/commit/21b6c04e3a02d67cebb3e3bc3d43d3e9311ea915
DIFF: https://github.com/llvm/llvm-project/commit/21b6c04e3a02d67cebb3e3bc3d43d3e9311ea915.diff
LOG: [llvm-readelf/obj] - Report unique warnings in `parseDynamicTable`.
This makes the warnings reported to be unique and adds test cases.
Differential revision: https://reviews.llvm.org/D92382
Added:
Modified:
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
llvm/tools/llvm-readobj/ELFDumper.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test b/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
index eb976f673b93..43ca57a80b61 100644
--- a/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
+++ b/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
@@ -451,11 +451,15 @@ DynamicSymbols: []
## c) In the case when the DT_SYMENT tag is present, we report when it's value does not match the
# value of the symbol size for the platform.
# RUN: yaml2obj %s -D BITS=32 --docnum=12 -o %t12
-# RUN: llvm-readobj --dyn-symbols %t12 2>&1 | FileCheck %s -DFILE=%t12 --check-prefix=DYNSYM-SIZE-INVALID3
-# RUN: llvm-readelf --dyn-symbols %t12 2>&1 | FileCheck %s -DFILE=%t12 --check-prefix=DYNSYM-SIZE-INVALID3
+# RUN: llvm-readobj --dyn-symbols %t12 2>&1 | \
+# RUN: FileCheck %s -DFILE=%t12 --implicit-check-not=warning: --check-prefix=DYNSYM-SIZE-INVALID3
+# RUN: llvm-readelf --dyn-symbols %t12 2>&1 | \
+# RUN: FileCheck %s -DFILE=%t12 --implicit-check-not=warning: --check-prefix=DYNSYM-SIZE-INVALID3
# RUN: yaml2obj %s -D BITS=64 --docnum=12 -o %t13
-# RUN: llvm-readobj --dyn-symbols %t13 2>&1 | FileCheck %s -DFILE=%t13 --check-prefix=DYNSYM-SIZE-INVALID4
-# RUN: llvm-readelf --dyn-symbols %t13 2>&1 | FileCheck %s -DFILE=%t13 --check-prefix=DYNSYM-SIZE-INVALID4
+# RUN: llvm-readobj --dyn-symbols %t13 2>&1 | \
+# RUN: FileCheck %s -DFILE=%t13 --implicit-check-not=warning: --check-prefix=DYNSYM-SIZE-INVALID4
+# RUN: llvm-readelf --dyn-symbols %t13 2>&1 | \
+# RUN: FileCheck %s -DFILE=%t13 --implicit-check-not=warning: --check-prefix=DYNSYM-SIZE-INVALID4
# DYNSYM-SIZE-INVALID3: warning: '[[FILE]]': DT_SYMENT value of 0x123 is not the size of a symbol (0x10){{$}}
# DYNSYM-SIZE-INVALID4: warning: '[[FILE]]': DT_SYMENT value of 0x123 is not the size of a symbol (0x18){{$}}
@@ -502,6 +506,8 @@ Sections:
- Name: .dynamic
Type: SHT_DYNAMIC
Entries:
+ - Tag: DT_SYMENT
+ Value: 0x123
- Tag: DT_SYMENT
Value: 0x123
- Tag: DT_NULL
diff --git a/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test b/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
index 48ab1d914c3b..bb12ce80d9e2 100644
--- a/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
@@ -215,6 +215,9 @@ Sections:
Type: SHT_DYNAMIC
Address: 0x1000
Entries:
+## Two DT_STRTAB entries are needed to check that we don't report it twice.
+ - Tag: DT_STRTAB
+ Value: 0x2000000
- Tag: DT_STRTAB
Value: 0x2000000
- Tag: DT_STRSZ
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index be018e18a912..8a774da52772 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -2090,11 +2090,9 @@ void ELFDumper<ELFT>::parseDynamicTable() {
auto toMappedAddr = [&](uint64_t Tag, uint64_t VAddr) -> const uint8_t * {
auto MappedAddrOrError = Obj.toMappedAddr(VAddr);
if (!MappedAddrOrError) {
- Error Err =
- createError("Unable to parse DT_" + Obj.getDynamicTagAsString(Tag) +
- ": " + llvm::toString(MappedAddrOrError.takeError()));
-
- reportWarning(std::move(Err), ObjF.getFileName());
+ this->reportUniqueWarning("Unable to parse DT_" +
+ Obj.getDynamicTagAsString(Tag) + ": " +
+ llvm::toString(MappedAddrOrError.takeError()));
return nullptr;
}
return MappedAddrOrError.get();
@@ -2134,11 +2132,10 @@ void ELFDumper<ELFT>::parseDynamicTable() {
case ELF::DT_SYMENT: {
uint64_t Val = Dyn.getVal();
if (Val != sizeof(Elf_Sym))
- reportWarning(createError("DT_SYMENT value of 0x" +
+ this->reportUniqueWarning("DT_SYMENT value of 0x" +
Twine::utohexstr(Val) +
" is not the size of a symbol (0x" +
- Twine::utohexstr(sizeof(Elf_Sym)) + ")"),
- ObjF.getFileName());
+ Twine::utohexstr(sizeof(Elf_Sym)) + ")");
break;
}
case ELF::DT_RELA:
More information about the llvm-branch-commits
mailing list