[PATCH] D92382: [llvm-readelf/obj] - Report unique warnings in `parseDynamicTable`.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 1 04:13:27 PST 2020
grimar created this revision.
grimar added reviewers: jhenderson, MaskRay.
Herald added subscribers: rupprecht, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
grimar requested review of this revision.
This makes the warnings reported to be unique and adds test cases.
https://reviews.llvm.org/D92382
Files:
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
llvm/tools/llvm-readobj/ELFDumper.cpp
Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -2089,11 +2089,9 @@
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();
@@ -2133,11 +2131,10 @@
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:
Index: llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
===================================================================
--- llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
+++ llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test
@@ -215,6 +215,9 @@
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
Index: llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
===================================================================
--- llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
+++ llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
@@ -451,11 +451,15 @@
## 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 @@
- Name: .dynamic
Type: SHT_DYNAMIC
Entries:
+ - Tag: DT_SYMENT
+ Value: 0x123
- Tag: DT_SYMENT
Value: 0x123
- Tag: DT_NULL
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92382.308614.patch
Type: text/x-patch
Size: 4021 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201201/28b0e0d4/attachment.bin>
More information about the llvm-commits
mailing list