summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-08-05 23:51:50 +0000
committerRui Ueyama <ruiu@google.com>2015-08-05 23:51:50 +0000
commitcb8474edaef076194a44f0ffb13edcbfc4196692 (patch)
tree0e3f50c1d1ec9051d7e3362f4e289b0e483b1f46
parente03437c756220fe802c67b17bda8f142f86e9cdc (diff)
downloadbcm5719-llvm-cb8474edaef076194a44f0ffb13edcbfc4196692.tar.gz
bcm5719-llvm-cb8474edaef076194a44f0ffb13edcbfc4196692.zip
COFF, ELF2: Pass output file path implicitly using Config global variable.
Various parameters are passed implicitly using Config global variable already. Output file path is no different from others, so there was no special reason to handle that differnetly. This patch changes the signature of writeResult(SymbolTable *, StringRef) to writeResult(SymbolTable *). llvm-svn: 244180
-rw-r--r--lld/COFF/Driver.cpp2
-rw-r--r--lld/COFF/Writer.cpp9
-rw-r--r--lld/COFF/Writer.h2
-rw-r--r--lld/ELF/Driver.cpp8
-rw-r--r--lld/ELF/Writer.cpp18
-rw-r--r--lld/ELF/Writer.h2
6 files changed, 18 insertions, 23 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index fc5d040cb0b..088e5369e90 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -726,7 +726,7 @@ bool LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) {
touchFile(Arg->getValue());
// Write the result.
- if (auto EC = writeResult(&Symtab, Config->OutputFile)) {
+ if (auto EC = writeResult(&Symtab)) {
llvm::errs() << EC.message() << "\n";
return false;
}
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 0d345871055..f08d9488b7c 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -45,7 +45,7 @@ namespace {
// The writer writes a SymbolTable result to a file.
class Writer {
public:
- Writer(SymbolTable *T, StringRef S) : Symtab(T), OutputPath(S) {}
+ Writer(SymbolTable *T) : Symtab(T) {}
std::error_code run();
private:
@@ -77,7 +77,6 @@ private:
std::map<StringRef, std::vector<DefinedImportData *>> binImports();
SymbolTable *Symtab;
- StringRef OutputPath;
std::unique_ptr<llvm::FileOutputBuffer> Buffer;
llvm::SpecificBumpPtrAllocator<OutputSection> CAlloc;
llvm::SpecificBumpPtrAllocator<BaserelChunk> BAlloc;
@@ -102,9 +101,7 @@ private:
namespace lld {
namespace coff {
-std::error_code writeResult(SymbolTable *T, StringRef Path) {
- return Writer(T, Path).run();
-}
+std::error_code writeResult(SymbolTable *T) { return Writer(T).run(); }
// OutputSection represents a section in an output file. It's a
// container of chunks. OutputSection and Chunk are 1:N relationship.
@@ -233,7 +230,7 @@ std::error_code Writer::run() {
assignAddresses();
removeEmptySections();
createSymbolAndStringTable();
- if (auto EC = openFile(OutputPath))
+ if (auto EC = openFile(Config->OutputFile))
return EC;
if (Config->is64()) {
writeHeader<pe32plus_header>();
diff --git a/lld/COFF/Writer.h b/lld/COFF/Writer.h
index 37caae8de8f..0a213e2134a 100644
--- a/lld/COFF/Writer.h
+++ b/lld/COFF/Writer.h
@@ -18,7 +18,7 @@ namespace coff {
class Chunk;
class OutputSection;
-std::error_code writeResult(SymbolTable *T, StringRef Path);
+std::error_code writeResult(SymbolTable *T);
// Implemented in ICF.cpp.
void doICF(const std::vector<Chunk *> &Chunks);
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index ab4fc2ec998..f48a33bfd0c 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -119,16 +119,16 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
ObjectFileBase &FirstObj = *Symtab.ObjectFiles[0];
switch (FirstObj.kind()) {
case InputFile::Object32LEKind:
- writeResult<object::ELF32LE>(&Symtab, Config->OutputFile);
+ writeResult<object::ELF32LE>(&Symtab);
return;
case InputFile::Object32BEKind:
- writeResult<object::ELF32BE>(&Symtab, Config->OutputFile);
+ writeResult<object::ELF32BE>(&Symtab);
return;
case InputFile::Object64LEKind:
- writeResult<object::ELF64LE>(&Symtab, Config->OutputFile);
+ writeResult<object::ELF64LE>(&Symtab);
return;
case InputFile::Object64BEKind:
- writeResult<object::ELF64BE>(&Symtab, Config->OutputFile);
+ writeResult<object::ELF64BE>(&Symtab);
return;
}
}
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index b7bfd462210..e4c5617f147 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "Chunks.h"
+#include "Config.h"
#include "Driver.h"
#include "SymbolTable.h"
#include "Writer.h"
@@ -28,7 +29,7 @@ namespace {
template <class ELFT> class Writer {
public:
typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t;
- Writer(SymbolTable *T, StringRef S) : Symtab(T), OutputPath(S) {}
+ Writer(SymbolTable *T) : Symtab(T) {}
void run();
private:
@@ -39,7 +40,6 @@ private:
void writeSections();
SymbolTable *Symtab;
- StringRef OutputPath;
std::unique_ptr<llvm::FileOutputBuffer> Buffer;
llvm::SpecificBumpPtrAllocator<OutputSection> CAlloc;
std::vector<OutputSection *> OutputSections;
@@ -80,14 +80,12 @@ private:
};
template <class ELFT>
-void writeResult(SymbolTable *Symtab, StringRef Path) {
- Writer<ELFT>(Symtab, Path).run();
-}
+void writeResult(SymbolTable *Symtab) { Writer<ELFT>(Symtab).run(); }
-template void writeResult<ELF32LE>(SymbolTable *, StringRef);
-template void writeResult<ELF32BE>(SymbolTable *, StringRef);
-template void writeResult<ELF64LE>(SymbolTable *, StringRef);
-template void writeResult<ELF64BE>(SymbolTable *, StringRef);
+template void writeResult<ELF32LE>(SymbolTable *);
+template void writeResult<ELF32BE>(SymbolTable *);
+template void writeResult<ELF64LE>(SymbolTable *);
+template void writeResult<ELF64BE>(SymbolTable *);
} // namespace elf2
} // namespace lld
@@ -96,7 +94,7 @@ template void writeResult<ELF64BE>(SymbolTable *, StringRef);
template <class ELFT> void Writer<ELFT>::run() {
createSections();
assignAddresses();
- openFile(OutputPath);
+ openFile(Config->OutputFile);
writeHeader();
writeSections();
error(Buffer->commit());
diff --git a/lld/ELF/Writer.h b/lld/ELF/Writer.h
index 5302d6bf3a3..b54251ef995 100644
--- a/lld/ELF/Writer.h
+++ b/lld/ELF/Writer.h
@@ -17,7 +17,7 @@ class OutputSection;
class SymbolTable;
template <class ELFT>
-void writeResult(SymbolTable *Symtab, StringRef Path);
+void writeResult(SymbolTable *Symtab);
}
}
OpenPOWER on IntegriCloud