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)19StringRef 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_LANAI: 65 switch (Type) { 66 #include "llvm/Support/ELFRelocs/Lanai.def" 67 default: 68 break; 69 } 70 break; 71 case ELF::EM_PPC: 72 switch (Type) { 73 #include "llvm/Support/ELFRelocs/PowerPC.def" 74 default: 75 break; 76 } 77 break; 78 case ELF::EM_PPC64: 79 switch (Type) { 80 #include "llvm/Support/ELFRelocs/PowerPC64.def" 81 default: 82 break; 83 } 84 break; 85 case ELF::EM_S390: 86 switch (Type) { 87 #include "llvm/Support/ELFRelocs/SystemZ.def" 88 default: 89 break; 90 } 91 break; 92 case ELF::EM_SPARC: 93 case ELF::EM_SPARC32PLUS: 94 case ELF::EM_SPARCV9: 95 switch (Type) { 96 #include "llvm/Support/ELFRelocs/Sparc.def" 97 default: 98 break; 99 } 100 break; 101 case ELF::EM_WEBASSEMBLY: 102 switch (Type) { 103 #include "llvm/Support/ELFRelocs/WebAssembly.def" 104 default: 105 break; 106 } 107 break; 108 case ELF::EM_AMDGPU: 109 switch (Type) { 110 #include "llvm/Support/ELFRelocs/AMDGPU.def" 111 default: 112 break; 113 } 114 break; 115 default: 116 break; 117 } 118 return "Unknown"; 119 } 120 121 #undef ELF_RELOC 122 123 } // end namespace object 124 } // end namespace llvm 125