Coverage Report

Created: 2018-10-23 15:26

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/ELF/Arch/PPC.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- PPC.cpp ------------------------------------------------------------===//
2
//
3
//                             The LLVM Linker
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#include "Symbols.h"
11
#include "Target.h"
12
#include "lld/Common/ErrorHandler.h"
13
#include "llvm/Support/Endian.h"
14
15
using namespace llvm;
16
using namespace llvm::support::endian;
17
using namespace llvm::ELF;
18
using namespace lld;
19
using namespace lld::elf;
20
21
namespace {
22
class PPC final : public TargetInfo {
23
public:
24
  PPC();
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;
28
};
29
} // namespace
30
31
3
PPC::PPC() {
32
3
  NoneRel = R_PPC_NONE;
33
3
  GotBaseSymOff = 0x8000;
34
3
  GotBaseSymInGotPlt = false;
35
3
}
36
37
RelExpr PPC::getRelExpr(RelType Type, const Symbol &S,
38
8
                        const uint8_t *Loc) const {
39
8
  switch (Type) {
40
8
  case R_PPC_REL24:
41
2
  case R_PPC_REL32:
42
2
    return R_PC;
43
2
  case R_PPC_PLTREL24:
44
1
    return R_PLT_PC;
45
5
  default:
46
5
    return R_ABS;
47
8
  }
48
8
}
49
50
7
void PPC::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
51
7
  switch (Type) {
52
7
  case R_PPC_ADDR16_HA:
53
1
    write16be(Loc, (Val + 0x8000) >> 16);
54
1
    break;
55
7
  case R_PPC_ADDR16_HI:
56
1
    write16be(Loc, Val >> 16);
57
1
    break;
58
7
  case R_PPC_ADDR16_LO:
59
1
    write16be(Loc, Val);
60
1
    break;
61
7
  case R_PPC_ADDR32:
62
2
  case R_PPC_REL32:
63
2
    write32be(Loc, Val);
64
2
    break;
65
2
  case R_PPC_PLTREL24:
66
2
  case R_PPC_REL24:
67
2
    write32be(Loc, read32be(Loc) | (Val & 0x3FFFFFC));
68
2
    break;
69
2
  default:
70
0
    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
71
7
  }
72
7
}
73
74
3
TargetInfo *elf::getPPCTargetInfo() {
75
3
  static PPC Target;
76
3
  return &Target;
77
3
}