+//===- llvm-link.cpp - Low-level LLVM linker ------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
//===----------------------------------------------------------------------===//
-// LLVM 'LINK' UTILITY
//
// This utility may be invoked in the following manner:
-// link a.bc b.bc c.bc -o x.bc
+// llvm-link a.bc b.bc c.bc -o x.bc
//
//===----------------------------------------------------------------------===//
-#include "llvm/Transforms/Utils/Linker.h"
+#include "llvm/Module.h"
+#include "llvm/Analysis/Verifier.h"
#include "llvm/Bytecode/Reader.h"
#include "llvm/Bytecode/Writer.h"
-#include "llvm/Module.h"
+#include "llvm/Transforms/Utils/Linker.h"
#include "Support/CommandLine.h"
#include "Support/Signals.h"
#include <fstream>
#include <sys/types.h> // For FileExists
#include <sys/stat.h>
+using namespace llvm;
+
static cl::list<std::string>
InputFilenames(cl::Positional, cl::OneOrMore,
cl::desc("<input bytecode files>"));
if (FoundAFile)
std::cerr << "Bytecode file '" << FN << "' corrupt! "
- << "Use 'link -v ...' for more info.\n";
+ << "Use 'llvm-link -v ...' for more info.\n";
else
std::cerr << "Could not locate bytecode file: '" << FN << "'\n";
return std::auto_ptr<Module>();
return 1;
}
- // Make sure that the Out file gets unlink'd from the disk if we get a
+ // Make sure that the Out file gets unlinked from the disk if we get a
// SIGINT
RemoveFileOnSignal(OutputFilename);
}
+ if (verifyModule(*Composite.get())) {
+ std::cerr << argv[0] << ": linked module is broken!\n";
+ return 1;
+ }
+
if (Verbose) std::cerr << "Writing bytecode...\n";
WriteBytecodeToFile(Composite.get(), *Out);