Files
clang-p2996/lld/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp
Rui Ueyama bba452f23e ELF: Remove partial class definitions of <Arch>LinkingContexts.
What we are doing in ELFTarget.h was dubious. In the file, we define
partial classes of <Arch>LinkingContexts to declare only static member
functions. We have different (complete) class definitions in other files.
They would conflict if they exist in the same compilation unit (because
the ones defined in ELFTarget.h has only static member functions).
I don't think this was valid C++.

http://reviews.llvm.org/D8797

llvm-svn: 234039
2015-04-03 19:32:31 +00:00

65 lines
1.8 KiB
C++

//===--------- lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp -------------===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "ARMLinkingContext.h"
#include "ARMRelocationPass.h"
#include "ARMTargetHandler.h"
namespace lld {
namespace elf {
std::unique_ptr<ELFLinkingContext>
createARMLinkingContext(llvm::Triple triple) {
if (triple.getArch() == llvm::Triple::arm)
return llvm::make_unique<ARMLinkingContext>(triple);
return nullptr;
}
ARMLinkingContext::ARMLinkingContext(llvm::Triple triple)
: ELFLinkingContext(triple, llvm::make_unique<ARMTargetHandler>(*this)) {}
void ARMLinkingContext::addPasses(PassManager &pm) {
auto pass = createARMRelocationPass(*this);
if (pass)
pm.add(std::move(pass));
ELFLinkingContext::addPasses(pm);
}
bool isARMCode(const DefinedAtom *atom) {
return isARMCode(atom->codeModel());
}
bool isARMCode(DefinedAtom::CodeModel codeModel) {
return !isThumbCode(codeModel);
}
bool isThumbCode(const DefinedAtom *atom) {
return isThumbCode(atom->codeModel());
}
bool isThumbCode(DefinedAtom::CodeModel codeModel) {
return codeModel == DefinedAtom::codeARMThumb ||
codeModel == DefinedAtom::codeARM_t;
}
static const Registry::KindStrings kindStrings[] = {
#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
#include "llvm/Support/ELFRelocs/ARM.def"
#undef ELF_RELOC
LLD_KIND_STRING_END
};
void ARMLinkingContext::registerRelocationNames(Registry &registry) {
registry.addKindTable(Reference::KindNamespace::ELF, Reference::KindArch::ARM,
kindStrings);
}
} // namespace elf
} // namespace lld