summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/llvm-readobj
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/llvm-readobj')
-rw-r--r--contrib/llvm/tools/llvm-readobj/COFFDumper.cpp36
-rw-r--r--contrib/llvm/tools/llvm-readobj/ELFDumper.cpp266
-rw-r--r--contrib/llvm/tools/llvm-readobj/MachODumper.cpp71
-rw-r--r--contrib/llvm/tools/llvm-readobj/ObjDumper.h2
-rw-r--r--contrib/llvm/tools/llvm-readobj/StreamWriter.h14
-rw-r--r--contrib/llvm/tools/llvm-readobj/Win64EHDumper.cpp2
-rw-r--r--contrib/llvm/tools/llvm-readobj/llvm-readobj.cpp42
-rw-r--r--contrib/llvm/tools/llvm-readobj/llvm-readobj.h3
8 files changed, 347 insertions, 89 deletions
diff --git a/contrib/llvm/tools/llvm-readobj/COFFDumper.cpp b/contrib/llvm/tools/llvm-readobj/COFFDumper.cpp
index 156e39a..4a1d5da 100644
--- a/contrib/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/contrib/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -71,7 +71,7 @@ private:
void printBaseOfDataField(const pe32_header *Hdr);
void printBaseOfDataField(const pe32plus_header *Hdr);
- void printCodeViewLineTables(const SectionRef &Section);
+ void printCodeViewDebugInfo(const SectionRef &Section);
void printCodeViewSymbolsSubsection(StringRef Subsection,
const SectionRef &Section,
@@ -142,7 +142,7 @@ std::error_code COFFDumper::resolveSymbolName(const coff_section *Section,
return EC;
if (std::error_code EC = Symbol.getName(Name))
return EC;
- return object_error::success;
+ return std::error_code();
}
static const EnumEntry<COFF::MachineTypes> ImageFileMachineType[] = {
@@ -469,7 +469,7 @@ void COFFDumper::printBaseOfDataField(const pe32_header *Hdr) {
void COFFDumper::printBaseOfDataField(const pe32plus_header *) {}
-void COFFDumper::printCodeViewLineTables(const SectionRef &Section) {
+void COFFDumper::printCodeViewDebugInfo(const SectionRef &Section) {
StringRef Data;
if (error(Section.getContents(Data)))
return;
@@ -477,7 +477,7 @@ void COFFDumper::printCodeViewLineTables(const SectionRef &Section) {
SmallVector<StringRef, 10> FunctionNames;
StringMap<StringRef> FunctionLineTables;
- ListScope D(W, "CodeViewLineTables");
+ ListScope D(W, "CodeViewDebugInfo");
{
// FIXME: Add more offset correctness checks.
DataExtractor DE(Data, true, 4);
@@ -503,14 +503,17 @@ void COFFDumper::printCodeViewLineTables(const SectionRef &Section) {
return;
}
- // Print the raw contents to simplify debugging if anything goes wrong
- // afterwards.
StringRef Contents = Data.substr(Offset, PayloadSize);
- W.printBinaryBlock("Contents", Contents);
+ if (opts::CodeViewSubsectionBytes) {
+ // Print the raw contents to simplify debugging if anything goes wrong
+ // afterwards.
+ W.printBinaryBlock("Contents", Contents);
+ }
switch (SubSectionType) {
case COFF::DEBUG_SYMBOL_SUBSECTION:
- printCodeViewSymbolsSubsection(Contents, Section, Offset);
+ if (opts::SectionSymbols)
+ printCodeViewSymbolsSubsection(Contents, Section, Offset);
break;
case COFF::DEBUG_LINE_TABLE_SUBSECTION: {
// Holds a PC to file:line table. Some data to parse this subsection is
@@ -695,10 +698,20 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
InFunctionScope = false;
break;
}
- default:
+ default: {
+ if (opts::CodeViewSubsectionBytes) {
+ ListScope S(W, "Record");
+ W.printHex("Size", Size);
+ W.printHex("Type", Type);
+
+ StringRef Contents = DE.getData().substr(Offset, Size);
+ W.printBinaryBlock("Contents", Contents);
+ }
+
Offset += Size;
break;
}
+ }
}
if (InFunctionScope)
@@ -747,8 +760,8 @@ void COFFDumper::printSections() {
}
}
- if (Name == ".debug$S" && opts::CodeViewLineTables)
- printCodeViewLineTables(Sec);
+ if (Name == ".debug$S" && opts::CodeView)
+ printCodeViewDebugInfo(Sec);
if (opts::SectionData &&
!(Section->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)) {
@@ -1107,6 +1120,7 @@ static StringRef getBaseRelocTypeName(uint8_t Type) {
case COFF::IMAGE_REL_BASED_LOW: return "LOW";
case COFF::IMAGE_REL_BASED_HIGHLOW: return "HIGHLOW";
case COFF::IMAGE_REL_BASED_HIGHADJ: return "HIGHADJ";
+ case COFF::IMAGE_REL_BASED_ARM_MOV32T: return "ARM_MOV32(T)";
case COFF::IMAGE_REL_BASED_DIR64: return "DIR64";
default: return "unknown (" + llvm::utostr(Type) + ")";
}
diff --git a/contrib/llvm/tools/llvm-readobj/ELFDumper.cpp b/contrib/llvm/tools/llvm-readobj/ELFDumper.cpp
index d68c786..99969fd 100644
--- a/contrib/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/contrib/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -26,6 +26,7 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/MipsABIFlags.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
@@ -56,6 +57,8 @@ public:
void printAttributes() override;
void printMipsPLTGOT() override;
+ void printMipsABIFlags() override;
+ void printMipsReginfo() override;
private:
typedef ELFFile<ELFT> ELFO;
@@ -139,19 +142,19 @@ static void
getSectionNameIndex(const ELFO &Obj, typename ELFO::Elf_Sym_Iter Symbol,
StringRef &SectionName, unsigned &SectionIndex) {
SectionIndex = Symbol->st_shndx;
- if (SectionIndex == SHN_UNDEF) {
+ if (Symbol->isUndefined())
SectionName = "Undefined";
- } else if (SectionIndex >= SHN_LOPROC && SectionIndex <= SHN_HIPROC) {
+ else if (Symbol->isProcessorSpecific())
SectionName = "Processor Specific";
- } else if (SectionIndex >= SHN_LOOS && SectionIndex <= SHN_HIOS) {
+ else if (Symbol->isOSSpecific())
SectionName = "Operating System Specific";
- } else if (SectionIndex > SHN_HIOS && SectionIndex < SHN_ABS) {
- SectionName = "Reserved";
- } else if (SectionIndex == SHN_ABS) {
+ else if (Symbol->isAbsolute())
SectionName = "Absolute";
- } else if (SectionIndex == SHN_COMMON) {
+ else if (Symbol->isCommon())
SectionName = "Common";
- } else {
+ else if (Symbol->isReserved() && SectionIndex != SHN_XINDEX)
+ SectionName = "Reserved";
+ else {
if (SectionIndex == SHN_XINDEX)
SectionIndex = Obj.getSymbolTableIndex(&*Symbol);
assert(SectionIndex != SHN_XINDEX &&
@@ -170,6 +173,16 @@ findSectionByAddress(const ELFFile<ELFT> *Obj, uint64_t Addr) {
return nullptr;
}
+template <class ELFT>
+static const typename ELFFile<ELFT>::Elf_Shdr *
+findSectionByName(const ELFFile<ELFT> &Obj, StringRef Name) {
+ for (const auto &Shdr : Obj.sections()) {
+ if (Name == errorOrDefault(Obj.getSectionName(&Shdr)))
+ return &Shdr;
+ }
+ return nullptr;
+}
+
static const EnumEntry<unsigned> ElfClass[] = {
{ "None", ELF::ELFCLASSNONE },
{ "32-bit", ELF::ELFCLASS32 },
@@ -207,6 +220,7 @@ static const EnumEntry<unsigned> ElfOSABI[] = {
{ "NSK", ELF::ELFOSABI_NSK },
{ "AROS", ELF::ELFOSABI_AROS },
{ "FenixOS", ELF::ELFOSABI_FENIXOS },
+ { "CloudABI", ELF::ELFOSABI_CLOUDABI },
{ "C6000_ELFABI", ELF::ELFOSABI_C6000_ELFABI },
{ "C6000_LINUX" , ELF::ELFOSABI_C6000_LINUX },
{ "ARM", ELF::ELFOSABI_ARM },
@@ -220,7 +234,7 @@ static const EnumEntry<unsigned> ElfMachineType[] = {
LLVM_READOBJ_ENUM_ENT(ELF, EM_386 ),
LLVM_READOBJ_ENUM_ENT(ELF, EM_68K ),
LLVM_READOBJ_ENUM_ENT(ELF, EM_88K ),
- LLVM_READOBJ_ENUM_ENT(ELF, EM_486 ),
+ LLVM_READOBJ_ENUM_ENT(ELF, EM_IAMCU ),
LLVM_READOBJ_ENUM_ENT(ELF, EM_860 ),
LLVM_READOBJ_ENUM_ENT(ELF, EM_MIPS ),
LLVM_READOBJ_ENUM_ENT(ELF, EM_S370 ),
@@ -372,9 +386,10 @@ static const EnumEntry<unsigned> ElfMachineType[] = {
};
static const EnumEntry<unsigned> ElfSymbolBindings[] = {
- { "Local", ELF::STB_LOCAL },
- { "Global", ELF::STB_GLOBAL },
- { "Weak", ELF::STB_WEAK }
+ { "Local", ELF::STB_LOCAL },
+ { "Global", ELF::STB_GLOBAL },
+ { "Weak", ELF::STB_WEAK },
+ { "Unique", ELF::STB_GNU_UNIQUE }
};
static const EnumEntry<unsigned> ElfSymbolTypes[] = {
@@ -469,6 +484,7 @@ static const char *getElfSegmentType(unsigned Arch, unsigned Type) {
LLVM_READOBJ_ENUM_CASE(ELF, PT_MIPS_REGINFO);
LLVM_READOBJ_ENUM_CASE(ELF, PT_MIPS_RTPROC);
LLVM_READOBJ_ENUM_CASE(ELF, PT_MIPS_OPTIONS);
+ LLVM_READOBJ_ENUM_CASE(ELF, PT_MIPS_ABIFLAGS);
}
}
@@ -503,10 +519,33 @@ static const EnumEntry<unsigned> ElfHeaderMipsFlags[] = {
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_CPIC),
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ABI2),
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_32BITMODE),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_FP64),
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_NAN2008),
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ABI_O32),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ABI_O64),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ABI_EABI32),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ABI_EABI64),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_3900),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_4010),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_4100),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_4650),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_4120),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_4111),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_SB1),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_OCTEON),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_XLR),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_OCTEON2),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_OCTEON3),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_5400),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_5900),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_5500),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_9000),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_LS2E),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_LS2F),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MACH_LS3A),
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MICROMIPS),
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_ASE_M16),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_ASE_MDMX),
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_1),
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_2),
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_3),
@@ -549,7 +588,8 @@ void ELFDumper<ELFT>::printFileHeaders() {
W.printHex ("SectionHeaderOffset", Header->e_shoff);
if (Header->e_machine == EM_MIPS)
W.printFlags("Flags", Header->e_flags, makeArrayRef(ElfHeaderMipsFlags),
- unsigned(ELF::EF_MIPS_ARCH));
+ unsigned(ELF::EF_MIPS_ARCH), unsigned(ELF::EF_MIPS_ABI),
+ unsigned(ELF::EF_MIPS_MACH));
else
W.printFlags("Flags", Header->e_flags);
W.printNumber("HeaderSize", Header->e_ehsize);
@@ -666,26 +706,30 @@ void ELFDumper<ELFT>::printRelocation(const Elf_Shdr *Sec,
typename ELFO::Elf_Rela Rel) {
SmallString<32> RelocName;
Obj->getRelocationTypeName(Rel.getType(Obj->isMips64EL()), RelocName);
- StringRef SymbolName;
+ StringRef TargetName;
std::pair<const Elf_Shdr *, const Elf_Sym *> Sym =
Obj->getRelocationSymbol(Sec, &Rel);
- if (Sym.first)
- SymbolName = errorOrDefault(Obj->getSymbolName(Sym.first, Sym.second));
+ if (Sym.second && Sym.second->getType() == ELF::STT_SECTION) {
+ const Elf_Shdr *Sec = Obj->getSection(Sym.second);
+ ErrorOr<StringRef> SecName = Obj->getSectionName(Sec);
+ if (SecName)
+ TargetName = SecName.get();
+ } else if (Sym.first) {
+ TargetName = errorOrDefault(Obj->getSymbolName(Sym.first, Sym.second));
+ }
if (opts::ExpandRelocs) {
DictScope Group(W, "Relocation");
W.printHex("Offset", Rel.r_offset);
W.printNumber("Type", RelocName, (int)Rel.getType(Obj->isMips64EL()));
- W.printNumber("Symbol", SymbolName.size() > 0 ? SymbolName : "-",
+ W.printNumber("Symbol", TargetName.size() > 0 ? TargetName : "-",
Rel.getSymbol(Obj->isMips64EL()));
W.printHex("Addend", Rel.r_addend);
} else {
raw_ostream& OS = W.startLine();
- OS << W.hex(Rel.r_offset)
- << " " << RelocName
- << " " << (SymbolName.size() > 0 ? SymbolName : "-")
- << " " << W.hex(Rel.r_addend)
- << "\n";
+ OS << W.hex(Rel.r_offset) << " " << RelocName << " "
+ << (TargetName.size() > 0 ? TargetName : "-") << " "
+ << W.hex(Rel.r_addend) << "\n";
}
}
@@ -739,6 +783,7 @@ static const char *getTypeString(uint64_t Type) {
LLVM_READOBJ_TYPE_CASE(FINI_ARRAY);
LLVM_READOBJ_TYPE_CASE(FINI_ARRAYSZ);
LLVM_READOBJ_TYPE_CASE(FLAGS);
+ LLVM_READOBJ_TYPE_CASE(FLAGS_1);
LLVM_READOBJ_TYPE_CASE(HASH);
LLVM_READOBJ_TYPE_CASE(INIT);
LLVM_READOBJ_TYPE_CASE(INIT_ARRAY);
@@ -780,6 +825,7 @@ static const char *getTypeString(uint64_t Type) {
LLVM_READOBJ_TYPE_CASE(MIPS_GOTSYM);
LLVM_READOBJ_TYPE_CASE(MIPS_RLD_MAP);
LLVM_READOBJ_TYPE_CASE(MIPS_PLTGOT);
+ LLVM_READOBJ_TYPE_CASE(MIPS_OPTIONS);
default: return "unknown";
}
}
@@ -797,6 +843,34 @@ static const EnumEntry<unsigned> ElfDynamicDTFlags[] = {
LLVM_READOBJ_DT_FLAG_ENT(DF, STATIC_TLS)
};
+static const EnumEntry<unsigned> ElfDynamicDTFlags1[] = {
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, NOW),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, GLOBAL),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, GROUP),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, NODELETE),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, LOADFLTR),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, INITFIRST),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, NOOPEN),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, ORIGIN),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, DIRECT),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, TRANS),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, INTERPOSE),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, NODEFLIB),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, NODUMP),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, CONFALT),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, ENDFILTEE),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, DISPRELDNE),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, NODIRECT),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, IGNMULDEF),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, NOKSYMS),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, NOHDR),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, EDITED),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, NORELOC),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, SYMINTPOSE),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, GLOBAUDIT),
+ LLVM_READOBJ_DT_FLAG_ENT(DF_1, SINGLETON)
+};
+
static const EnumEntry<unsigned> ElfDynamicDTMipsFlags[] = {
LLVM_READOBJ_DT_FLAG_ENT(RHF, NONE),
LLVM_READOBJ_DT_FLAG_ENT(RHF, QUICKSTART),
@@ -871,6 +945,7 @@ static void printValue(const ELFFile<ELFT> *O, uint64_t Type, uint64_t Value,
case DT_MIPS_GOTSYM:
case DT_MIPS_RLD_MAP:
case DT_MIPS_PLTGOT:
+ case DT_MIPS_OPTIONS:
OS << format("0x%" PRIX64, Value);
break;
case DT_RELCOUNT:
@@ -909,6 +984,9 @@ static void printValue(const ELFFile<ELFT> *O, uint64_t Type, uint64_t Value,
case DT_FLAGS:
printFlags(Value, makeArrayRef(ElfDynamicDTFlags), OS);
break;
+ case DT_FLAGS_1:
+ printFlags(Value, makeArrayRef(ElfDynamicDTFlags1), OS);
+ break;
}
}
@@ -918,11 +996,10 @@ void ELFDumper<ELFT>::printUnwindInfo() {
}
namespace {
-template <>
-void ELFDumper<ELFType<support::little, 2, false> >::printUnwindInfo() {
+template <> void ELFDumper<ELFType<support::little, false>>::printUnwindInfo() {
const unsigned Machine = Obj->getHeader()->e_machine;
if (Machine == EM_ARM) {
- ARM::EHABI::PrinterContext<ELFType<support::little, 2, false> > Ctx(W, Obj);
+ ARM::EHABI::PrinterContext<ELFType<support::little, false>> Ctx(W, Obj);
return Ctx.PrintUnwindInformation();
}
W.startLine() << "UnwindInfo not implemented.\n";
@@ -1002,8 +1079,7 @@ void ELFDumper<ELFT>::printAttributes() {
}
namespace {
-template <>
-void ELFDumper<ELFType<support::little, 2, false> >::printAttributes() {
+template <> void ELFDumper<ELFType<support::little, false>>::printAttributes() {
if (Obj->getHeader()->e_machine != EM_ARM) {
W.startLine() << "Attributes not implemented.\n";
return;
@@ -1240,3 +1316,139 @@ template <class ELFT> void ELFDumper<ELFT>::printMipsPLTGOT() {
MipsGOTParser<ELFT>(Obj, W).parseGOT(*GotShdr);
}
+
+static const EnumEntry<unsigned> ElfMipsISAExtType[] = {
+ {"None", Mips::AFL_EXT_NONE},
+ {"Broadcom SB-1", Mips::AFL_EXT_SB1},
+ {"Cavium Networks Octeon", Mips::AFL_EXT_OCTEON},
+ {"Cavium Networks Octeon2", Mips::AFL_EXT_OCTEON2},
+ {"Cavium Networks OcteonP", Mips::AFL_EXT_OCTEONP},
+ {"Cavium Networks Octeon3", Mips::AFL_EXT_OCTEON3},
+ {"LSI R4010", Mips::AFL_EXT_4010},
+ {"Loongson 2E", Mips::AFL_EXT_LOONGSON_2E},
+ {"Loongson 2F", Mips::AFL_EXT_LOONGSON_2F},
+ {"Loongson 3A", Mips::AFL_EXT_LOONGSON_3A},
+ {"MIPS R4650", Mips::AFL_EXT_4650},
+ {"MIPS R5900", Mips::AFL_EXT_5900},
+ {"MIPS R10000", Mips::AFL_EXT_10000},
+ {"NEC VR4100", Mips::AFL_EXT_4100},
+ {"NEC VR4111/VR4181", Mips::AFL_EXT_4111},
+ {"NEC VR4120", Mips::AFL_EXT_4120},
+ {"NEC VR5400", Mips::AFL_EXT_5400},
+ {"NEC VR5500", Mips::AFL_EXT_5500},
+ {"RMI Xlr", Mips::AFL_EXT_XLR},
+ {"Toshiba R3900", Mips::AFL_EXT_3900}
+};
+
+static const EnumEntry<unsigned> ElfMipsASEFlags[] = {
+ {"DSP", Mips::AFL_ASE_DSP},
+ {"DSPR2", Mips::AFL_ASE_DSPR2},
+ {"Enhanced VA Scheme", Mips::AFL_ASE_EVA},
+ {"MCU", Mips::AFL_ASE_MCU},
+ {"MDMX", Mips::AFL_ASE_MDMX},
+ {"MIPS-3D", Mips::AFL_ASE_MIPS3D},
+ {"MT", Mips::AFL_ASE_MT},
+ {"SmartMIPS", Mips::AFL_ASE_SMARTMIPS},
+ {"VZ", Mips::AFL_ASE_VIRT},
+ {"MSA", Mips::AFL_ASE_MSA},
+ {"MIPS16", Mips::AFL_ASE_MIPS16},
+ {"microMIPS", Mips::AFL_ASE_MICROMIPS},
+ {"XPA", Mips::AFL_ASE_XPA}
+};
+
+static const EnumEntry<unsigned> ElfMipsFpABIType[] = {
+ {"Hard or soft float", Mips::Val_GNU_MIPS_ABI_FP_ANY},
+ {"Hard float (double precision)", Mips::Val_GNU_MIPS_ABI_FP_DOUBLE},
+ {"Hard float (single precision)", Mips::Val_GNU_MIPS_ABI_FP_SINGLE},
+ {"Soft float", Mips::Val_GNU_MIPS_ABI_FP_SOFT},
+ {"Hard float (MIPS32r2 64-bit FPU 12 callee-saved)",
+ Mips::Val_GNU_MIPS_ABI_FP_OLD_64},
+ {"Hard float (32-bit CPU, Any FPU)", Mips::Val_GNU_MIPS_ABI_FP_XX},
+ {"Hard float (32-bit CPU, 64-bit FPU)", Mips::Val_GNU_MIPS_ABI_FP_64},
+ {"Hard float compat (32-bit CPU, 64-bit FPU)",
+ Mips::Val_GNU_MIPS_ABI_FP_64A}
+};
+
+static const EnumEntry<unsigned> ElfMipsFlags1[] {
+ {"ODDSPREG", Mips::AFL_FLAGS1_ODDSPREG},
+};
+
+static int getMipsRegisterSize(uint8_t Flag) {
+ switch (Flag) {
+ case Mips::AFL_REG_NONE:
+ return 0;
+ case Mips::AFL_REG_32:
+ return 32;
+ case Mips::AFL_REG_64:
+ return 64;
+ case Mips::AFL_REG_128:
+ return 128;
+ default:
+ return -1;
+ }
+}
+
+template <class ELFT> void ELFDumper<ELFT>::printMipsABIFlags() {
+ const Elf_Shdr *Shdr = findSectionByName(*Obj, ".MIPS.abiflags");
+ if (!Shdr) {
+ W.startLine() << "There is no .MIPS.abiflags section in the file.\n";
+ return;
+ }
+ ErrorOr<ArrayRef<uint8_t>> Sec = Obj->getSectionContents(Shdr);
+ if (!Sec) {
+ W.startLine() << "The .MIPS.abiflags section is empty.\n";
+ return;
+ }
+ if (Sec->size() != sizeof(Elf_Mips_ABIFlags<ELFT>)) {
+ W.startLine() << "The .MIPS.abiflags section has a wrong size.\n";
+ return;
+ }
+
+ auto *Flags = reinterpret_cast<const Elf_Mips_ABIFlags<ELFT> *>(Sec->data());
+
+ raw_ostream &OS = W.getOStream();
+ DictScope GS(W, "MIPS ABI Flags");
+
+ W.printNumber("Version", Flags->version);
+ W.startLine() << "ISA: ";
+ if (Flags->isa_rev <= 1)
+ OS << format("MIPS%u", Flags->isa_level);
+ else
+ OS << format("MIPS%ur%u", Flags->isa_level, Flags->isa_rev);
+ OS << "\n";
+ W.printEnum("ISA Extension", Flags->isa_ext, makeArrayRef(ElfMipsISAExtType));
+ W.printFlags("ASEs", Flags->ases, makeArrayRef(ElfMipsASEFlags));
+ W.printEnum("FP ABI", Flags->fp_abi, makeArrayRef(ElfMipsFpABIType));
+ W.printNumber("GPR size", getMipsRegisterSize(Flags->gpr_size));
+ W.printNumber("CPR1 size", getMipsRegisterSize(Flags->cpr1_size));
+ W.printNumber("CPR2 size", getMipsRegisterSize(Flags->cpr2_size));
+ W.printFlags("Flags 1", Flags->flags1, makeArrayRef(ElfMipsFlags1));
+ W.printHex("Flags 2", Flags->flags2);
+}
+
+template <class ELFT> void ELFDumper<ELFT>::printMipsReginfo() {
+ const Elf_Shdr *Shdr = findSectionByName(*Obj, ".reginfo");
+ if (!Shdr) {
+ W.startLine() << "There is no .reginfo section in the file.\n";
+ return;
+ }
+ ErrorOr<ArrayRef<uint8_t>> Sec = Obj->getSectionContents(Shdr);
+ if (!Sec) {
+ W.startLine() << "The .reginfo section is empty.\n";
+ return;
+ }
+ if (Sec->size() != sizeof(Elf_Mips_RegInfo<ELFT>)) {
+ W.startLine() << "The .reginfo section has a wrong size.\n";
+ return;
+ }
+
+ auto *Reginfo = reinterpret_cast<const Elf_Mips_RegInfo<ELFT> *>(Sec->data());
+
+ DictScope GS(W, "MIPS RegInfo");
+ W.printHex("GP", Reginfo->ri_gp_value);
+ W.printHex("General Mask", Reginfo->ri_gprmask);
+ W.printHex("Co-Proc Mask0", Reginfo->ri_cprmask[0]);
+ W.printHex("Co-Proc Mask1", Reginfo->ri_cprmask[1]);
+ W.printHex("Co-Proc Mask2", Reginfo->ri_cprmask[2]);
+ W.printHex("Co-Proc Mask3", Reginfo->ri_cprmask[3]);
+}
diff --git a/contrib/llvm/tools/llvm-readobj/MachODumper.cpp b/contrib/llvm/tools/llvm-readobj/MachODumper.cpp
index 7e8fdad..aeb563a 100644
--- a/contrib/llvm/tools/llvm-readobj/MachODumper.cpp
+++ b/contrib/llvm/tools/llvm-readobj/MachODumper.cpp
@@ -203,31 +203,6 @@ static const EnumEntry<uint32_t> MachOHeaderFlags[] = {
LLVM_READOBJ_ENUM_ENT(MachO, MH_APP_EXTENSION_SAFE),
};
-static const EnumEntry<unsigned> MachOSectionTypes[] = {
- { "Regular" , 0x00 },
- { "ZeroFill" , 0x01 },
- { "CStringLiterals" , 0x02 },
- { "4ByteLiterals" , 0x03 },
- { "8ByteLiterals" , 0x04 },
- { "LiteralPointers" , 0x05 },
- { "NonLazySymbolPointers" , 0x06 },
- { "LazySymbolPointers" , 0x07 },
- { "SymbolStubs" , 0x08 },
- { "ModInitFuncs" , 0x09 },
- { "ModTermFuncs" , 0x0A },
- { "Coalesced" , 0x0B },
- { "GBZeroFill" , 0x0C },
- { "Interposing" , 0x0D },
- { "16ByteLiterals" , 0x0E },
- { "DTraceDOF" , 0x0F },
- { "LazyDylibSymbolPoints" , 0x10 },
- { "ThreadLocalRegular" , 0x11 },
- { "ThreadLocalZerofill" , 0x12 },
- { "ThreadLocalVariables" , 0x13 },
- { "ThreadLocalVariablePointers" , 0x14 },
- { "ThreadLocalInitFunctionPointers", 0x15 }
-};
-
static const EnumEntry<unsigned> MachOSectionAttributes[] = {
{ "LocReloc" , 1 << 0 /*S_ATTR_LOC_RELOC */ },
{ "ExtReloc" , 1 << 1 /*S_ATTR_EXT_RELOC */ },
@@ -494,35 +469,47 @@ void MachODumper::printRelocation(const MachOObjectFile *Obj,
DataRefImpl DR = Reloc.getRawDataRefImpl();
MachO::any_relocation_info RE = Obj->getRelocation(DR);
bool IsScattered = Obj->isRelocationScattered(RE);
- SmallString<32> SymbolNameOrOffset("0x");
- if (IsScattered) {
- // Scattered relocations don't really have an associated symbol
- // for some reason, even if one exists in the symtab at the correct address.
- SymbolNameOrOffset += utohexstr(Obj->getScatteredRelocationValue(RE));
- } else {
+ bool IsExtern = !IsScattered && Obj->getPlainRelocationExternal(RE);
+
+ StringRef TargetName;
+ if (IsExtern) {
symbol_iterator Symbol = Reloc.getSymbol();
if (Symbol != Obj->symbol_end()) {
- StringRef SymbolName;
- if (error(Symbol->getName(SymbolName)))
+ if (error(Symbol->getName(TargetName)))
+ return;
+ }
+ } else if (!IsScattered) {
+ section_iterator SecI = Obj->getRelocationSection(DR);
+ if (SecI != Obj->section_end()) {
+ if (error(SecI->getName(TargetName)))
return;
- SymbolNameOrOffset = SymbolName;
- } else
- SymbolNameOrOffset += utohexstr(Obj->getPlainRelocationSymbolNum(RE));
+ }
}
+ if (TargetName.empty())
+ TargetName = "-";
if (opts::ExpandRelocs) {
DictScope Group(W, "Relocation");
W.printHex("Offset", Offset);
W.printNumber("PCRel", Obj->getAnyRelocationPCRel(RE));
W.printNumber("Length", Obj->getAnyRelocationLength(RE));
- if (IsScattered)
- W.printString("Extern", StringRef("N/A"));
- else
- W.printNumber("Extern", Obj->getPlainRelocationExternal(RE));
W.printNumber("Type", RelocName, Obj->getAnyRelocationType(RE));
- W.printString("Symbol", SymbolNameOrOffset);
- W.printNumber("Scattered", IsScattered);
+ if (IsScattered) {
+ W.printHex("Value", Obj->getScatteredRelocationValue(RE));
+ } else {
+ const char *Kind = IsExtern ? "Symbol" : "Section";
+ W.printNumber(Kind, TargetName, Obj->getPlainRelocationSymbolNum(RE));
+ }
} else {
+ SmallString<32> SymbolNameOrOffset("0x");
+ if (IsScattered) {
+ // Scattered relocations don't really have an associated symbol for some
+ // reason, even if one exists in the symtab at the correct address.
+ SymbolNameOrOffset += utohexstr(Obj->getScatteredRelocationValue(RE));
+ } else {
+ SymbolNameOrOffset = TargetName;
+ }
+
raw_ostream& OS = W.startLine();
OS << W.hex(Offset)
<< " " << Obj->getAnyRelocationPCRel(RE)
diff --git a/contrib/llvm/tools/llvm-readobj/ObjDumper.h b/contrib/llvm/tools/llvm-readobj/ObjDumper.h
index 27e658f..323f5e3 100644
--- a/contrib/llvm/tools/llvm-readobj/ObjDumper.h
+++ b/contrib/llvm/tools/llvm-readobj/ObjDumper.h
@@ -42,6 +42,8 @@ public:
// Only implemented for MIPS ELF at this time.
virtual void printMipsPLTGOT() { }
+ virtual void printMipsABIFlags() { }
+ virtual void printMipsReginfo() { }
// Only implemented for PE/COFF.
virtual void printCOFFImports() { }
diff --git a/contrib/llvm/tools/llvm-readobj/StreamWriter.h b/contrib/llvm/tools/llvm-readobj/StreamWriter.h
index 2fc53ee..245588b 100644
--- a/contrib/llvm/tools/llvm-readobj/StreamWriter.h
+++ b/contrib/llvm/tools/llvm-readobj/StreamWriter.h
@@ -96,9 +96,10 @@ public:
}
}
- template<typename T, typename TFlag>
- void printFlags(StringRef Label, T Value, ArrayRef<EnumEntry<TFlag> > Flags,
- TFlag EnumMask = TFlag(0)) {
+ template <typename T, typename TFlag>
+ void printFlags(StringRef Label, T Value, ArrayRef<EnumEntry<TFlag>> Flags,
+ TFlag EnumMask1 = {}, TFlag EnumMask2 = {},
+ TFlag EnumMask3 = {}) {
typedef EnumEntry<TFlag> FlagEntry;
typedef SmallVector<FlagEntry, 10> FlagVector;
FlagVector SetFlags;
@@ -107,6 +108,13 @@ public:
if (Flag.Value == 0)
continue;
+ TFlag EnumMask{};
+ if (Flag.Value & EnumMask1)
+ EnumMask = EnumMask1;
+ else if (Flag.Value & EnumMask2)
+ EnumMask = EnumMask2;
+ else if (Flag.Value & EnumMask3)
+ EnumMask = EnumMask3;
bool IsEnum = (Flag.Value & EnumMask) != 0;
if ((!IsEnum && (Value & Flag.Value) == Flag.Value) ||
(IsEnum && (Value & EnumMask) == Flag.Value)) {
diff --git a/contrib/llvm/tools/llvm-readobj/Win64EHDumper.cpp b/contrib/llvm/tools/llvm-readobj/Win64EHDumper.cpp
index f058632..b148c5d 100644
--- a/contrib/llvm/tools/llvm-readobj/Win64EHDumper.cpp
+++ b/contrib/llvm/tools/llvm-readobj/Win64EHDumper.cpp
@@ -152,7 +152,7 @@ static std::error_code resolveRelocation(const Dumper::Context &Ctx,
return EC;
ResolvedSection = Ctx.COFF.getCOFFSection(*SI);
- return object_error::success;
+ return std::error_code();
}
namespace llvm {
diff --git a/contrib/llvm/tools/llvm-readobj/llvm-readobj.cpp b/contrib/llvm/tools/llvm-readobj/llvm-readobj.cpp
index f95fea8..f960796 100644
--- a/contrib/llvm/tools/llvm-readobj/llvm-readobj.cpp
+++ b/contrib/llvm/tools/llvm-readobj/llvm-readobj.cpp
@@ -25,6 +25,7 @@
#include "StreamWriter.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/MachOUniversal.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
@@ -127,9 +128,14 @@ namespace opts {
cl::opt<bool> ExpandRelocs("expand-relocs",
cl::desc("Expand each shown relocation to multiple lines"));
- // -codeview-linetables
- cl::opt<bool> CodeViewLineTables("codeview-linetables",
- cl::desc("Display CodeView line table information"));
+ // -codeview
+ cl::opt<bool> CodeView("codeview",
+ cl::desc("Display CodeView debug information"));
+
+ // -codeview-subsection-bytes
+ cl::opt<bool> CodeViewSubsectionBytes(
+ "codeview-subsection-bytes",
+ cl::desc("Dump raw contents of codeview debug sections and records"));
// -arm-attributes, -a
cl::opt<bool> ARMAttributes("arm-attributes",
@@ -142,6 +148,14 @@ namespace opts {
MipsPLTGOT("mips-plt-got",
cl::desc("Display the MIPS GOT and PLT GOT sections"));
+ // -mips-abi-flags
+ cl::opt<bool> MipsABIFlags("mips-abi-flags",
+ cl::desc("Display the MIPS.abiflags section"));
+
+ // -mips-reginfo
+ cl::opt<bool> MipsReginfo("mips-reginfo",
+ cl::desc("Display the MIPS .reginfo section"));
+
// -coff-imports
cl::opt<bool>
COFFImports("coff-imports", cl::desc("Display the PE/COFF import table"));
@@ -281,9 +295,14 @@ static void dumpObject(const ObjectFile *Obj) {
if (Obj->getArch() == llvm::Triple::arm && Obj->isELF())
if (opts::ARMAttributes)
Dumper->printAttributes();
- if (isMipsArch(Obj->getArch()) && Obj->isELF())
+ if (isMipsArch(Obj->getArch()) && Obj->isELF()) {
if (opts::MipsPLTGOT)
Dumper->printMipsPLTGOT();
+ if (opts::MipsABIFlags)
+ Dumper->printMipsABIFlags();
+ if (opts::MipsReginfo)
+ Dumper->printMipsReginfo();
+ }
if (opts::COFFImports)
Dumper->printCOFFImports();
if (opts::COFFExports)
@@ -315,6 +334,18 @@ static void dumpArchive(const Archive *Arc) {
}
}
+/// @brief Dumps each object file in \a MachO Universal Binary;
+static void dumpMachOUniversalBinary(const MachOUniversalBinary *UBinary) {
+ for (const MachOUniversalBinary::ObjectForArch &Obj : UBinary->objects()) {
+ ErrorOr<std::unique_ptr<MachOObjectFile>> ObjOrErr = Obj.getAsObjectFile();
+ if (ObjOrErr)
+ dumpObject(&*ObjOrErr.get());
+ else if (ErrorOr<std::unique_ptr<Archive>> AOrErr = Obj.getAsArchive())
+ dumpArchive(&*AOrErr.get());
+ else
+ reportError(UBinary->getFileName(), ObjOrErr.getError().message());
+ }
+}
/// @brief Opens \a File and dumps it.
static void dumpInput(StringRef File) {
@@ -334,6 +365,9 @@ static void dumpInput(StringRef File) {
if (Archive *Arc = dyn_cast<Archive>(&Binary))
dumpArchive(Arc);
+ else if (MachOUniversalBinary *UBinary =
+ dyn_cast<MachOUniversalBinary>(&Binary))
+ dumpMachOUniversalBinary(UBinary);
else if (ObjectFile *Obj = dyn_cast<ObjectFile>(&Binary))
dumpObject(Obj);
else
diff --git a/contrib/llvm/tools/llvm-readobj/llvm-readobj.h b/contrib/llvm/tools/llvm-readobj/llvm-readobj.h
index 1c33417..74b9a60 100644
--- a/contrib/llvm/tools/llvm-readobj/llvm-readobj.h
+++ b/contrib/llvm/tools/llvm-readobj/llvm-readobj.h
@@ -36,7 +36,8 @@ namespace opts {
extern llvm::cl::opt<bool> DynamicSymbols;
extern llvm::cl::opt<bool> UnwindInfo;
extern llvm::cl::opt<bool> ExpandRelocs;
- extern llvm::cl::opt<bool> CodeViewLineTables;
+ extern llvm::cl::opt<bool> CodeView;
+ extern llvm::cl::opt<bool> CodeViewSubsectionBytes;
extern llvm::cl::opt<bool> ARMAttributes;
extern llvm::cl::opt<bool> MipsPLTGOT;
} // namespace opts
OpenPOWER on IntegriCloud