aboutsummaryrefslogtreecommitdiffstats
path: root/COFF
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-06 20:14:02 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-06 20:14:02 +0000
commitc09ce7fd2d62d85dcdf370f4bef732380fca4f1b (patch)
treedd5cf05b9ae703e6fb816b9663d4a0c903e0c2c6 /COFF
parent5d4d137132d719d0d20d119375b205d6a2c721ee (diff)
downloadsrc-c09ce7fd2d62d85dcdf370f4bef732380fca4f1b.tar.gz
src-c09ce7fd2d62d85dcdf370f4bef732380fca4f1b.zip
Vendor import of lld trunk r291274:vendor/lld/lld-trunk-r291274
Notes
Notes: svn path=/vendor/lld/dist/; revision=311540 svn path=/vendor/lld/lld-trunk-r291274/; revision=311541; tag=vendor/lld/lld-trunk-r291274
Diffstat (limited to 'COFF')
-rw-r--r--COFF/Driver.cpp35
-rw-r--r--COFF/Driver.h3
-rw-r--r--COFF/InputFiles.cpp7
-rw-r--r--COFF/InputFiles.h5
-rw-r--r--COFF/Symbols.cpp15
-rw-r--r--COFF/Symbols.h5
6 files changed, 36 insertions, 34 deletions
diff --git a/COFF/Driver.cpp b/COFF/Driver.cpp
index dc3a00ba55ed..4dabd9ebcc6d 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 e8114640edec..44894269fcbe 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 0a97c2185f89..cde355cd3f34 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 498a1743e985..1b5d42939cca 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 6de85d581f49..c44537d37135 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 bc9ad4aa8aff..1ca7366364d7 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