diff options
Diffstat (limited to 'COFF')
| -rw-r--r-- | COFF/Driver.cpp | 35 | ||||
| -rw-r--r-- | COFF/Driver.h | 3 | ||||
| -rw-r--r-- | COFF/InputFiles.cpp | 7 | ||||
| -rw-r--r-- | COFF/InputFiles.h | 5 | ||||
| -rw-r--r-- | COFF/Symbols.cpp | 15 | ||||
| -rw-r--r-- | COFF/Symbols.h | 5 |
6 files changed, 36 insertions, 34 deletions
diff --git a/COFF/Driver.cpp b/COFF/Driver.cpp index dc3a00ba55ed0..4dabd9ebcc6d3 100644 --- a/COFF/Driver.cpp +++ b/COFF/Driver.cpp @@ -25,6 +25,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" +#include "llvm/Support/TarWriter.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> @@ -98,9 +99,9 @@ MemoryBufferRef LinkerDriver::takeBuffer(std::unique_ptr<MemoryBuffer> MB) { MemoryBufferRef MBRef = *MB; OwningMBs.push_back(std::move(MB)); - if (Driver->Cpio) - Driver->Cpio->append(relativeToRoot(MBRef.getBufferIdentifier()), - MBRef.getBuffer()); + if (Driver->Tar) + Driver->Tar->append(relativeToRoot(MBRef.getBufferIdentifier()), + MBRef.getBuffer()); return MBRef; } @@ -368,7 +369,7 @@ static std::string createResponseFile(const opt::InputArgList &Args, case OPT_libpath: break; default: - OS << stringize(Arg) << "\n"; + OS << toString(Arg) << "\n"; } } @@ -458,13 +459,17 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) { if (auto *Arg = Args.getLastArg(OPT_linkrepro)) { SmallString<64> Path = StringRef(Arg->getValue()); - sys::path::append(Path, "repro"); - ErrorOr<CpioFile *> F = CpioFile::create(Path); - if (F) - Cpio.reset(*F); - else - errs() << "/linkrepro: failed to open " << Path - << ".cpio: " << F.getError().message() << '\n'; + sys::path::append(Path, "repro.tar"); + + Expected<std::unique_ptr<TarWriter>> ErrOrWriter = + TarWriter::create(Path, "repro"); + + if (ErrOrWriter) { + Tar = std::move(*ErrOrWriter); + } else { + errs() << "/linkrepro: failed to open " << Path << ": " + << toString(ErrOrWriter.takeError()) << '\n'; + } } if (Args.filtered_begin(OPT_INPUT) == Args.filtered_end()) @@ -683,10 +688,10 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) { if (!Resources.empty()) addBuffer(convertResToCOFF(Resources)); - if (Cpio) - Cpio->append("response.txt", - createResponseFile(Args, FilePaths, - ArrayRef<StringRef>(SearchPaths).slice(1))); + if (Tar) + Tar->append("response.txt", + createResponseFile(Args, FilePaths, + ArrayRef<StringRef>(SearchPaths).slice(1))); // Handle /largeaddressaware if (Config->is64() || Args.hasArg(OPT_largeaddressaware)) diff --git a/COFF/Driver.h b/COFF/Driver.h index e8114640edecc..44894269fcbe7 100644 --- a/COFF/Driver.h +++ b/COFF/Driver.h @@ -20,6 +20,7 @@ #include "llvm/Object/COFF.h" #include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" +#include "llvm/Support/TarWriter.h" #include <memory> #include <set> #include <vector> @@ -74,7 +75,7 @@ private: ArgParser Parser; SymbolTable Symtab; - std::unique_ptr<CpioFile> Cpio; // for /linkrepro + std::unique_ptr<llvm::TarWriter> Tar; // for /linkrepro // Opens a file. Path has to be resolved already. MemoryBufferRef openFile(StringRef Path); diff --git a/COFF/InputFiles.cpp b/COFF/InputFiles.cpp index 0a97c2185f894..cde355cd3f343 100644 --- a/COFF/InputFiles.cpp +++ b/COFF/InputFiles.cpp @@ -372,6 +372,8 @@ MachineTypes BitcodeFile::getMachineType() { return IMAGE_FILE_MACHINE_UNKNOWN; } } +} // namespace coff +} // namespace lld // Returns the last element of a path, which is supposed to be a filename. static StringRef getBasename(StringRef Path) { @@ -382,7 +384,7 @@ static StringRef getBasename(StringRef Path) { } // Returns a string in the format of "foo.obj" or "foo.obj(bar.lib)". -std::string toString(InputFile *File) { +std::string lld::toString(coff::InputFile *File) { if (!File) return "(internal)"; if (File->ParentName.empty()) @@ -393,6 +395,3 @@ std::string toString(InputFile *File) { .str(); return StringRef(Res).lower(); } - -} // namespace coff -} // namespace lld diff --git a/COFF/InputFiles.h b/COFF/InputFiles.h index 498a1743e9853..1b5d42939ccab 100644 --- a/COFF/InputFiles.h +++ b/COFF/InputFiles.h @@ -202,10 +202,9 @@ private: llvm::BumpPtrAllocator Alloc; std::unique_ptr<LTOModule> M; }; - -std::string toString(InputFile *File); - } // namespace coff + +std::string toString(coff::InputFile *File); } // namespace lld #endif diff --git a/COFF/Symbols.cpp b/COFF/Symbols.cpp index 6de85d581f494..c44537d371350 100644 --- a/COFF/Symbols.cpp +++ b/COFF/Symbols.cpp @@ -19,6 +19,13 @@ using namespace llvm; using namespace llvm::object; +// Returns a symbol name for an error message. +std::string lld::toString(coff::SymbolBody &B) { + if (Optional<std::string> S = coff::demangle(B.getName())) + return ("\"" + *S + "\" (" + B.getName() + ")").str(); + return B.getName(); +} + namespace lld { namespace coff { @@ -73,13 +80,5 @@ Defined *Undefined::getWeakAlias() { return D; return nullptr; } - -// Returns a symbol name for an error message. -std::string toString(SymbolBody &B) { - if (Optional<std::string> S = demangle(B.getName())) - return ("\"" + *S + "\" (" + B.getName() + ")").str(); - return B.getName(); -} - } // namespace coff } // namespace lld diff --git a/COFF/Symbols.h b/COFF/Symbols.h index bc9ad4aa8affa..1ca7366364d79 100644 --- a/COFF/Symbols.h +++ b/COFF/Symbols.h @@ -428,10 +428,9 @@ inline Symbol *SymbolBody::symbol() { return reinterpret_cast<Symbol *>(reinterpret_cast<char *>(this) - offsetof(Symbol, Body)); } - -std::string toString(SymbolBody &B); - } // namespace coff + +std::string toString(coff::SymbolBody &B); } // namespace lld #endif |
