• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   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_HEXAGON:
58     switch (Type) {
59 #include "llvm/Support/ELFRelocs/Hexagon.def"
60     default:
61       break;
62     }
63     break;
64   case ELF::EM_PPC:
65     switch (Type) {
66 #include "llvm/Support/ELFRelocs/PowerPC.def"
67     default:
68       break;
69     }
70     break;
71   case ELF::EM_PPC64:
72     switch (Type) {
73 #include "llvm/Support/ELFRelocs/PowerPC64.def"
74     default:
75       break;
76     }
77     break;
78   case ELF::EM_S390:
79     switch (Type) {
80 #include "llvm/Support/ELFRelocs/SystemZ.def"
81     default:
82       break;
83     }
84     break;
85   case ELF::EM_SPARC:
86   case ELF::EM_SPARC32PLUS:
87   case ELF::EM_SPARCV9:
88     switch (Type) {
89 #include "llvm/Support/ELFRelocs/Sparc.def"
90     default:
91       break;
92     }
93     break;
94   default:
95     break;
96   }
97   return "Unknown";
98 }
99 
100 #undef ELF_RELOC
101 
102 } // end namespace object
103 } // end namespace llvm
104