diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-09 21:23:48 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-09 21:23:48 +0000 |
| commit | b047fead11133644be3dbae34b85be39ce2819e9 (patch) | |
| tree | 3e7f6a4c9e5ffd7af6044225e9be2962e4d8eabf /ELF/Driver.cpp | |
| parent | c09ce7fd2d62d85dcdf370f4bef732380fca4f1b (diff) | |
Notes
Diffstat (limited to 'ELF/Driver.cpp')
| -rw-r--r-- | ELF/Driver.cpp | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/ELF/Driver.cpp b/ELF/Driver.cpp index 6afbe62e5ec7..c8ea821ec522 100644 --- a/ELF/Driver.cpp +++ b/ELF/Driver.cpp @@ -26,6 +26,7 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Path.h" +#include "llvm/Support/TarWriter.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" #include <cstdlib> @@ -51,6 +52,7 @@ bool elf::link(ArrayRef<const char *> Args, bool CanExitEarly, ErrorCount = 0; ErrorOS = &Error; Argv0 = Args[0]; + Tar = nullptr; Config = make<Configuration>(); Driver = make<LinkerDriver>(); @@ -170,25 +172,6 @@ void LinkerDriver::addFile(StringRef Path) { } } -Optional<MemoryBufferRef> LinkerDriver::readFile(StringRef Path) { - if (Config->Verbose) - outs() << Path << "\n"; - - auto MBOrErr = MemoryBuffer::getFile(Path); - if (auto EC = MBOrErr.getError()) { - error(EC, "cannot open " + Path); - return None; - } - std::unique_ptr<MemoryBuffer> &MB = *MBOrErr; - MemoryBufferRef MBRef = MB->getMemBufferRef(); - make<std::unique_ptr<MemoryBuffer>>(std::move(MB)); // take MB ownership - - if (Tar) - Tar->append(relativeToRoot(Path), MBRef.getBuffer()); - - return MBRef; -} - // Add a given library by searching it from input search paths. void LinkerDriver::addLibrary(StringRef Name) { if (Optional<std::string> Path = searchLibrary(Name)) @@ -313,9 +296,10 @@ void LinkerDriver::main(ArrayRef<const char *> ArgsArr, bool CanExitEarly) { Expected<std::unique_ptr<TarWriter>> ErrOrWriter = TarWriter::create(Path, path::stem(Path)); if (ErrOrWriter) { - Tar = std::move(*ErrOrWriter); + Tar = ErrOrWriter->get(); Tar->append("response.txt", createResponseFile(Args)); Tar->append("version.txt", getLLDVersion() + "\n"); + make<std::unique_ptr<TarWriter>>(std::move(*ErrOrWriter)); } else { error(Twine("--reproduce: failed to open ") + Path + ": " + toString(ErrOrWriter.takeError())); |
