#include "llvm/ADT/StringSwitch.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/BinaryFormat/XCOFF.h"
#include "llvm/DebugInfo/Symbolize/Symbolize.h"
#include "llvm/Demangle/Demangle.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/COFF.h"
#include "llvm/Object/COFFImportFile.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/IRObjectFile.h"
#include "llvm/Object/MachO.h"
#include "llvm/Object/MachOUniversal.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Object/SymbolicFile.h"
#include "llvm/Object/TapiFile.h"
#include "llvm/Object/TapiUniversal.h"
#include "llvm/Object/Wasm.h"
#include "llvm/Object/XCOFFObjectFile.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/Triple.h"
#include <vector>
usingnamespacellvm;
usingnamespaceobject;
namespace {
usingnamespacellvm::opt;
enum ID { … };
#define PREFIX …
#include "Opts.inc"
#undef PREFIX
static constexpr opt::OptTable::Info InfoTable[] = …;
class NmOptTable : public opt::GenericOptTable { … };
enum OutputFormatTy { … };
enum class BitModeTy { … };
}
static bool ArchiveMap;
static BitModeTy BitMode;
static bool DebugSyms;
static bool DefinedOnly;
static bool Demangle;
static bool DynamicSyms;
static bool ExportSymbols;
static bool ExternalOnly;
static bool LineNumbers;
static OutputFormatTy OutputFormat;
static bool NoLLVMBitcode;
static bool NoSort;
static bool NoWeakSymbols;
static bool NumericSort;
static bool PrintFileName;
static bool PrintSize;
static bool Quiet;
static bool ReverseSort;
static bool SpecialSyms;
static bool SizeSort;
static bool UndefinedOnly;
static bool WithoutAliases;
static bool NoRsrc;
namespace {
enum Radix { … };
}
static Radix AddressRadix;
static bool ArchAll = …;
static std::vector<StringRef> ArchFlags;
static bool AddDyldInfo;
static bool AddInlinedInfo;
static bool DyldInfoOnly;
static bool FormatMachOasHex;
static bool NoDyldInfo;
static std::vector<StringRef> SegSect;
static bool MachOPrintSizeWarning = …;
static bool PrintAddress = …;
static bool MultipleFiles = …;
static bool HadError = …;
static StringRef ToolName;
static void warn(Error Err, Twine FileName, Twine Context = Twine(),
Twine Archive = Twine()) { … }
static void error(Twine Message, Twine Path = Twine()) { … }
static bool error(std::error_code EC, Twine Path = Twine()) { … }
static void error(llvm::Error E, StringRef FileName, const Archive::Child &C,
StringRef ArchitectureName = StringRef()) { … }
static void error(llvm::Error E, StringRef FileName,
StringRef ArchitectureName = StringRef()) { … }
namespace {
struct NMSymbol { … };
bool operator<(const NMSymbol &A, const NMSymbol &B) { … }
bool operator>(const NMSymbol &A, const NMSymbol &B) { … }
bool operator==(const NMSymbol &A, const NMSymbol &B) { … }
}
static StringRef CurrentFilename;
static char getSymbolNMTypeChar(IRObjectFile &Obj, basic_symbol_iterator I);
static void darwinPrintSymbol(SymbolicFile &Obj, const NMSymbol &S,
char *SymbolAddrStr, const char *printBlanks,
const char *printDashes,
const char *printFormat) { … }
struct DarwinStabName { … };
const struct DarwinStabName DarwinStabNames[] = …;
static const char *getDarwinStabString(uint8_t NType) { … }
static void darwinPrintStab(MachOObjectFile *MachO, const NMSymbol &S) { … }
static bool symbolIsDefined(const NMSymbol &Sym) { … }
static void writeFileName(raw_ostream &S, StringRef ArchiveName,
StringRef ArchitectureName) { … }
static void sortSymbolList(std::vector<NMSymbol> &SymbolList) { … }
static void printExportSymbolList(const std::vector<NMSymbol> &SymbolList) { … }
static void printLineNumbers(symbolize::LLVMSymbolizer &Symbolizer,
const NMSymbol &S) { … }
static void printSymbolList(SymbolicFile &Obj,
std::vector<NMSymbol> &SymbolList, bool printName,
StringRef ArchiveName, StringRef ArchitectureName) { … }
static char getSymbolNMTypeChar(ELFObjectFileBase &Obj,
basic_symbol_iterator I) { … }
static char getSymbolNMTypeChar(COFFObjectFile &Obj, symbol_iterator I) { … }
static char getSymbolNMTypeChar(XCOFFObjectFile &Obj, symbol_iterator I) { … }
static char getSymbolNMTypeChar(COFFImportFile &Obj) { … }
static char getSymbolNMTypeChar(MachOObjectFile &Obj, basic_symbol_iterator I) { … }
static char getSymbolNMTypeChar(TapiFile &Obj, basic_symbol_iterator I) { … }
static char getSymbolNMTypeChar(WasmObjectFile &Obj, basic_symbol_iterator I) { … }
static char getSymbolNMTypeChar(IRObjectFile &Obj, basic_symbol_iterator I) { … }
static bool isObject(SymbolicFile &Obj, basic_symbol_iterator I) { … }
static StringRef getNMTypeName(SymbolicFile &Obj, basic_symbol_iterator I) { … }
static char getNMSectionTagAndName(SymbolicFile &Obj, basic_symbol_iterator I,
StringRef &SecName) { … }
static unsigned getNsectForSegSect(MachOObjectFile *Obj) { … }
static unsigned getNsectInMachO(MachOObjectFile &Obj, BasicSymbolRef Sym) { … }
static void dumpSymbolsFromDLInfoMachO(MachOObjectFile &MachO,
std::vector<NMSymbol> &SymbolList) { … }
static bool shouldDump(SymbolicFile &Obj) { … }
static void getXCOFFExports(XCOFFObjectFile *XCOFFObj,
std::vector<NMSymbol> &SymbolList,
StringRef ArchiveName) { … }
static Expected<SymbolicFile::basic_symbol_iterator_range>
getDynamicSyms(SymbolicFile &Obj) { … }
static bool getSymbolNamesFromObject(SymbolicFile &Obj,
std::vector<NMSymbol> &SymbolList) { … }
static void printObjectLabel(bool PrintArchiveName, StringRef ArchiveName,
StringRef ArchitectureName,
StringRef ObjectFileName) { … }
static Expected<bool> hasSymbols(SymbolicFile &Obj) { … }
static void printSymbolNamesFromObject(
SymbolicFile &Obj, std::vector<NMSymbol> &SymbolList,
bool PrintSymbolObject, bool PrintObjectLabel, StringRef ArchiveName = { … }
static void dumpSymbolsNameFromMachOFilesetEntry(
MachOObjectFile *Obj, std::vector<NMSymbol> &SymbolList,
bool PrintSymbolObject, bool PrintObjectLabel) { … }
static void dumpSymbolNamesFromObject(
SymbolicFile &Obj, std::vector<NMSymbol> &SymbolList,
bool PrintSymbolObject, bool PrintObjectLabel, StringRef ArchiveName = { … }
static bool checkMachOAndArchFlags(SymbolicFile *O, StringRef Filename) { … }
static void printArchiveMap(iterator_range<Archive::symbol_iterator> &map,
StringRef Filename) { … }
static void dumpArchiveMap(Archive *A, StringRef Filename) { … }
static void dumpArchive(Archive *A, std::vector<NMSymbol> &SymbolList,
StringRef Filename, LLVMContext *ContextPtr) { … }
static void dumpMachOUniversalBinaryMatchArchFlags(
MachOUniversalBinary *UB, std::vector<NMSymbol> &SymbolList,
StringRef Filename, LLVMContext *ContextPtr) { … }
static bool dumpMachOUniversalBinaryMatchHost(MachOUniversalBinary *UB,
std::vector<NMSymbol> &SymbolList,
StringRef Filename,
LLVMContext *ContextPtr) { … }
static void dumpMachOUniversalBinaryArchAll(MachOUniversalBinary *UB,
std::vector<NMSymbol> &SymbolList,
StringRef Filename,
LLVMContext *ContextPtr) { … }
static void dumpMachOUniversalBinary(MachOUniversalBinary *UB,
std::vector<NMSymbol> &SymbolList,
StringRef Filename,
LLVMContext *ContextPtr) { … }
static void dumpTapiUniversal(TapiUniversal *TU,
std::vector<NMSymbol> &SymbolList,
StringRef Filename) { … }
static void dumpSymbolicFile(SymbolicFile *O, std::vector<NMSymbol> &SymbolList,
StringRef Filename) { … }
static std::vector<NMSymbol> dumpSymbolNamesFromFile(StringRef Filename) { … }
static void
exportSymbolNamesFromFiles(const std::vector<std::string> &InputFilenames) { … }
int llvm_nm_main(int argc, char **argv, const llvm::ToolContext &) { … }