Configuration *elf2::Config;
LinkerDriver *elf2::Driver;
-bool elf2::link(ArrayRef<const char *> Args) {
+bool elf2::link(ArrayRef<const char *> Args, raw_ostream &Error) {
HasError = false;
+ ErrorOS = &Error;
Configuration C;
LinkerDriver D;
Config = &C;
#include "lld/Core/LLVM.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Option/ArgList.h"
+#include "llvm/Support/raw_ostream.h"
namespace lld {
namespace elf2 {
extern class LinkerDriver *Driver;
// Entry point of the ELF linker. Returns true on success.
-bool link(ArrayRef<const char *> Args);
+bool link(ArrayRef<const char *> Args, llvm::raw_ostream &Error = llvm::errs());
class LinkerDriver {
public:
namespace elf2 {
bool HasError;
+llvm::raw_ostream *ErrorOS;
void warning(const Twine &Msg) { llvm::errs() << Msg << "\n"; }
void error(const Twine &Msg) {
- llvm::errs() << Msg << "\n";
+ *ErrorOS << Msg << "\n";
HasError = true;
}
#include "lld/Core/LLVM.h"
+namespace llvm {
+class raw_ostream;
+}
+
namespace lld {
namespace elf2 {
extern bool HasError;
+extern llvm::raw_ostream *ErrorOS;
void warning(const Twine &Msg);
}
namespace elf2 {
-bool link(llvm::ArrayRef<const char *> args);
+bool link(llvm::ArrayRef<const char *> args, raw_ostream &diag = llvm::errs());
}
/// Driver for lld unit tests
case Flavor::old_gnu_ld:
return GnuLdDriver::linkELF(args, diagnostics);
case Flavor::gnu_ld:
- return elf2::link(args);
+ return elf2::link(args, diagnostics);
case Flavor::darwin_ld:
return DarwinLdDriver::linkMachO(args, diagnostics);
case Flavor::win_link: