Files
clang-p2996/lld/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp
Simon Atanasyan 663aa62863 [Mips] Set default base address for MIPS executables to 0x400000. Assign
the lowest segment address to the MIPS_BASE_ADDRESS dynamic tag.

llvm-svn: 199234
2014-01-14 18:19:12 +00:00

55 lines
1.7 KiB
C++

//===- lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp -------------------===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "Atoms.h"
#include "MipsLinkingContext.h"
#include "MipsRelocationPass.h"
#include "MipsTargetHandler.h"
using namespace lld;
using namespace lld::elf;
MipsLinkingContext::MipsLinkingContext(llvm::Triple triple)
: ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
new MipsTargetHandler(*this))) {}
MipsTargetLayout<Mips32ElELFType> &MipsLinkingContext::getTargetLayout() {
auto &layout = getTargetHandler<Mips32ElELFType>().targetLayout();
return static_cast<MipsTargetLayout<Mips32ElELFType> &>(layout);
}
const MipsTargetLayout<Mips32ElELFType> &
MipsLinkingContext::getTargetLayout() const {
auto &layout = getTargetHandler<Mips32ElELFType>().targetLayout();
return static_cast<MipsTargetLayout<Mips32ElELFType> &>(layout);
}
bool MipsLinkingContext::isLittleEndian() const {
return Mips32ElELFType::TargetEndianness == llvm::support::little;
}
uint64_t MipsLinkingContext::getBaseAddress() const {
if (_baseAddress == 0 && getOutputELFType() == llvm::ELF::ET_EXEC)
return 0x400000;
return _baseAddress;
}
StringRef MipsLinkingContext::entrySymbolName() const {
if (_outputELFType == elf::ET_EXEC && _entrySymbolName.empty())
return "__start";
return _entrySymbolName;
}
void MipsLinkingContext::addPasses(PassManager &pm) {
auto pass = createMipsRelocationPass(*this);
if (pass)
pm.add(std::move(pass));
ELFLinkingContext::addPasses(pm);
}