Skip to content

Commit

Permalink
Fix the printing of n_type.
Browse files Browse the repository at this point in the history
Despite the name, n_type contains the type of the symbol, but also if it is
extern or private extern.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203154 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
espindola committed Mar 6, 2014
1 parent 7ed86b0 commit abb1fad
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
27 changes: 18 additions & 9 deletions test/tools/llvm-readobj/sections-ext.test
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ MACHO-I386-NEXT: ]
MACHO-I386-NEXT: Symbols [
MACHO-I386-NEXT: Symbol {
MACHO-I386-NEXT: Name: _main (1)
MACHO-I386-NEXT: Type: 0xF
MACHO-I386-NEXT: Extern
MACHO-I386-NEXT: Type: Section (0xE)
MACHO-I386-NEXT: Section: __text (0x1)
MACHO-I386-NEXT: RefType: UndefinedNonLazy (0x0)
MACHO-I386-NEXT: Flags [ (0x0)
Expand Down Expand Up @@ -231,7 +232,8 @@ MACHO-X86-64-NEXT: ]
MACHO-X86-64-NEXT: Symbols [
MACHO-X86-64-NEXT: Symbol {
MACHO-X86-64-NEXT: Name: _main (1)
MACHO-X86-64-NEXT: Type: 0xF
MACHO-X86-64-NEXT: Extern
MACHO-X86-64-NEXT: Type: Section (0xE)
MACHO-X86-64-NEXT: Section: __text (0x1)
MACHO-X86-64-NEXT: RefType: UndefinedNonLazy (0x0)
MACHO-X86-64-NEXT: Flags [ (0x0)
Expand Down Expand Up @@ -306,7 +308,8 @@ MACHO-PPC-NEXT: ]
MACHO-PPC-NEXT: Symbols [
MACHO-PPC-NEXT: Symbol {
MACHO-PPC-NEXT: Name: _f (4)
MACHO-PPC-NEXT: Type: 0xF
MACHO-PPC-NEXT: Extern
MACHO-PPC-NEXT: Type: Section (0xE)
MACHO-PPC-NEXT: Section: __text (0x1)
MACHO-PPC-NEXT: RefType: UndefinedNonLazy (0x0)
MACHO-PPC-NEXT: Flags [ (0x0)
Expand Down Expand Up @@ -371,7 +374,8 @@ MACHO-PPC-NEXT: ]
MACHO-PPC-NEXT: Symbols [
MACHO-PPC-NEXT: Symbol {
MACHO-PPC-NEXT: Name: _b (1)
MACHO-PPC-NEXT: Type: 0xF
MACHO-PPC-NEXT: Extern
MACHO-PPC-NEXT: Type: Section (0xE)
MACHO-PPC-NEXT: Section: __data (0x3)
MACHO-PPC-NEXT: RefType: UndefinedNonLazy (0x0)
MACHO-PPC-NEXT: Flags [ (0x0)
Expand Down Expand Up @@ -461,7 +465,8 @@ MACHO-PPC64-NEXT: ]
MACHO-PPC64-NEXT: Symbols [
MACHO-PPC64-NEXT: Symbol {
MACHO-PPC64-NEXT: Name: _f (4)
MACHO-PPC64-NEXT: Type: 0xF
MACHO-PPC64-NEXT: Extern
MACHO-PPC64-NEXT: Type: Section (0xE)
MACHO-PPC64-NEXT: Section: __text (0x1)
MACHO-PPC64-NEXT: RefType: UndefinedNonLazy (0x0)
MACHO-PPC64-NEXT: Flags [ (0x0)
Expand Down Expand Up @@ -526,7 +531,8 @@ MACHO-PPC64-NEXT: ]
MACHO-PPC64-NEXT: Symbols [
MACHO-PPC64-NEXT: Symbol {
MACHO-PPC64-NEXT: Name: _b (1)
MACHO-PPC64-NEXT: Type: 0xF
MACHO-PPC64-NEXT: Extern
MACHO-PPC64-NEXT: Type: Section (0xE)
MACHO-PPC64-NEXT: Section: __data (0x3)
MACHO-PPC64-NEXT: RefType: UndefinedNonLazy (0x0)
MACHO-PPC64-NEXT: Flags [ (0x0)
Expand Down Expand Up @@ -691,7 +697,8 @@ MACHO-ARM-NEXT: ]
MACHO-ARM-NEXT: Symbols [
MACHO-ARM-NEXT: Symbol {
MACHO-ARM-NEXT: Name: _f (4)
MACHO-ARM-NEXT: Type: 0xF
MACHO-ARM-NEXT: Extern
MACHO-ARM-NEXT: Type: Section (0xE)
MACHO-ARM-NEXT: Section: __text (0x1)
MACHO-ARM-NEXT: RefType: UndefinedNonLazy (0x0)
MACHO-ARM-NEXT: Flags [ (0x0)
Expand All @@ -700,7 +707,8 @@ MACHO-ARM-NEXT: Value: 0x10
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Symbol {
MACHO-ARM-NEXT: Name: _h (1)
MACHO-ARM-NEXT: Type: 0xF
MACHO-ARM-NEXT: Extern
MACHO-ARM-NEXT: Type: Section (0xE)
MACHO-ARM-NEXT: Section: __text (0x1)
MACHO-ARM-NEXT: RefType: UndefinedNonLazy (0x0)
MACHO-ARM-NEXT: Flags [ (0x0)
Expand Down Expand Up @@ -825,7 +833,8 @@ MACHO-ARM-NEXT: ]
MACHO-ARM-NEXT: Symbols [
MACHO-ARM-NEXT: Symbol {
MACHO-ARM-NEXT: Name: _b (10)
MACHO-ARM-NEXT: Type: 0xF
MACHO-ARM-NEXT: Extern
MACHO-ARM-NEXT: Type: Section (0xE)
MACHO-ARM-NEXT: Section: __data (0x6)
MACHO-ARM-NEXT: RefType: UndefinedNonLazy (0x0)
MACHO-ARM-NEXT: Flags [ (0x0)
Expand Down
11 changes: 7 additions & 4 deletions tools/llvm-readobj/MachODumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,10 @@ static const EnumEntry<unsigned> MachOSymbolFlags[] = {

static const EnumEntry<unsigned> MachOSymbolTypes[] = {
{ "Undef", 0x0 },
{ "External", 0x1 },
{ "Abs", 0x2 },
{ "Indirect", 0xA },
{ "PreboundUndef", 0xC },
{ "Section", 0xE },
{ "PrivateExternal", 0x10 }
{ "Section", 0xE }
};

namespace {
Expand Down Expand Up @@ -395,7 +393,12 @@ void MachODumper::printSymbol(symbol_iterator SymI) {
if (Symbol.Type & MachO::N_STAB) {
W.printHex ("Type", "SymDebugTable", Symbol.Type);
} else {
W.printEnum("Type", Symbol.Type, makeArrayRef(MachOSymbolTypes));
if (Symbol.Type & MachO::N_PEXT)
W.startLine() << "PrivateExtern\n";
if (Symbol.Type & MachO::N_EXT)
W.startLine() << "Extern\n";
W.printEnum("Type", Symbol.Type & MachO::N_TYPE,
makeArrayRef(MachOSymbolTypes));
}
W.printHex ("Section", SectionName, Symbol.SectionIndex);
W.printEnum ("RefType", static_cast<uint16_t>(Symbol.Flags & 0xF),
Expand Down

0 comments on commit abb1fad

Please sign in to comment.