Coverage Report

Created: 2018-01-17 17:22

/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
2
  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;
28
};
29
} // namespace
30
31
RelExpr PPC::getRelExpr(RelType Type, const Symbol &S,
32
7
                        const uint8_t *Loc) const {
33
7
  switch (Type) {
34
7
  case R_PPC_REL24:
35
2
  case R_PPC_REL32:
36
2
    return R_PC;
37
2
  case R_PPC_PLTREL24:
38
1
    return R_PLT_PC;
39
4
  default:
40
4
    return R_ABS;
41
0
  }
42
0
}
43
44
7
void PPC::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
45
7
  switch (Type) {
46
7
  case R_PPC_ADDR16_HA:
47
1
    write16be(Loc, (Val + 0x8000) >> 16);
48
1
    break;
49
7
  case R_PPC_ADDR16_HI:
50
1
    write16be(Loc, Val >> 16);
51
1
    break;
52
7
  case R_PPC_ADDR16_LO:
53
1
    write16be(Loc, Val);
54
1
    break;
55
7
  case R_PPC_ADDR32:
56
2
  case R_PPC_REL32:
57
2
    write32be(Loc, Val);
58
2
    break;
59
2
  case R_PPC_PLTREL24:
60
2
  case R_PPC_REL24:
61
2
    write32be(Loc, read32be(Loc) | (Val & 0x3FFFFFC));
62
2
    break;
63
2
  default:
64
0
    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
65
7
  }
66
7
}
67
68
2
TargetInfo *elf::getPPCTargetInfo() {
69
2
  static PPC Target;
70
2
  return &Target;
71
2
}