LLVM_TARGET(ARM)
LLVM_TARGET(Hexagon)
LLVM_TARGET(Mips)
-LLVM_TARGET(PPC)
LLVM_TARGET(X86)
LLVM_TARGET(X86_64)
lldARMELFTarget
lldHexagonELFTarget
lldMipsELFTarget
- lldPPCELFTarget
lldX86ELFTarget
lldX86_64ELFTarget
lldCore
LLVM_TARGET(ARM)
LLVM_TARGET(Hexagon)
LLVM_TARGET(Mips)
- LLVM_TARGET(PPC)
LLVM_TARGET(X86)
LLVM_TARGET(X86_64)
return nullptr;
add_subdirectory(X86)
add_subdirectory(X86_64)
-add_subdirectory(PPC)
add_subdirectory(Mips)
add_subdirectory(Hexagon)
add_subdirectory(AArch64)
CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLD_LEVEL)/lib/ReaderWriter/ELF
# these link against this lib
-PARALLEL_DIRS := Hexagon PPC X86 X86_64 Mips AArch64 ARM
+PARALLEL_DIRS := Hexagon X86 X86_64 Mips AArch64 ARM
include $(LLD_LEVEL)/Makefile
-##===- lld/lib/ReaderWriter/ELF/PPC/Makefile ----------*- Makefile -*-===##
+##===- lld/lib/ReaderWriter/ELF/Mips/Makefile ----------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
+++ /dev/null
-add_llvm_library(lldPPCELFTarget
- PPCLinkingContext.cpp
- PPCTargetHandler.cpp
- LINK_LIBS
- lldCore
- lldELF
- LLVMObject
- LLVMSupport
- )
+++ /dev/null
-##===- lld/lib/ReaderWriter/ELF/PPC/Makefile ----------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LLD_LEVEL := ../../../..
-LIBRARYNAME := lldPPCELFTarget
-USEDLIBS = lldCore.a
-CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLD_LEVEL)/lib/ReaderWriter/ELF
-
-include $(LLD_LEVEL)/Makefile
+++ /dev/null
-//===- lib/ReaderWriter/ELF/PPCELFFile.h -------------------------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLD_READER_WRITER_ELF_PPC_ELF_FILE_H
-#define LLD_READER_WRITER_ELF_PPC_ELF_FILE_H
-
-#include "ELFReader.h"
-
-namespace lld {
-namespace elf {
-
-class PPCLinkingContext;
-
-template <class ELFT> class PPCELFFile : public ELFFile<ELFT> {
-public:
- PPCELFFile(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings)
- : ELFFile<ELFT>(std::move(mb), atomizeStrings) {}
-
- static ErrorOr<std::unique_ptr<PPCELFFile>>
- create(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings) {
- return std::unique_ptr<PPCELFFile<ELFT>>(
- new PPCELFFile<ELFT>(std::move(mb), atomizeStrings));
- }
-};
-
-template <class ELFT> class PPCDynamicFile : public DynamicFile<ELFT> {
-public:
- PPCDynamicFile(const PPCLinkingContext &context, StringRef name)
- : DynamicFile<ELFT>(context, name) {}
-};
-
-} // elf
-} // lld
-
-#endif // LLD_READER_WRITER_ELF_PPC_ELF_FILE_H
+++ /dev/null
-//===- lib/ReaderWriter/ELF/PPC/PPCELFReader.h ----------------------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLD_READER_WRITER_PPC_PPC_ELF_READER_H
-#define LLD_READER_WRITER_PPC_PPC_ELF_READER_H
-
-#include "ELFReader.h"
-#include "PPCELFFile.h"
-
-namespace lld {
-namespace elf {
-
-typedef llvm::object::ELFType<llvm::support::big, 2, false> PPCELFType;
-
-struct PPCDynamicFileCreateELFTraits {
- typedef llvm::ErrorOr<std::unique_ptr<lld::SharedLibraryFile>> result_type;
-
- template <class ELFT>
- static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
- bool useUndefines) {
- return lld::elf::PPCDynamicFile<ELFT>::create(std::move(mb), useUndefines);
- }
-};
-
-struct PPCELFFileCreateELFTraits {
- typedef llvm::ErrorOr<std::unique_ptr<lld::File>> result_type;
-
- template <class ELFT>
- static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
- bool atomizeStrings) {
- return lld::elf::PPCELFFile<ELFT>::create(std::move(mb), atomizeStrings);
- }
-};
-
-class PPCELFObjectReader
- : public ELFObjectReader<PPCELFType, PPCELFFileCreateELFTraits> {
-public:
- PPCELFObjectReader(bool atomizeStrings)
- : ELFObjectReader<PPCELFType, PPCELFFileCreateELFTraits>(
- atomizeStrings, llvm::ELF::EM_PPC) {}
-};
-
-class PPCELFDSOReader
- : public ELFDSOReader<PPCELFType, PPCDynamicFileCreateELFTraits> {
-public:
- PPCELFDSOReader(bool useUndefines)
- : ELFDSOReader<PPCELFType, PPCDynamicFileCreateELFTraits>(
- useUndefines, llvm::ELF::EM_PPC) {}
-};
-
-} // namespace elf
-} // namespace lld
-
-#endif // LLD_READER_WRITER_PPC_PPC_ELF_READER_H
+++ /dev/null
-//===- lib/ReaderWriter/ELF/PPC/PPCLinkingContext.cpp ---------------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "PPCLinkingContext.h"
-#include "PPCTargetHandler.h"
-#include "lld/Core/LLVM.h"
-#include "llvm/ADT/StringSwitch.h"
-#include "llvm/Support/ErrorOr.h"
-
-using namespace lld;
-
-std::unique_ptr<ELFLinkingContext>
-elf::PPCLinkingContext::create(llvm::Triple triple) {
- if (triple.getArch() == llvm::Triple::ppc)
- return std::unique_ptr<ELFLinkingContext>(
- new elf::PPCLinkingContext(triple));
- return nullptr;
-}
-
-elf::PPCLinkingContext::PPCLinkingContext(llvm::Triple triple)
- : ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
- new PPCTargetHandler(*this))) {}
-
+++ /dev/null
-//===- lib/ReaderWriter/ELF/PPC/PPCLinkingContext.h -----------------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLD_READER_WRITER_ELF_PPC_PPC_LINKING_CONTEXT_H
-#define LLD_READER_WRITER_ELF_PPC_PPC_LINKING_CONTEXT_H
-
-#include "lld/ReaderWriter/ELFLinkingContext.h"
-#include "llvm/Object/ELF.h"
-#include "llvm/Support/ELF.h"
-
-namespace lld {
-namespace elf {
-
-class PPCLinkingContext final : public ELFLinkingContext {
-public:
- static std::unique_ptr<ELFLinkingContext> create(llvm::Triple);
- PPCLinkingContext(llvm::Triple triple);
-
- /// \brief PPC has no relative relocations defined
- bool isRelativeReloc(const Reference &) const override { return false; }
-};
-
-} // elf
-} // lld
-
-#endif // LLD_READER_WRITER_ELF_PPC_PPC_LINKING_CONTEXT_H
+++ /dev/null
-//===- lib/ReaderWriter/ELF/PPC/PPCTargetHandler.cpp ----------------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "PPCTargetHandler.h"
-#include "PPCLinkingContext.h"
-
-using namespace lld;
-using namespace elf;
-
-using namespace llvm::ELF;
-
-/// \brief The following relocation routines are derived from the
-/// SYSTEM V APPLICATION BINARY INTERFACE: PowerPC Processor Supplement
-/// Symbols used:
-/// A: Added used to compute the value, r_addend
-/// P: Place address of the field being relocated, r_offset
-/// S: Value of the symbol whose index resides in the relocation entry.
-
-/// \brief low24 (S + A - P) >> 2 : Verify
-static int relocB24PCREL(uint8_t *location, uint64_t P, uint64_t S,
- uint64_t A) {
- int32_t result = (uint32_t)(((S + A) - P));
- if ((result < 0x1000000) && (result > -0x1000000)) {
- result &= ~-(0x1000000);
- *reinterpret_cast<llvm::support::ubig32_t *>(location) = result |
- (uint32_t)*reinterpret_cast<llvm::support::ubig32_t *>(location);
- return 0;
- }
- return 1;
-}
-
-std::error_code PPCTargetRelocationHandler::applyRelocation(
- ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
- const Reference &ref) const {
- uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;
- uint8_t *location = atomContent + ref.offsetInAtom();
- uint64_t targetVAddress = writer.addressOfAtom(ref.target());
- uint64_t relocVAddress = atom._virtualAddr + ref.offsetInAtom();
-
- if (ref.kindNamespace() != Reference::KindNamespace::ELF)
- return std::error_code();
- assert(ref.kindArch() == Reference::KindArch::PowerPC);
- switch (ref.kindValue()) {
- case R_PPC_REL24:
- relocB24PCREL(location, relocVAddress, targetVAddress, ref.addend());
- break;
-
- default:
- return make_unhandled_reloc_error();
- }
-
- return std::error_code();
-}
-
-PPCTargetHandler::PPCTargetHandler(PPCLinkingContext &context)
- : _ppcLinkingContext(context),
- _ppcTargetLayout(new PPCTargetLayout<PPCELFType>(context)),
- _ppcRelocationHandler(new PPCTargetRelocationHandler()) {}
-
-void PPCTargetHandler::registerRelocationNames(Registry ®istry) {
- registry.addKindTable(Reference::KindNamespace::ELF,
- Reference::KindArch::PowerPC, kindStrings);
-}
-
-std::unique_ptr<Writer> PPCTargetHandler::getWriter() {
- switch (_ppcLinkingContext.getOutputELFType()) {
- case llvm::ELF::ET_EXEC:
- return std::unique_ptr<Writer>(new elf::ExecutableWriter<PPCELFType>(
- _ppcLinkingContext, *_ppcTargetLayout.get()));
- case llvm::ELF::ET_DYN:
- return std::unique_ptr<Writer>(new elf::DynamicLibraryWriter<PPCELFType>(
- _ppcLinkingContext, *_ppcTargetLayout.get()));
- case llvm::ELF::ET_REL:
- llvm_unreachable("TODO: support -r mode");
- default:
- llvm_unreachable("unsupported output type");
- }
-}
-
-#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
-
-const Registry::KindStrings PPCTargetHandler::kindStrings[] = {
-#include "llvm/Support/ELFRelocs/PowerPC.def"
- LLD_KIND_STRING_END
-};
-
-#undef ELF_RELOC
+++ /dev/null
-//===- lib/ReaderWriter/ELF/PPC/PPCTargetHandler.h ------------------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLD_READER_WRITER_ELF_PPC_PPC_TARGET_HANDLER_H
-#define LLD_READER_WRITER_ELF_PPC_PPC_TARGET_HANDLER_H
-
-#include "DefaultTargetHandler.h"
-#include "PPCELFReader.h"
-#include "TargetLayout.h"
-
-namespace lld {
-namespace elf {
-class PPCLinkingContext;
-
-template <class ELFT> class PPCTargetLayout : public TargetLayout<ELFT> {
-public:
- PPCTargetLayout(PPCLinkingContext &context) : TargetLayout<ELFT>(context) {}
-};
-
-class PPCTargetRelocationHandler final : public TargetRelocationHandler {
-public:
- std::error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
- const lld::AtomLayout &,
- const Reference &) const override;
-};
-
-class PPCTargetHandler final
- : public DefaultTargetHandler<PPCELFType> {
-public:
- PPCTargetHandler(PPCLinkingContext &context);
-
- PPCTargetLayout<PPCELFType> &getTargetLayout() override {
- return *(_ppcTargetLayout.get());
- }
-
- void registerRelocationNames(Registry ®istry) override;
-
- const PPCTargetRelocationHandler &getRelocationHandler() const override {
- return *(_ppcRelocationHandler.get());
- }
-
- std::unique_ptr<Reader> getObjReader(bool atomizeStrings) override {
- return std::unique_ptr<Reader>(new PPCELFObjectReader(atomizeStrings));
- }
-
- std::unique_ptr<Reader> getDSOReader(bool useShlibUndefines) override {
- return std::unique_ptr<Reader>(new PPCELFDSOReader(useShlibUndefines));
- }
-
- std::unique_ptr<Writer> getWriter() override;
-
-private:
- static const Registry::KindStrings kindStrings[];
- PPCLinkingContext &_ppcLinkingContext;
- std::unique_ptr<PPCTargetLayout<PPCELFType>> _ppcTargetLayout;
- std::unique_ptr<PPCTargetRelocationHandler> _ppcRelocationHandler;
-};
-} // end namespace elf
-} // end namespace lld
-
-#endif
+++ /dev/null
-RUN: lld -flavor gnu -target powerpc %p/Inputs/branch-test.ppc %p/Inputs/target-test.ppc -o %t1 --noinhibit-exec
-RUN: llvm-readobj -h %t1 | FileCheck -check-prefix=ppc-readobj %s
-
-
-ppc-readobj: ElfHeader {
-ppc-readobj: Ident {
-ppc-readobj: Class: 32-bit (0x1)
-ppc-readobj: DataEncoding: BigEndian (0x2)
-ppc-readobj: FileVersion: 1
-ppc-readobj: OS/ABI: SystemV (0x0)
-ppc-readobj: ABIVersion: 0
-ppc-readobj: }
-ppc-readobj: Type: Executable (0x2)
-ppc-readobj: Machine: EM_PPC (0x14)
USEDLIBS = lldDriver.a lldConfig.a \
lldELF.a lldMachO.a lldPasses.a lldPECOFF.a lldYAML.a \
lldReaderWriter.a lldCore.a lldNative.a \
- lldHexagonELFTarget.a lldPPCELFTarget.a lldMipsELFTarget.a \
+ lldHexagonELFTarget.a lldMipsELFTarget.a \
lldX86ELFTarget.a lldX86_64ELFTarget.a lldAArch64ELFTarget.a \
lldARMELFTarget.a \
LLVMOption.a