[llvm] e00e5d3 - [llvm-readelf/llvm-readobj] - Remove getSecTypeName() helper.
Georgii Rymar via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 4 23:59:17 PST 2019
Author: Georgii Rymar
Date: 2019-12-05T10:56:22+03:00
New Revision: e00e5d3347a37d0eda8429a32e3bee68f7bdf970
URL: https://github.com/llvm/llvm-project/commit/e00e5d3347a37d0eda8429a32e3bee68f7bdf970
DIFF: https://github.com/llvm/llvm-project/commit/e00e5d3347a37d0eda8429a32e3bee68f7bdf970.diff
LOG: [llvm-readelf/llvm-readobj] - Remove getSecTypeName() helper.
We do not need it, we have
`object::getELFSectionTypeName` that can be used instead.
Differential revision: https://reviews.llvm.org/D71017
Added:
Modified:
llvm/tools/llvm-readobj/ELFDumper.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 122bc45084ad..b95fbcb90469 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -344,16 +344,6 @@ template <typename ELFT> class ELFDumper : public ObjDumper {
getVersionDependencies(const Elf_Shdr *Sec) const;
};
-static StringRef getSecTypeName(unsigned Type) {
- if (Type == ELF::SHT_GNU_versym)
- return "SHT_GNU_versym";
- if (Type == ELF::SHT_GNU_verdef)
- return "SHT_GNU_verdef";
- if (Type == ELF::SHT_GNU_verneed)
- return "SHT_GNU_verneed";
- llvm_unreachable("unexpected section type");
-}
-
template <class ELFT>
static Expected<StringRef> getLinkAsStrtab(const ELFFile<ELFT> *Obj,
const typename ELFT::Shdr *Sec,
@@ -362,15 +352,17 @@ static Expected<StringRef> getLinkAsStrtab(const ELFFile<ELFT> *Obj,
Obj->getSection(Sec->sh_link);
if (!StrTabSecOrErr)
return createError("invalid section linked to " +
- getSecTypeName(Sec->sh_type) + " section with index " +
- Twine(SecNdx) + ": " +
+ object::getELFSectionTypeName(
+ Obj->getHeader()->e_machine, Sec->sh_type) +
+ " section with index " + Twine(SecNdx) + ": " +
toString(StrTabSecOrErr.takeError()));
Expected<StringRef> StrTabOrErr = Obj->getStringTable(*StrTabSecOrErr);
if (!StrTabOrErr)
return createError("invalid string table linked to " +
- getSecTypeName(Sec->sh_type) + " section with index " +
- Twine(SecNdx) + ": " +
+ object::getELFSectionTypeName(
+ Obj->getHeader()->e_machine, Sec->sh_type) +
+ " section with index " + Twine(SecNdx) + ": " +
toString(StrTabOrErr.takeError()));
return *StrTabOrErr;
}
@@ -3997,8 +3989,10 @@ void GNUStyle<ELFT>::printGNUVersionSectionProlog(
else
this->reportUniqueWarning(
createError("invalid section linked to " +
- getSecTypeName(Sec->sh_type) + " section with index " +
- Twine(SecNdx) + ": " + toString(SymTabOrErr.takeError())));
+ object::getELFSectionTypeName(Obj->getHeader()->e_machine,
+ Sec->sh_type) +
+ " section with index " + Twine(SecNdx) + ": " +
+ toString(SymTabOrErr.takeError())));
OS << " Addr: " << format_hex_no_prefix(Sec->sh_addr, 16)
<< " Offset: " << format_hex(Sec->sh_offset, 8)
More information about the llvm-commits
mailing list