Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/lld/ELF/Arch/AMDGPU.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- AMDGPU.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 "InputFiles.h"
12
#include "Symbols.h"
13
#include "Target.h"
14
#include "llvm/Object/ELF.h"
15
#include "llvm/Support/Endian.h"
16
17
using namespace llvm;
18
using namespace llvm::object;
19
using namespace llvm::support::endian;
20
using namespace llvm::ELF;
21
using namespace lld;
22
using namespace lld::elf;
23
24
namespace {
25
class AMDGPU final : public TargetInfo {
26
public:
27
  AMDGPU();
28
  void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
29
  RelExpr getRelExpr(uint32_t Type, const SymbolBody &S, const InputFile &File,
30
                     const uint8_t *Loc) const override;
31
};
32
} // namespace
33
34
3
AMDGPU::AMDGPU() {
35
3
  RelativeRel = R_AMDGPU_REL64;
36
3
  GotRel = R_AMDGPU_ABS64;
37
3
  GotEntrySize = 8;
38
3
}
39
40
24
void AMDGPU::relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const {
41
24
  switch (Type) {
42
18
  case R_AMDGPU_ABS32:
43
18
  case R_AMDGPU_GOTPCREL:
44
18
  case R_AMDGPU_GOTPCREL32_LO:
45
18
  case R_AMDGPU_REL32:
46
18
  case R_AMDGPU_REL32_LO:
47
18
    write32le(Loc, Val);
48
18
    break;
49
0
  case R_AMDGPU_ABS64:
50
0
    write64le(Loc, Val);
51
0
    break;
52
6
  case R_AMDGPU_GOTPCREL32_HI:
53
6
  case R_AMDGPU_REL32_HI:
54
6
    write32le(Loc, Val >> 32);
55
6
    break;
56
0
  default:
57
0
    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
58
24
  }
59
24
}
60
61
RelExpr AMDGPU::getRelExpr(uint32_t Type, const SymbolBody &S,
62
25
                           const InputFile &File, const uint8_t *Loc) const {
63
25
  switch (Type) {
64
7
  case R_AMDGPU_ABS32:
65
7
  case R_AMDGPU_ABS64:
66
7
    return R_ABS;
67
3
  case R_AMDGPU_REL32:
68
3
  case R_AMDGPU_REL32_LO:
69
3
  case R_AMDGPU_REL32_HI:
70
3
    return R_PC;
71
15
  case R_AMDGPU_GOTPCREL:
72
15
  case R_AMDGPU_GOTPCREL32_LO:
73
15
  case R_AMDGPU_GOTPCREL32_HI:
74
15
    return R_GOT_PC;
75
0
  default:
76
0
    error(toString(&File) + ": unknown relocation type: " + toString(Type));
77
0
    return R_HINT;
78
0
  }
79
0
}
80
81
3
TargetInfo *elf::getAMDGPUTargetInfo() {
82
3
  static AMDGPU Target;
83
3
  return &Target;
84
3
}