[PATCH] D92556: [llvm-readelf/obj] - Report unique warnings in getSymbolForReloc() helper.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 3 03:14:42 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG50de7d55044a: [llvm-readelf/obj] - Report unique warnings in getSymbolForReloc() helper. (authored by grimar).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92556/new/
https://reviews.llvm.org/D92556
Files:
llvm/test/tools/llvm-readobj/ELF/broken-dynamic-reloc.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
@@ -4554,16 +4554,14 @@
namespace {
template <class ELFT>
-RelSymbol<ELFT> getSymbolForReloc(const ELFFile<ELFT> &Obj, StringRef FileName,
- const ELFDumper<ELFT> &Dumper,
+RelSymbol<ELFT> getSymbolForReloc(const ELFDumper<ELFT> &Dumper,
const Relocation<ELFT> &Reloc) {
using Elf_Sym = typename ELFT::Sym;
auto WarnAndReturn = [&](const Elf_Sym *Sym,
const Twine &Reason) -> RelSymbol<ELFT> {
- reportWarning(
- createError("unable to get name of the dynamic symbol with index " +
- Twine(Reloc.Symbol) + ": " + Reason),
- FileName);
+ Dumper.reportUniqueWarning(
+ "unable to get name of the dynamic symbol with index " +
+ Twine(Reloc.Symbol) + ": " + Reason);
return {Sym, "<corrupt>"};
};
@@ -4581,6 +4579,7 @@
"index is greater than or equal to the number of dynamic symbols (" +
Twine(Symbols.size()) + ")");
+ const ELFFile<ELFT> &Obj = *Dumper.getElfObject().getELFFile();
const uint64_t FileSize = Obj.getBufSize();
const uint64_t SymOffset = ((const uint8_t *)FirstSym - Obj.base()) +
(uint64_t)Reloc.Symbol * sizeof(Elf_Sym);
@@ -4600,8 +4599,7 @@
template <class ELFT>
void GNUStyle<ELFT>::printDynamicReloc(const Relocation<ELFT> &R) {
- printRelRelaReloc(
- R, getSymbolForReloc(this->Obj, this->FileName, this->dumper(), R));
+ printRelRelaReloc(R, getSymbolForReloc(this->dumper(), R));
}
template <class ELFT>
@@ -6604,8 +6602,7 @@
template <class ELFT>
void LLVMStyle<ELFT>::printDynamicReloc(const Relocation<ELFT> &R) {
- RelSymbol<ELFT> S =
- getSymbolForReloc(this->Obj, this->FileName, this->dumper(), R);
+ RelSymbol<ELFT> S = getSymbolForReloc(this->dumper(), R);
printRelRelaReloc(R, S.Name);
}
Index: llvm/test/tools/llvm-readobj/ELF/broken-dynamic-reloc.test
===================================================================
--- llvm/test/tools/llvm-readobj/ELF/broken-dynamic-reloc.test
+++ llvm/test/tools/llvm-readobj/ELF/broken-dynamic-reloc.test
@@ -260,18 +260,22 @@
## Show we print a warning when the symbol index of a dynamic relocation is too
## large (goes past the end of the dynamic symbol table).
# RUN: yaml2obj --docnum=5 %s -o %t12
-# RUN: llvm-readobj --dyn-relocations %t12 2>&1 | FileCheck %s -DFILE=%t12 --check-prefix=LLVM-INVALID-DYNSYM
-# RUN: llvm-readelf --dyn-relocations %t12 2>&1 | FileCheck %s -DFILE=%t12 --check-prefix=GNU-INVALID-DYNSYM
+# RUN: llvm-readobj --dyn-relocations %t12 2>&1 | \
+# RUN: FileCheck %s -DFILE=%t12 --implicit-check-not=warning: --check-prefix=LLVM-INVALID-DYNSYM
+# RUN: llvm-readelf --dyn-relocations %t12 2>&1 | \
+# RUN: FileCheck %s -DFILE=%t12 --implicit-check-not=warning: --check-prefix=GNU-INVALID-DYNSYM
# LLVM-INVALID-DYNSYM: Dynamic Relocations {
# LLVM-INVALID-DYNSYM-NEXT: warning: '[[FILE]]': unable to get name of the dynamic symbol with index 2: index is greater than or equal to the number of dynamic symbols (2)
# LLVM-INVALID-DYNSYM-NEXT: 0x0 R_X86_64_NONE <corrupt> 0x0
+# LLVM-INVALID-DYNSYM-NEXT: 0x0 R_X86_64_NONE <corrupt> 0x0
# LLVM-INVALID-DYNSYM-NEXT: }
-# GNU-INVALID-DYNSYM: 'RELA' relocation section at offset 0x78 contains 24 bytes:
+# GNU-INVALID-DYNSYM: 'RELA' relocation section at offset 0x78 contains 48 bytes:
# GNU-INVALID-DYNSYM-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
# GNU-INVALID-DYNSYM-NEXT: warning: '[[FILE]]': unable to get name of the dynamic symbol with index 2: index is greater than or equal to the number of dynamic symbols (2)
# GNU-INVALID-DYNSYM-NEXT: 0000000000000000 0000000200000000 R_X86_64_NONE <corrupt> + 0
+# GNU-INVALID-DYNSYM-NEXT: 0000000000000000 0000000200000000 R_X86_64_NONE <corrupt> + 0
--- !ELF
FileHeader:
@@ -285,13 +289,15 @@
Relocations:
- Type: R_X86_64_NONE
Symbol: 0x2
+ - Type: R_X86_64_NONE
+ Symbol: 0x2
- Name: .dynamic
Type: SHT_DYNAMIC
Entries:
- Tag: DT_RELA
Value: 0x0
- Tag: DT_RELASZ
- Value: 0x18
+ Value: 0x30
- Tag: DT_RELAENT
Value: 0x18
- Tag: DT_NULL
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92556.309211.patch
Type: text/x-patch
Size: 4553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201203/7581b196/attachment.bin>
More information about the llvm-commits
mailing list