Files
clang-p2996/lld/lib/ReaderWriter/ELF/Writer.cpp
Nick Kledzik c314b46e71 This is my Driver refactoring patch.
The major changes are:
1) LinkerOptions has been merged into TargetInfo
2) LinkerInvocation has been merged into Driver
3) Drivers no longer convert arguments into an intermediate (core) argument 
   list, but instead create a TargetInfo object and call setter methods on 
   it. This is only how in-process linking would work. That is, you can 
   programmatically set up a TargetInfo object which controls the linking.
4) Lots of tweaks to test suite to work with driver changes
5) Add the DarwinDriver
6) I heavily doxygen commented TargetInfo.h

Things to do after this patch is committed:
a) Consider renaming TargetInfo, given its new roll. 
b) Consider pulling the list of input files out of TargetInfo. This will 
   enable in-process clients to create one TargetInfo the re-use it with 
   different input file lists.
c) Work out a way for Drivers to format the warnings and error done in 
   core linking.

llvm-svn: 178776
2013-04-04 18:59:24 +00:00

69 lines
2.2 KiB
C++

//===- lib/ReaderWriter/ELF/WriterELF.cpp ---------------------------------===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lld/ReaderWriter/Writer.h"
#include "DynamicLibraryWriter.h"
#include "ExecutableWriter.h"
using namespace llvm;
using namespace llvm::object;
namespace lld {
std::unique_ptr<Writer> createWriterELF(const ELFTargetInfo &info) {
using llvm::object::ELFType;
// Set the default layout to be the static executable layout
// We would set the layout to a dynamic executable layout
// if we came across any shared libraries in the process
switch(info.getOutputType()) {
case llvm::ELF::ET_EXEC:
if (info.is64Bits()) {
if (info.isLittleEndian())
return std::unique_ptr<Writer>(new
elf::ExecutableWriter<ELFType<support::little, 8, true>>(info));
else
return std::unique_ptr<Writer>(new
elf::ExecutableWriter<ELFType<support::big, 8, true>>(info));
} else {
if (info.isLittleEndian())
return std::unique_ptr<Writer>(new
elf::ExecutableWriter<ELFType<support::little, 4, false>>(info));
else
return std::unique_ptr<Writer>(new
elf::ExecutableWriter<ELFType<support::big, 4, false>>(info));
}
break;
case llvm::ELF::ET_DYN:
if (info.is64Bits()) {
if (info.isLittleEndian())
return std::unique_ptr<Writer>(new
elf::DynamicLibraryWriter<ELFType<support::little, 8, true>>(info));
else
return std::unique_ptr<Writer>(new
elf::DynamicLibraryWriter<ELFType<support::big, 8, true>>(info));
} else {
if (info.isLittleEndian())
return std::unique_ptr<Writer>(new
elf::DynamicLibraryWriter<ELFType<support::little, 4, false>>(info));
else
return std::unique_ptr<Writer>(new
elf::DynamicLibraryWriter<ELFType<support::big, 4, false>>(info));
}
break;
case llvm::ELF::ET_REL:
llvm_unreachable("TODO: support -r mode");
default:
llvm_unreachable("unsupported output type");
}
}
} // namespace lld