1 //===- PPC.cpp ------------------------------------------------------------===//
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 #include "lld/Common/ErrorHandler.h"
13 #include "llvm/Support/Endian.h"
16 using namespace llvm::support::endian;
17 using namespace llvm::ELF;
19 using namespace lld::elf;
22 class PPC final : public TargetInfo {
25 void relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const override;
26 RelExpr getRelExpr(RelType Type, const Symbol &S,
27 const uint8_t *Loc) const override;
33 GotBaseSymOff = 0x8000;
34 GotBaseSymInGotPlt = false;
37 RelExpr PPC::getRelExpr(RelType Type, const Symbol &S,
38 const uint8_t *Loc) const {
51 void PPC::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
54 write16be(Loc, (Val + 0x8000) >> 16);
57 write16be(Loc, Val >> 16);
67 write32be(Loc, read32be(Loc) | (Val & 0xFFFC));
71 write32be(Loc, read32be(Loc) | (Val & 0x3FFFFFC));
74 error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
78 TargetInfo *elf::getPPCTargetInfo() {