[PATCH] D137092: [llvm-readobj] Use a helper to extract the Other Flags from symbols
Paul Kirth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 19 15:31:44 PST 2022
paulkirth updated this revision to Diff 484106.
paulkirth added a comment.
Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137092/new/
https://reviews.llvm.org/D137092
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
@@ -234,6 +234,9 @@
return 4;
}
+ std::vector<EnumEntry<unsigned>>
+ getOtherFlagsFromSymbol(const Elf_Ehdr &Header, const Elf_Sym &Symbol) const;
+
Elf_Dyn_Range dynamic_table() const {
// A valid .dynamic section contains an array of entries terminated
// with a DT_NULL entry. However, sometimes the section content may
@@ -3238,6 +3241,35 @@
printRelRelaReloc(R, *Target);
}
+template <class ELFT>
+std::vector<EnumEntry<unsigned>>
+ELFDumper<ELFT>::getOtherFlagsFromSymbol(const Elf_Ehdr &Header,
+ const Elf_Sym &Symbol) const {
+ std::vector<EnumEntry<unsigned>> SymOtherFlags(std::begin(ElfSymOtherFlags),
+ std::end(ElfSymOtherFlags));
+ if (Header.e_machine == EM_MIPS) {
+ // Someones in their infinite wisdom decided to make STO_MIPS_MIPS16
+ // flag overlapped with other ST_MIPS_xxx flags. So consider both
+ // cases separately.
+ if ((Symbol.st_other & STO_MIPS_MIPS16) == STO_MIPS_MIPS16)
+ SymOtherFlags.insert(SymOtherFlags.end(),
+ std::begin(ElfMips16SymOtherFlags),
+ std::end(ElfMips16SymOtherFlags));
+ else
+ SymOtherFlags.insert(SymOtherFlags.end(),
+ std::begin(ElfMipsSymOtherFlags),
+ std::end(ElfMipsSymOtherFlags));
+ } else if (Header.e_machine == EM_AARCH64) {
+ SymOtherFlags.insert(SymOtherFlags.end(),
+ std::begin(ElfAArch64SymOtherFlags),
+ std::end(ElfAArch64SymOtherFlags));
+ } else if (Header.e_machine == EM_RISCV) {
+ SymOtherFlags.insert(SymOtherFlags.end(), std::begin(ElfRISCVSymOtherFlags),
+ std::end(ElfRISCVSymOtherFlags));
+ }
+ return SymOtherFlags;
+}
+
static inline void printFields(formatted_raw_ostream &OS, StringRef Str1,
StringRef Str2) {
OS.PadToColumn(2u);
@@ -6797,29 +6829,8 @@
// by flags enumeration in that case.
W.printNumber("Other", 0);
else {
- std::vector<EnumEntry<unsigned>> SymOtherFlags(std::begin(ElfSymOtherFlags),
- std::end(ElfSymOtherFlags));
- if (this->Obj.getHeader().e_machine == EM_MIPS) {
- // Someones in their infinite wisdom decided to make STO_MIPS_MIPS16
- // flag overlapped with other ST_MIPS_xxx flags. So consider both
- // cases separately.
- if ((Symbol.st_other & STO_MIPS_MIPS16) == STO_MIPS_MIPS16)
- SymOtherFlags.insert(SymOtherFlags.end(),
- std::begin(ElfMips16SymOtherFlags),
- std::end(ElfMips16SymOtherFlags));
- else
- SymOtherFlags.insert(SymOtherFlags.end(),
- std::begin(ElfMipsSymOtherFlags),
- std::end(ElfMipsSymOtherFlags));
- } else if (this->Obj.getHeader().e_machine == EM_AARCH64) {
- SymOtherFlags.insert(SymOtherFlags.end(),
- std::begin(ElfAArch64SymOtherFlags),
- std::end(ElfAArch64SymOtherFlags));
- } else if (this->Obj.getHeader().e_machine == EM_RISCV) {
- SymOtherFlags.insert(SymOtherFlags.end(),
- std::begin(ElfRISCVSymOtherFlags),
- std::end(ElfRISCVSymOtherFlags));
- }
+ std::vector<EnumEntry<unsigned>> SymOtherFlags =
+ this->getOtherFlagsFromSymbol(this->Obj.getHeader(), Symbol);
W.printFlags("Other", Symbol.st_other, makeArrayRef(SymOtherFlags), 0x3u);
}
printSymbolSection(Symbol, SymIndex, ShndxTable);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137092.484106.patch
Type: text/x-patch
Size: 3879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221219/b5b03887/attachment.bin>
More information about the llvm-commits
mailing list