aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm-ranlib/llvm-ranlib.cpp
diff options
context:
space:
mode:
authorJohn Criswell <criswell@uiuc.edu>2005-11-02 18:05:50 +0000
committerJohn Criswell <criswell@uiuc.edu>2005-11-02 18:05:50 +0000
commitcfa435f79bf39fead32263a8b71c9ae440b55214 (patch)
tree2f1ef0a4c3fb5549b8bbb014891f92866d46e042 /tools/llvm-ranlib/llvm-ranlib.cpp
Mark these as failing on sparc instead of sparcv9.
The configure script no longer tells us that we're configuring for SparcV9 specifically. 2004-06-17-UnorderedCompares may work on SparcV8, but it's experiental anyway. 2005-02-20-AggregateSAVEEXPR should fail on any Solaris machine, as Solaris doesn't provide complex number support. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_16@24155 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-ranlib/llvm-ranlib.cpp')
-rw-r--r--tools/llvm-ranlib/llvm-ranlib.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/tools/llvm-ranlib/llvm-ranlib.cpp b/tools/llvm-ranlib/llvm-ranlib.cpp
new file mode 100644
index 0000000000..d7d4714980
--- /dev/null
+++ b/tools/llvm-ranlib/llvm-ranlib.cpp
@@ -0,0 +1,92 @@
+//===-- llvm-ranlib.cpp - LLVM archive index generator --------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Adds or updates an index (symbol table) for an LLVM archive file.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Bytecode/Archive.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/System/Signals.h"
+#include <iostream>
+#include <iomanip>
+
+using namespace llvm;
+
+// llvm-ar operation code and modifier flags
+static cl::opt<std::string>
+ArchiveName(cl::Positional, cl::Optional, cl::desc("<archive-file>"));
+
+static cl::opt<bool>
+Verbose("verbose",cl::Optional,cl::init(false),
+ cl::desc("Print the symbol table"));
+
+// printSymbolTable - print out the archive's symbol table.
+void printSymbolTable(Archive* TheArchive) {
+ std::cout << "\nArchive Symbol Table:\n";
+ const Archive::SymTabType& symtab = TheArchive->getSymbolTable();
+ for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end();
+ I != E; ++I ) {
+ unsigned offset = TheArchive->getFirstFileOffset() + I->second;
+ std::cout << " " << std::setw(9) << offset << "\t" << I->first <<"\n";
+ }
+}
+
+int main(int argc, char **argv) {
+
+ // Have the command line options parsed and handle things
+ // like --help and --version.
+ cl::ParseCommandLineOptions(argc, argv,
+ " LLVM Archive Index Generator (llvm-ranlib)\n\n"
+ " This program adds or updates an index of bytecode symbols\n"
+ " to an LLVM archive file."
+ );
+
+ // Print a stack trace if we signal out.
+ sys::PrintStackTraceOnErrorSignal();
+
+ int exitCode = 0;
+
+ // Make sure we don't exit with "unhandled exception".
+ try {
+
+ // Check the path name of the archive
+ sys::Path ArchivePath;
+ if (!ArchivePath.set(ArchiveName))
+ throw std::string("Archive name invalid: ") + ArchiveName;
+
+ // Make sure it exists, we don't create empty archives
+ if (!ArchivePath.exists())
+ throw std::string("Archive file does not exist");
+
+ std::string err_msg;
+ std::auto_ptr<Archive>
+ AutoArchive(Archive::OpenAndLoad(ArchivePath,&err_msg));
+ Archive* TheArchive = AutoArchive.get();
+ if (!TheArchive)
+ throw err_msg;
+
+ TheArchive->writeToDisk(true, false, false );
+
+ if (Verbose)
+ printSymbolTable(TheArchive);
+
+ } catch (const char*msg) {
+ std::cerr << argv[0] << ": " << msg << "\n\n";
+ exitCode = 1;
+ } catch (const std::string& msg) {
+ std::cerr << argv[0] << ": " << msg << "\n";
+ exitCode = 2;
+ } catch (...) {
+ std::cerr << argv[0] << ": An unexpected unknown exception occurred.\n";
+ exitCode = 3;
+ }
+ return exitCode;
+}