summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/ELF/PPC/PPCLinkingContext.cpp
blob: 0b397eaa26a9f6d022e3594b7822be568f6b2e0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "PPCLinkingContext.h"

#include "lld/Core/LLVM.h"

#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/ErrorOr.h"

using namespace lld;

#define LLD_CASE(name) .Case(#name, llvm::ELF::name)

ErrorOr<Reference::Kind>
elf::PPCLinkingContext::relocKindFromString(StringRef str) const {
  int32_t ret = llvm::StringSwitch<int32_t>(str) LLD_CASE(R_PPC_NONE)
      LLD_CASE(R_PPC_ADDR32).Default(-1);

  if (ret == -1)
    return make_error_code(YamlReaderError::illegal_value);
  return ret;
}

#undef LLD_CASE

#define LLD_CASE(name)                                                         \
  case llvm::ELF::name:                                                        \
  return std::string(#name);

ErrorOr<std::string>
elf::PPCLinkingContext::stringFromRelocKind(Reference::Kind kind) const {
  switch (kind) {
    LLD_CASE(R_PPC_NONE)
    LLD_CASE(R_PPC_ADDR32)
  }

  return make_error_code(YamlReaderError::illegal_value);
}
OpenPOWER on IntegriCloud