summaryrefslogtreecommitdiff
path: root/tools/llvm-nm/llvm-nm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llvm-nm/llvm-nm.cpp')
-rw-r--r--tools/llvm-nm/llvm-nm.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp
index 3e43953796..422cdda874 100644
--- a/tools/llvm-nm/llvm-nm.cpp
+++ b/tools/llvm-nm/llvm-nm.cpp
@@ -20,6 +20,7 @@
#include "llvm/Bytecode/Reader.h"
#include "llvm/Bytecode/Archive.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ManagedStatic.h"
#include "llvm/System/Signals.h"
#include <cctype>
#include <cerrno>
@@ -65,18 +66,18 @@ namespace {
std::string ToolName;
}
-char TypeCharForSymbol (GlobalValue &GV) {
- if (GV.isExternal ()) return 'U';
- if (GV.hasLinkOnceLinkage ()) return 'C';
- if (GV.hasWeakLinkage ()) return 'W';
- if (isa<Function> (GV) && GV.hasInternalLinkage ()) return 't';
- if (isa<Function> (GV)) return 'T';
- if (isa<GlobalVariable> (GV) && GV.hasInternalLinkage ()) return 'd';
- if (isa<GlobalVariable> (GV)) return 'D';
+static char TypeCharForSymbol(GlobalValue &GV) {
+ if (GV.isExternal()) return 'U';
+ if (GV.hasLinkOnceLinkage()) return 'C';
+ if (GV.hasWeakLinkage()) return 'W';
+ if (isa<Function>(GV) && GV.hasInternalLinkage()) return 't';
+ if (isa<Function>(GV)) return 'T';
+ if (isa<GlobalVariable>(GV) && GV.hasInternalLinkage()) return 'd';
+ if (isa<GlobalVariable>(GV)) return 'D';
return '?';
}
-void DumpSymbolNameForGlobalValue (GlobalValue &GV) {
+static void DumpSymbolNameForGlobalValue(GlobalValue &GV) {
const std::string SymbolAddrStr = " "; // Not used yet...
char TypeChar = TypeCharForSymbol (GV);
if ((TypeChar != 'U') && UndefinedOnly)
@@ -101,7 +102,7 @@ void DumpSymbolNameForGlobalValue (GlobalValue &GV) {
}
}
-void DumpSymbolNamesFromModule (Module *M) {
+static void DumpSymbolNamesFromModule(Module *M) {
const std::string &Filename = M->getModuleIdentifier ();
if (OutputFormat == posix && MultipleFiles) {
std::cout << Filename << ":\n";
@@ -116,7 +117,7 @@ void DumpSymbolNamesFromModule (Module *M) {
std::for_each (M->global_begin (), M->global_end (), DumpSymbolNameForGlobalValue);
}
-void DumpSymbolNamesFromFile (std::string &Filename) {
+static void DumpSymbolNamesFromFile(std::string &Filename) {
std::string ErrorMessage;
sys::Path aPath(Filename);
if (Filename != "-") {
@@ -135,16 +136,16 @@ void DumpSymbolNamesFromFile (std::string &Filename) {
}
} else if (aPath.isArchive()) {
std::string ErrMsg;
- Archive* archive = Archive::OpenAndLoad(sys::Path(Filename),&ErrorMessage);
+ Archive* archive = Archive::OpenAndLoad(sys::Path(Filename), &ErrorMessage);
if (!archive)
std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
std::vector<Module *> Modules;
- if (archive->getAllModules(Modules,&ErrorMessage)) {
+ if (archive->getAllModules(Modules, &ErrorMessage)) {
std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
return;
}
MultipleFiles = true;
- std::for_each (Modules.begin (), Modules.end (), DumpSymbolNamesFromModule);
+ std::for_each (Modules.begin(), Modules.end(), DumpSymbolNamesFromModule);
} else {
std::cerr << ToolName << ": " << Filename << ": "
<< "unrecognizable file type\n";
@@ -153,6 +154,7 @@ void DumpSymbolNamesFromFile (std::string &Filename) {
}
int main(int argc, char **argv) {
+ llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
try {
cl::ParseCommandLineOptions(argc, argv, " llvm symbol table dumper\n");
sys::PrintStackTraceOnErrorSignal();