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 {
24 PPC() { GotBaseSymOff = 0x8000; }
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;
31 RelExpr PPC::getRelExpr(RelType Type, const Symbol &S,
32 const uint8_t *Loc) const {
44 void PPC::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
47 write16be(Loc, (Val + 0x8000) >> 16);
50 write16be(Loc, Val >> 16);
61 write32be(Loc, read32be(Loc) | (Val & 0x3FFFFFC));
64 error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
68 TargetInfo *elf::getPPCTargetInfo() {