Coverage Report

Created: 2017-09-21 03:39

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/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 "Error.h"
11
#include "Symbols.h"
12
#include "Target.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, uint32_t Type, uint64_t Val) const override;
26
  RelExpr getRelExpr(uint32_t Type, const SymbolBody &S, const InputFile &File,
27
                     const uint8_t *Loc) const override;
28
};
29
} // namespace
30
31
5
void PPC::relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const {
32
5
  switch (Type) {
33
1
  case R_PPC_ADDR16_HA:
34
1
    write16be(Loc, (Val + 0x8000) >> 16);
35
1
    break;
36
1
  case R_PPC_ADDR16_LO:
37
1
    write16be(Loc, Val);
38
1
    break;
39
2
  case R_PPC_ADDR32:
40
2
  case R_PPC_REL32:
41
2
    write32be(Loc, Val);
42
2
    break;
43
1
  case R_PPC_REL24:
44
1
    write32be(Loc, read32be(Loc) | (Val & 0x3FFFFFC));
45
1
    break;
46
0
  default:
47
0
    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
48
5
  }
49
5
}
50
51
RelExpr PPC::getRelExpr(uint32_t Type, const SymbolBody &S,
52
5
                        const InputFile &File, const uint8_t *Loc) const {
53
5
  switch (Type) {
54
2
  case R_PPC_REL24:
55
2
  case R_PPC_REL32:
56
2
    return R_PC;
57
3
  default:
58
3
    return R_ABS;
59
0
  }
60
0
}
61
62
2
TargetInfo *elf::getPPCTargetInfo() {
63
2
  static PPC Target;
64
2
  return &Target;
65
2
}