forked from OSchip/llvm-project
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
This commit is contained in:
parent
e03437c756
commit
cb8474edae
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class OutputSection;
|
|||
class SymbolTable;
|
||||
|
||||
template <class ELFT>
|
||||
void writeResult(SymbolTable *Symtab, StringRef Path);
|
||||
void writeResult(SymbolTable *Symtab);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue