aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm-readobj/llvm-readobj.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-04-03 14:07:16 +0000
committerAlexander Kornienko <alexfh@google.com>2013-04-03 14:07:16 +0000
commite133bc868944822bf8961f825d3aa63d6fa48fb7 (patch)
treeebbd4a8040181471467a9737d90d94dc6b58b316 /tools/llvm-readobj/llvm-readobj.cpp
parent647735c781c5b37061ee03d6e9e6c7dda92218e2 (diff)
parent080e3c523e87ec68ca1ea5db4cd49816028dd8bd (diff)
Updating branches/google/stable to r178511stable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/google/stable@178655 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-readobj/llvm-readobj.cpp')
-rw-r--r--tools/llvm-readobj/llvm-readobj.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/tools/llvm-readobj/llvm-readobj.cpp b/tools/llvm-readobj/llvm-readobj.cpp
index 8f0917fc91..ea37d105dc 100644
--- a/tools/llvm-readobj/llvm-readobj.cpp
+++ b/tools/llvm-readobj/llvm-readobj.cpp
@@ -39,13 +39,13 @@ static cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input object>"), cl::init(""));
static void dumpSymbolHeader() {
- outs() << format(" %-32s", (const char*)"Name")
- << format(" %-4s", (const char*)"Type")
- << format(" %-16s", (const char*)"Address")
- << format(" %-16s", (const char*)"Size")
- << format(" %-16s", (const char*)"FileOffset")
- << format(" %-26s", (const char*)"Flags")
- << "\n";
+ outs() << format(" %-32s", (const char *)"Name")
+ << format(" %-4s", (const char *)"Type")
+ << format(" %-4s", (const char *)"Section")
+ << format(" %-16s", (const char *)"Address")
+ << format(" %-16s", (const char *)"Size")
+ << format(" %-16s", (const char *)"FileOffset")
+ << format(" %-26s", (const char *)"Flags") << "\n";
}
static void dumpSectionHeader() {
@@ -145,6 +145,14 @@ dumpSymbol(const SymbolRef &Sym, const ObjectFile *obj, bool IsDynamic) {
checkError(Sym.getFlags(Flags), "SymbolRef.getFlags() failed");
std::string FullName = Name;
+ llvm::object::section_iterator symSection(obj->begin_sections());
+ Sym.getSection(symSection);
+ StringRef sectionName;
+
+ if (symSection != obj->end_sections())
+ checkError(symSection->getName(sectionName),
+ "SectionRef::getName() failed");
+
// If this is a dynamic symbol from an ELF object, append
// the symbol's version to the name.
if (IsDynamic && obj->isELF()) {
@@ -160,11 +168,10 @@ dumpSymbol(const SymbolRef &Sym, const ObjectFile *obj, bool IsDynamic) {
// format() can't handle StringRefs
outs() << format(" %-32s", FullName.c_str())
<< format(" %-4s", getTypeStr(Type))
- << format(" %16" PRIx64, Address)
- << format(" %16" PRIx64, Size)
- << format(" %16" PRIx64, FileOffset)
- << " " << getSymbolFlagStr(Flags)
- << "\n";
+ << format(" %-32s", std::string(sectionName).c_str())
+ << format(" %16" PRIx64, Address) << format(" %16" PRIx64, Size)
+ << format(" %16" PRIx64, FileOffset) << " "
+ << getSymbolFlagStr(Flags) << "\n";
}
static void dumpStaticSymbol(const SymbolRef &Sym, const ObjectFile *obj) {