Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
Show First 20 Lines • Show All 591 Lines • ▼ Show 20 Lines | static void darwinPrintStab(MachOObjectFile *MachO, SymbolListT::iterator I) { | ||||
outs() << Str << ' '; | outs() << Str << ' '; | ||||
if (const char *stabString = getDarwinStabString(NType)) | if (const char *stabString = getDarwinStabString(NType)) | ||||
format("%5.5s", stabString).print(Str, sizeof(Str)); | format("%5.5s", stabString).print(Str, sizeof(Str)); | ||||
else | else | ||||
format(" %02x", NType).print(Str, sizeof(Str)); | format(" %02x", NType).print(Str, sizeof(Str)); | ||||
outs() << Str; | outs() << Str; | ||||
} | } | ||||
static bool symbolIsDefined(const NMSymbol &Sym) { | |||||
return Sym.TypeChar != 'U' && Sym.TypeChar != 'w' && Sym.TypeChar != 'v'; | |||||
} | |||||
static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName, | static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName, | ||||
const std::string &ArchiveName, | const std::string &ArchiveName, | ||||
const std::string &ArchitectureName) { | const std::string &ArchitectureName) { | ||||
if (!NoSort) { | if (!NoSort) { | ||||
std::function<bool(const NMSymbol &, const NMSymbol &)> Cmp; | std::function<bool(const NMSymbol &, const NMSymbol &)> Cmp; | ||||
if (NumericSort) | if (NumericSort) | ||||
Cmp = compareSymbolAddress; | Cmp = compareSymbolAddress; | ||||
else if (SizeSort) | else if (SizeSort) | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | if ((JustSymbolName || (UndefinedOnly && isa<MachOObjectFile>(Obj) && | ||||
OutputFormat != darwin)) && OutputFormat != posix) { | OutputFormat != darwin)) && OutputFormat != posix) { | ||||
outs() << I->Name << "\n"; | outs() << I->Name << "\n"; | ||||
continue; | continue; | ||||
} | } | ||||
char SymbolAddrStr[18] = ""; | char SymbolAddrStr[18] = ""; | ||||
char SymbolSizeStr[18] = ""; | char SymbolSizeStr[18] = ""; | ||||
if (OutputFormat == sysv || I->TypeChar == 'U') { | // If the format is SysV or the symbol isn't defined, then print spaces. | ||||
if (OutputFormat == posix) | if (OutputFormat == sysv || !symbolIsDefined(*I)) { | ||||
if (OutputFormat == posix) { | |||||
format(printFormat, I->Address) | format(printFormat, I->Address) | ||||
.print(SymbolAddrStr, sizeof(SymbolAddrStr)); | .print(SymbolAddrStr, sizeof(SymbolAddrStr)); | ||||
else | format(printFormat, I->Size) | ||||
.print(SymbolSizeStr, sizeof(SymbolSizeStr)); | |||||
} else { | |||||
strcpy(SymbolAddrStr, printBlanks); | strcpy(SymbolAddrStr, printBlanks); | ||||
} | |||||
if (OutputFormat == sysv) | |||||
strcpy(SymbolSizeStr, printBlanks); | strcpy(SymbolSizeStr, printBlanks); | ||||
} | |||||
} | |||||
if (I->TypeChar != 'U') { | // Otherwise, print the symbol address and size. | ||||
if (symbolIsDefined(*I)) { | |||||
if (Obj.isIR()) | if (Obj.isIR()) | ||||
strcpy(SymbolAddrStr, printDashes); | strcpy(SymbolAddrStr, printDashes); | ||||
else | else | ||||
format(printFormat, I->Address) | format(printFormat, I->Address) | ||||
.print(SymbolAddrStr, sizeof(SymbolAddrStr)); | .print(SymbolAddrStr, sizeof(SymbolAddrStr)); | ||||
} | |||||
format(printFormat, I->Size).print(SymbolSizeStr, sizeof(SymbolSizeStr)); | format(printFormat, I->Size).print(SymbolSizeStr, sizeof(SymbolSizeStr)); | ||||
} | |||||
// If OutputFormat is darwin or we are printing Mach-O symbols in hex and | // If OutputFormat is darwin or we are printing Mach-O symbols in hex and | ||||
// we have a MachOObjectFile, call darwinPrintSymbol to print as darwin's | // we have a MachOObjectFile, call darwinPrintSymbol to print as darwin's | ||||
// nm(1) -m output or hex, else if OutputFormat is darwin or we are | // nm(1) -m output or hex, else if OutputFormat is darwin or we are | ||||
// printing Mach-O symbols in hex and not a Mach-O object fall back to | // printing Mach-O symbols in hex and not a Mach-O object fall back to | ||||
// OutputFormat bsd (see below). | // OutputFormat bsd (see below). | ||||
MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj); | MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj); | ||||
if ((OutputFormat == darwin || FormatMachOasHex) && (MachO || Obj.isIR())) { | if ((OutputFormat == darwin || FormatMachOasHex) && (MachO || Obj.isIR())) { | ||||
▲ Show 20 Lines • Show All 713 Lines • Show Last 20 Lines |