forked from OSchip/llvm-project
Do not use templates to instantiate {Object,Shared}Files.
createELFFile looked complex because of its use of template, so I want to keep it private within this file. llvm-svn: 256880
This commit is contained in:
parent
f588ac4663
commit
533c03078b
|
@ -77,17 +77,17 @@ void LinkerDriver::addFile(StringRef Path) {
|
|||
if (WholeArchive) {
|
||||
auto File = make_unique<ArchiveFile>(MBRef);
|
||||
for (MemoryBufferRef &MB : File->getMembers())
|
||||
Files.push_back(createELFFile<ObjectFile>(MB));
|
||||
Files.push_back(createObjectFile(MB));
|
||||
OwningArchives.emplace_back(std::move(File));
|
||||
return;
|
||||
}
|
||||
Files.push_back(make_unique<ArchiveFile>(MBRef));
|
||||
return;
|
||||
case file_magic::elf_shared_object:
|
||||
Files.push_back(createELFFile<SharedFile>(MBRef));
|
||||
Files.push_back(createSharedFile(MBRef));
|
||||
return;
|
||||
default:
|
||||
Files.push_back(createELFFile<ObjectFile>(MBRef));
|
||||
Files.push_back(createObjectFile(MBRef));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -453,7 +453,7 @@ static std::unique_ptr<InputFile> createELFFileAux(MemoryBufferRef MB) {
|
|||
}
|
||||
|
||||
template <template <class> class T>
|
||||
std::unique_ptr<InputFile> elf2::createELFFile(MemoryBufferRef MB) {
|
||||
static std::unique_ptr<InputFile> createELFFile(MemoryBufferRef MB) {
|
||||
std::pair<unsigned char, unsigned char> Type = getElfArchType(MB.getBuffer());
|
||||
if (Type.second != ELF::ELFDATA2LSB && Type.second != ELF::ELFDATA2MSB)
|
||||
error("Invalid data encoding: " + MB.getBufferIdentifier());
|
||||
|
@ -471,6 +471,14 @@ std::unique_ptr<InputFile> elf2::createELFFile(MemoryBufferRef MB) {
|
|||
error("Invalid file class: " + MB.getBufferIdentifier());
|
||||
}
|
||||
|
||||
std::unique_ptr<InputFile> elf2::createObjectFile(MemoryBufferRef MB) {
|
||||
return createELFFile<ObjectFile>(MB);
|
||||
}
|
||||
|
||||
std::unique_ptr<InputFile> elf2::createSharedFile(MemoryBufferRef MB) {
|
||||
return createELFFile<SharedFile>(MB);
|
||||
}
|
||||
|
||||
template class elf2::ELFFileBase<ELF32LE>;
|
||||
template class elf2::ELFFileBase<ELF32BE>;
|
||||
template class elf2::ELFFileBase<ELF64LE>;
|
||||
|
@ -485,9 +493,3 @@ template class elf2::SharedFile<ELF32LE>;
|
|||
template class elf2::SharedFile<ELF32BE>;
|
||||
template class elf2::SharedFile<ELF64LE>;
|
||||
template class elf2::SharedFile<ELF64BE>;
|
||||
|
||||
template std::unique_ptr<InputFile>
|
||||
elf2::createELFFile<ObjectFile>(MemoryBufferRef);
|
||||
|
||||
template std::unique_ptr<InputFile>
|
||||
elf2::createELFFile<SharedFile>(MemoryBufferRef);
|
||||
|
|
|
@ -202,8 +202,8 @@ public:
|
|||
bool isNeeded() const { return !AsNeeded || IsUsed; }
|
||||
};
|
||||
|
||||
template <template <class> class T>
|
||||
std::unique_ptr<InputFile> createELFFile(MemoryBufferRef MB);
|
||||
std::unique_ptr<InputFile> createObjectFile(MemoryBufferRef MB);
|
||||
std::unique_ptr<InputFile> createSharedFile(MemoryBufferRef MB);
|
||||
|
||||
} // namespace elf2
|
||||
} // namespace lld
|
||||
|
|
|
@ -115,8 +115,7 @@ std::unique_ptr<InputFile> Lazy::getMember() {
|
|||
// read from the library.
|
||||
if (MBRef.getBuffer().empty())
|
||||
return std::unique_ptr<InputFile>(nullptr);
|
||||
|
||||
return createELFFile<ObjectFile>(MBRef);
|
||||
return createObjectFile(MBRef);
|
||||
}
|
||||
|
||||
template <class ELFT> static void doInitSymbols() {
|
||||
|
|
Loading…
Reference in New Issue