aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvm-objdump
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llvm-objdump')
-rw-r--r--tools/llvm-objdump/LLVMBuild.txt22
-rw-r--r--tools/llvm-objdump/MachODump.cpp20
-rw-r--r--tools/llvm-objdump/llvm-objdump.cpp39
3 files changed, 58 insertions, 23 deletions
diff --git a/tools/llvm-objdump/LLVMBuild.txt b/tools/llvm-objdump/LLVMBuild.txt
new file mode 100644
index 0000000..d16c501
--- /dev/null
+++ b/tools/llvm-objdump/LLVMBuild.txt
@@ -0,0 +1,22 @@
+;===- ./tools/llvm-objdump/LLVMBuild.txt -----------------------*- Conf -*--===;
+;
+; The LLVM Compiler Infrastructure
+;
+; This file is distributed under the University of Illinois Open Source
+; License. See LICENSE.TXT for details.
+;
+;===------------------------------------------------------------------------===;
+;
+; This is an LLVMBuild description file for the components in this subdirectory.
+;
+; For more information on the LLVMBuild system, please see:
+;
+; http://llvm.org/docs/LLVMBuild.html
+;
+;===------------------------------------------------------------------------===;
+
+[component_0]
+type = Tool
+name = llvm-objdump
+parent = Tools
+required_libraries = DebugInfo MC MCDisassembler MCParser Object all-targets
diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp
index c61ec4c..ffeea88 100644
--- a/tools/llvm-objdump/MachODump.cpp
+++ b/tools/llvm-objdump/MachODump.cpp
@@ -385,7 +385,7 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
bool symbolTableWorked = false;
// Parse relocations.
- std::vector<std::pair<uint64_t, uint32_t> > Relocs;
+ std::vector<std::pair<uint64_t, SymbolRef> > Relocs;
error_code ec;
for (relocation_iterator RI = Sections[SectIdx].begin_relocations(),
RE = Sections[SectIdx].end_relocations(); RI != RE; RI.increment(ec)) {
@@ -394,10 +394,10 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
Sections[SectIdx].getAddress(SectionAddress);
RelocOffset -= SectionAddress;
- uint32_t RelocInfo;
- RI->getType(RelocInfo);
+ SymbolRef RelocSym;
+ RI->getSymbol(RelocSym);
- Relocs.push_back(std::make_pair(RelocOffset, RelocInfo));
+ Relocs.push_back(std::make_pair(RelocOffset, RelocSym));
}
array_pod_sort(Relocs.begin(), Relocs.end());
@@ -419,7 +419,7 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
// Start at the address of the symbol relative to the section's address.
uint64_t Start = 0;
- Symbols[SymIdx].getOffset(Start);
+ Symbols[SymIdx].getAddress(Start);
// Stop disassembling either at the beginning of the next symbol or at
// the end of the section.
@@ -432,7 +432,7 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
if (NextSymType == SymbolRef::ST_Function) {
Sections[SectIdx].containsSymbol(Symbols[NextSymIdx],
containsNextSym);
- Symbols[NextSymIdx].getOffset(NextSym);
+ Symbols[NextSymIdx].getAddress(NextSym);
break;
}
++NextSymIdx;
@@ -459,7 +459,7 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
DebugOut, nulls())) {
uint64_t SectAddress = 0;
Sections[SectIdx].getAddress(SectAddress);
- outs() << format("%8llx:\t", SectAddress + Index);
+ outs() << format("%8" PRIx64 ":\t", SectAddress + Index);
DumpBytes(StringRef(Bytes.data() + Index, Size));
IP->printInst(&Inst, outs(), "");
@@ -579,7 +579,7 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
outs() << FunctionMap[SectAddress + Inst.Address]-> getName()
<< ":\n";
- outs() << format("%8llx:\t", SectAddress + Inst.Address);
+ outs() << format("%8" PRIx64 ":\t", SectAddress + Inst.Address);
DumpBytes(StringRef(Bytes.data() + Inst.Address, Inst.Size));
if (fi->second.contains(fi->first)) // Indent simple loops.
@@ -594,8 +594,8 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
Relocs[j].first < SectAddress + Inst.Address + Inst.Size) {
StringRef SymName;
uint64_t Addr;
- UnsortedSymbols[Relocs[j].second].getName(SymName);
- UnsortedSymbols[Relocs[j].second].getAddress(Addr);
+ Relocs[j].second.getAddress(Addr);
+ Relocs[j].second.getName(SymName);
outs() << "\t# " << SymName << ' ';
DumpAddress(Addr, Sections, MachOObj, outs());
diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp
index 0b6bd22..bcfecb3 100644
--- a/tools/llvm-objdump/llvm-objdump.cpp
+++ b/tools/llvm-objdump/llvm-objdump.cpp
@@ -186,7 +186,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
bool contains;
if (!error(i->containsSymbol(*si, contains)) && contains) {
uint64_t Address;
- if (error(si->getOffset(Address))) break;
+ if (error(si->getAddress(Address))) break;
StringRef Name;
if (error(si->getName(Name))) break;
Symbols.push_back(std::make_pair(Address, Name));
@@ -289,7 +289,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
if (DisAsm->getInstruction(Inst, Size, memoryObject, Index,
DebugOut, nulls())) {
- outs() << format("%8x:\t", SectionAddr + Index);
+ outs() << format("%8"PRIx64":\t", SectionAddr + Index);
DumpBytes(StringRef(Bytes.data() + Index, Size));
IP->printInst(&Inst, outs(), "");
outs() << "\n";
@@ -301,16 +301,22 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
// Print relocation for instruction.
while (rel_cur != rel_end) {
+ bool hidden = false;
uint64_t addr;
SmallString<16> name;
SmallString<32> val;
+
+ // If this relocation is hidden, skip it.
+ if (error(rel_cur->getHidden(hidden))) goto skip_print_rel;
+ if (hidden) goto skip_print_rel;
+
if (error(rel_cur->getAddress(addr))) goto skip_print_rel;
// Stop when rel_cur's address is past the current instruction.
- if (addr > Index + Size) break;
+ if (addr >= Index + Size) break;
if (error(rel_cur->getTypeName(name))) goto skip_print_rel;
if (error(rel_cur->getValueString(val))) goto skip_print_rel;
- outs() << format("\t\t\t%8x: ", SectionAddr + addr) << name << "\t"
+ outs() << format("\t\t\t%8"PRIx64": ", SectionAddr + addr) << name << "\t"
<< val << "\n";
skip_print_rel:
@@ -336,9 +342,12 @@ static void PrintRelocations(const ObjectFile *o) {
ri != re; ri.increment(ec)) {
if (error(ec)) return;
+ bool hidden;
uint64_t address;
SmallString<32> relocname;
SmallString<32> valuestr;
+ if (error(ri->getHidden(hidden))) continue;
+ if (hidden) continue;
if (error(ri->getTypeName(relocname))) continue;
if (error(ri->getAddress(address))) continue;
if (error(ri->getValueString(valuestr))) continue;
@@ -391,7 +400,7 @@ static void PrintSectionContents(const ObjectFile *o) {
// Dump out the content as hex and printable ascii characters.
for (std::size_t addr = 0, end = Contents.size(); addr < end; addr += 16) {
- outs() << format(" %04x ", BaseAddr + addr);
+ outs() << format(" %04"PRIx64" ", BaseAddr + addr);
// Dump line of hex.
for (std::size_t i = 0; i < 16; ++i) {
if (i != 0 && i % 4 == 0)
@@ -468,7 +477,7 @@ static void PrintSymbolTable(const ObjectFile *o) {
se = o->end_symbols(); si != se; si.increment(ec)) {
if (error(ec)) return;
StringRef Name;
- uint64_t Offset;
+ uint64_t Address;
bool Global;
SymbolRef::Type Type;
bool Weak;
@@ -476,7 +485,7 @@ static void PrintSymbolTable(const ObjectFile *o) {
uint64_t Size;
section_iterator Section = o->end_sections();
if (error(si->getName(Name))) continue;
- if (error(si->getOffset(Offset))) continue;
+ if (error(si->getAddress(Address))) continue;
if (error(si->isGlobal(Global))) continue;
if (error(si->getType(Type))) continue;
if (error(si->isWeak(Weak))) continue;
@@ -484,8 +493,10 @@ static void PrintSymbolTable(const ObjectFile *o) {
if (error(si->getSize(Size))) continue;
if (error(si->getSection(Section))) continue;
- if (Offset == UnknownAddressOrSize)
- Offset = 0;
+ if (Address == UnknownAddressOrSize)
+ Address = 0;
+ if (Size == UnknownAddressOrSize)
+ Size = 0;
char GlobLoc = ' ';
if (Type != SymbolRef::ST_External)
GlobLoc = Global ? 'g' : 'l';
@@ -497,7 +508,7 @@ static void PrintSymbolTable(const ObjectFile *o) {
else if (Type == SymbolRef::ST_Function)
FileFunc = 'F';
- outs() << format("%08x", Offset) << " "
+ outs() << format("%08"PRIx64, Address) << " "
<< GlobLoc // Local -> 'l', Global -> 'g', Neither -> ' '
<< (Weak ? 'w' : ' ') // Weak?
<< ' ' // Constructor. Not supported yet.
@@ -517,7 +528,7 @@ static void PrintSymbolTable(const ObjectFile *o) {
outs() << SectionName;
}
outs() << '\t'
- << format("%08x ", Size)
+ << format("%08"PRIx64" ", Size)
<< Name
<< '\n';
}
@@ -547,8 +558,10 @@ static void DumpArchive(const Archive *a) {
e = a->end_children(); i != e; ++i) {
OwningPtr<Binary> child;
if (error_code ec = i->getAsBinary(child)) {
- errs() << ToolName << ": '" << a->getFileName() << "': " << ec.message()
- << ".\n";
+ // Ignore non-object files.
+ if (ec != object_error::invalid_file_type)
+ errs() << ToolName << ": '" << a->getFileName() << "': " << ec.message()
+ << ".\n";
continue;
}
if (ObjectFile *o = dyn_cast<ObjectFile>(child.get()))