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 
getELFRelocationTypeName(uint32_t Machine,uint32_t Type)19 StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type) {
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     switch (Type) {
30 #include "llvm/Support/ELFRelocs/i386.def"
31     default:
32       break;
33     }
34     break;
35   case ELF::EM_MIPS:
36     switch (Type) {
37 #include "llvm/Support/ELFRelocs/Mips.def"
38     default:
39       break;
40     }
41     break;
42   case ELF::EM_AARCH64:
43     switch (Type) {
44 #include "llvm/Support/ELFRelocs/AArch64.def"
45     default:
46       break;
47     }
48     break;
49   case ELF::EM_ARM:
50     switch (Type) {
51 #include "llvm/Support/ELFRelocs/ARM.def"
52     default:
53       break;
54     }
55     break;
56   case ELF::EM_HEXAGON:
57     switch (Type) {
58 #include "llvm/Support/ELFRelocs/Hexagon.def"
59     default:
60       break;
61     }
62     break;
63   case ELF::EM_PPC:
64     switch (Type) {
65 #include "llvm/Support/ELFRelocs/PowerPC.def"
66     default:
67       break;
68     }
69     break;
70   case ELF::EM_PPC64:
71     switch (Type) {
72 #include "llvm/Support/ELFRelocs/PowerPC64.def"
73     default:
74       break;
75     }
76     break;
77   case ELF::EM_S390:
78     switch (Type) {
79 #include "llvm/Support/ELFRelocs/SystemZ.def"
80     default:
81       break;
82     }
83     break;
84   case ELF::EM_SPARC:
85   case ELF::EM_SPARC32PLUS:
86   case ELF::EM_SPARCV9:
87     switch (Type) {
88 #include "llvm/Support/ELFRelocs/Sparc.def"
89     default:
90       break;
91     }
92     break;
93   default:
94     break;
95   }
96   return "Unknown";
97 }
98 
99 #undef ELF_RELOC
100 
101 } // end namespace object
102 } // end namespace llvm
103