Print a header above the symbols. Extracted from a patch by Sami Liedes.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 31 Dec 2012 16:05:21 +0000 (16:05 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 31 Dec 2012 16:05:21 +0000 (16:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171302 91177308-0d34-0410-b5e6-96231b3b80d8

test/Object/readobj-shared-object.test
tools/llvm-readobj/llvm-readobj.cpp

index 3b5457ce073725a3d37ea3b31d58c734c2a94756..8d9b179002b4f74ba1b4f019d289ac3a46889a56 100644 (file)
@@ -19,6 +19,7 @@ ELF32:Address Size: 32 bits
 ELF32:Load Name   : libfoo.so
 
 ELF:Symbols:
+ELF:  Name                   Type            Address        Size           FileOffset     Flags
 ELF:  .dynsym                DBG             {{[0-9a-f]+}}  {{[0-9a-f]+}}  {{[0-9a-f]+}}  formatspecific
 ELF:  .dynstr                DBG             {{[0-9a-f]+}}  {{[0-9a-f]+}}  {{[0-9a-f]+}}  formatspecific
 ELF:  .text                  DBG             {{[0-9a-f]+}}  {{[0-9a-f]+}}  {{[0-9a-f]+}}  formatspecific
@@ -42,6 +43,7 @@ ELF:  _edata                 ?               {{[0-9a-f]+}}  {{[0-9a-f]+}}  {{[0-
 ELF:  Total: 21
 
 ELF:Dynamic Symbols:
+ELF:  Name                   Type            Address        Size           FileOffset     Flags
 ELF:  common_sym             DATA            {{[0-9a-f]+}}  {{[0-9a-f]+}}  {{[0-9a-f]+}}  global
 ELF:  tls_sym                DATA            {{[0-9a-f]+}}  {{[0-9a-f]+}}  {{[0-9a-f]+}}  global,threadlocal
 ELF:  defined_sym            DATA            {{[0-9a-f]+}}  {{[0-9a-f]+}}  {{[0-9a-f]+}}  global
index 8f8804a7c45812abddcba761a500177daba7f733..81d2bfb730b9a07abd3244c087684cbf3fd9752e 100644 (file)
@@ -33,6 +33,16 @@ using namespace llvm::object;
 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";
+}
+
 static const char *getTypeStr(SymbolRef::Type Type) {
   switch (Type) {
   case SymbolRef::ST_Unknown: return "?";
@@ -118,6 +128,7 @@ static void dumpSymbols(const ObjectFile *obj) {
   error_code ec;
   uint32_t count = 0;
   outs() << "Symbols:\n";
+  dumpSymbolHeader();
   symbol_iterator it = obj->begin_symbols();
   symbol_iterator ie = obj->end_symbols();
   while (it != ie) {
@@ -135,6 +146,7 @@ static void dumpDynamicSymbols(const ObjectFile *obj) {
   error_code ec;
   uint32_t count = 0;
   outs() << "Dynamic Symbols:\n";
+  dumpSymbolHeader();
   symbol_iterator it = obj->begin_dynamic_symbols();
   symbol_iterator ie = obj->end_dynamic_symbols();
   while (it != ie) {