summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/llvm-readobj/MachODumper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/llvm-readobj/MachODumper.cpp')
-rw-r--r--contrib/llvm/tools/llvm-readobj/MachODumper.cpp71
1 files changed, 29 insertions, 42 deletions
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)
OpenPOWER on IntegriCloud