[PATCH] D87089: [llvm-readobj] - Remove code duplication when printing dynamic relocations. NFCI.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 06:11:57 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4368739941eb: [llvm-readobj] - Remove code duplication when printing dynamic relocations. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D87089?vs=289705&id=290270#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87089/new/
https://reviews.llvm.org/D87089
Files:
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
@@ -960,6 +960,7 @@
void printRelrReloc(const Elf_Relr &R) override;
void printDynamicReloc(const Relocation<ELFT> &R) override;
+ void printRelRelaReloc(const Relocation<ELFT> &R, StringRef SymbolName);
void printSymbols();
void printDynamicSymbols();
void printSymbolSection(const Elf_Sym *Symbol, const Elf_Sym *First);
@@ -6156,7 +6157,12 @@
return;
}
- std::string TargetName = Target->Name;
+ printRelRelaReloc(R, Target->Name);
+}
+
+template <class ELFT>
+void LLVMStyle<ELFT>::printRelRelaReloc(const Relocation<ELFT> &R,
+ StringRef SymbolName) {
SmallString<32> RelocName;
this->Obj.getRelocationTypeName(R.Type, RelocName);
@@ -6165,12 +6171,12 @@
DictScope Group(W, "Relocation");
W.printHex("Offset", R.Offset);
W.printNumber("Type", RelocName, R.Type);
- W.printNumber("Symbol", !TargetName.empty() ? TargetName : "-", R.Symbol);
+ W.printNumber("Symbol", !SymbolName.empty() ? SymbolName : "-", R.Symbol);
W.printHex("Addend", Addend);
} else {
raw_ostream &OS = W.startLine();
OS << W.hex(R.Offset) << " " << RelocName << " "
- << (!TargetName.empty() ? TargetName : "-") << " " << W.hex(Addend)
+ << (!SymbolName.empty() ? SymbolName : "-") << " " << W.hex(Addend)
<< "\n";
}
}
@@ -6362,24 +6368,9 @@
template <class ELFT>
void LLVMStyle<ELFT>::printDynamicReloc(const Relocation<ELFT> &R) {
- SmallString<32> RelocName;
- this->Obj.getRelocationTypeName(R.Type, RelocName);
- std::string SymbolName =
- getSymbolForReloc(this->Obj, this->FileName, this->dumper(), R).Name;
-
- uintX_t Addend = R.Addend.getValueOr(0);
- if (opts::ExpandRelocs) {
- DictScope Group(W, "Relocation");
- W.printHex("Offset", R.Offset);
- W.printNumber("Type", RelocName, R.Type);
- W.printString("Symbol", !SymbolName.empty() ? SymbolName : "-");
- W.printHex("Addend", Addend);
- } else {
- raw_ostream &OS = W.startLine();
- OS << W.hex(R.Offset) << " " << RelocName << " "
- << (!SymbolName.empty() ? SymbolName : "-") << " " << W.hex(Addend)
- << "\n";
- }
+ RelSymbol<ELFT> S =
+ getSymbolForReloc(this->Obj, this->FileName, this->dumper(), R);
+ printRelRelaReloc(R, S.Name);
}
template <class ELFT>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87089.290270.patch
Type: text/x-patch
Size: 2502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200907/9794513b/attachment.bin>
More information about the llvm-commits
mailing list