LLVM  4.0.0
ELF.cpp
Go to the documentation of this file.
1 //===- ELF.cpp - ELF object file implementation -----------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
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 "llvm/Object/ELF.h"
11 
12 namespace llvm {
13 namespace object {
14 
15 #define ELF_RELOC(name, value) \
16  case ELF::name: \
17  return #name; \
18 
20  switch (Machine) {
21  case ELF::EM_X86_64:
22  switch (Type) {
23 #include "llvm/Support/ELFRelocs/x86_64.def"
24  default:
25  break;
26  }
27  break;
28  case ELF::EM_386:
29  case ELF::EM_IAMCU:
30  switch (Type) {
31 #include "llvm/Support/ELFRelocs/i386.def"
32  default:
33  break;
34  }
35  break;
36  case ELF::EM_MIPS:
37  switch (Type) {
38 #include "llvm/Support/ELFRelocs/Mips.def"
39  default:
40  break;
41  }
42  break;
43  case ELF::EM_AARCH64:
44  switch (Type) {
45 #include "llvm/Support/ELFRelocs/AArch64.def"
46  default:
47  break;
48  }
49  break;
50  case ELF::EM_ARM:
51  switch (Type) {
52 #include "llvm/Support/ELFRelocs/ARM.def"
53  default:
54  break;
55  }
56  break;
57  case ELF::EM_AVR:
58  switch (Type) {
59 #include "llvm/Support/ELFRelocs/AVR.def"
60  default:
61  break;
62  }
63  break;
64  case ELF::EM_HEXAGON:
65  switch (Type) {
66 #include "llvm/Support/ELFRelocs/Hexagon.def"
67  default:
68  break;
69  }
70  break;
71  case ELF::EM_LANAI:
72  switch (Type) {
73 #include "llvm/Support/ELFRelocs/Lanai.def"
74  default:
75  break;
76  }
77  break;
78  case ELF::EM_PPC:
79  switch (Type) {
80 #include "llvm/Support/ELFRelocs/PowerPC.def"
81  default:
82  break;
83  }
84  break;
85  case ELF::EM_PPC64:
86  switch (Type) {
87 #include "llvm/Support/ELFRelocs/PowerPC64.def"
88  default:
89  break;
90  }
91  break;
92  case ELF::EM_RISCV:
93  switch (Type) {
94 #include "llvm/Support/ELFRelocs/RISCV.def"
95  default:
96  break;
97  }
98  break;
99  case ELF::EM_S390:
100  switch (Type) {
101 #include "llvm/Support/ELFRelocs/SystemZ.def"
102  default:
103  break;
104  }
105  break;
106  case ELF::EM_SPARC:
107  case ELF::EM_SPARC32PLUS:
108  case ELF::EM_SPARCV9:
109  switch (Type) {
110 #include "llvm/Support/ELFRelocs/Sparc.def"
111  default:
112  break;
113  }
114  break;
115  case ELF::EM_WEBASSEMBLY:
116  switch (Type) {
117 #include "llvm/Support/ELFRelocs/WebAssembly.def"
118  default:
119  break;
120  }
121  break;
122  case ELF::EM_AMDGPU:
123  switch (Type) {
124 #include "llvm/Support/ELFRelocs/AMDGPU.def"
125  default:
126  break;
127  }
128  case ELF::EM_BPF:
129  switch (Type) {
130 #include "llvm/Support/ELFRelocs/BPF.def"
131  default:
132  break;
133  }
134  break;
135  default:
136  break;
137  }
138  return "Unknown";
139 }
140 
141 #undef ELF_RELOC
142 
143 } // end namespace object
144 } // end namespace llvm
COFF::MachineTypes Machine
Definition: COFFYAML.cpp:303
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type)
Definition: ELF.cpp:19
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47