From 7a3eed6d22b235433aa7e69919c5333cf2a60c5d Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Fri, 21 Nov 2014 20:16:09 +0000 Subject: [PATCH] Remove duplication of relocation names in lib/Object/ELFYAML.cpp We can now use the ELF relocation .def files to create the mapping of relocation numbers to names and avoid having to duplicate the list of relocations. Patch by Will Newton. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222567 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Object/ELFYAML.cpp | 337 +---------------------------------------- 1 file changed, 7 insertions(+), 330 deletions(-) diff --git a/lib/Object/ELFYAML.cpp b/lib/Object/ELFYAML.cpp index f513c11e1f1..06ac6a5bf50 100644 --- a/lib/Object/ELFYAML.cpp +++ b/lib/Object/ELFYAML.cpp @@ -418,350 +418,27 @@ void ScalarEnumerationTraits::enumeration( IO &IO, ELFYAML::ELF_REL &Value) { const auto *Object = static_cast(IO.getContext()); assert(Object && "The IO context is not initialized"); -#define ECase(X) IO.enumCase(Value, #X, ELF::X); +#define ELF_RELOC(X, Y) IO.enumCase(Value, #X, ELF::X); switch (Object->Header.Machine) { case ELF::EM_X86_64: - ECase(R_X86_64_NONE) - ECase(R_X86_64_64) - ECase(R_X86_64_PC32) - ECase(R_X86_64_GOT32) - ECase(R_X86_64_PLT32) - ECase(R_X86_64_COPY) - ECase(R_X86_64_GLOB_DAT) - ECase(R_X86_64_JUMP_SLOT) - ECase(R_X86_64_RELATIVE) - ECase(R_X86_64_GOTPCREL) - ECase(R_X86_64_32) - ECase(R_X86_64_32S) - ECase(R_X86_64_16) - ECase(R_X86_64_PC16) - ECase(R_X86_64_8) - ECase(R_X86_64_PC8) - ECase(R_X86_64_DTPMOD64) - ECase(R_X86_64_DTPOFF64) - ECase(R_X86_64_TPOFF64) - ECase(R_X86_64_TLSGD) - ECase(R_X86_64_TLSLD) - ECase(R_X86_64_DTPOFF32) - ECase(R_X86_64_GOTTPOFF) - ECase(R_X86_64_TPOFF32) - ECase(R_X86_64_PC64) - ECase(R_X86_64_GOTOFF64) - ECase(R_X86_64_GOTPC32) - ECase(R_X86_64_GOT64) - ECase(R_X86_64_GOTPCREL64) - ECase(R_X86_64_GOTPC64) - ECase(R_X86_64_GOTPLT64) - ECase(R_X86_64_PLTOFF64) - ECase(R_X86_64_SIZE32) - ECase(R_X86_64_SIZE64) - ECase(R_X86_64_GOTPC32_TLSDESC) - ECase(R_X86_64_TLSDESC_CALL) - ECase(R_X86_64_TLSDESC) - ECase(R_X86_64_IRELATIVE) +#include "llvm/Support/ELFRelocs/x86_64.def" break; case ELF::EM_MIPS: - ECase(R_MIPS_NONE) - ECase(R_MIPS_16) - ECase(R_MIPS_32) - ECase(R_MIPS_REL32) - ECase(R_MIPS_26) - ECase(R_MIPS_HI16) - ECase(R_MIPS_LO16) - ECase(R_MIPS_GPREL16) - ECase(R_MIPS_LITERAL) - ECase(R_MIPS_GOT16) - ECase(R_MIPS_PC16) - ECase(R_MIPS_CALL16) - ECase(R_MIPS_GPREL32) - ECase(R_MIPS_UNUSED1) - ECase(R_MIPS_UNUSED2) - ECase(R_MIPS_SHIFT5) - ECase(R_MIPS_SHIFT6) - ECase(R_MIPS_64) - ECase(R_MIPS_GOT_DISP) - ECase(R_MIPS_GOT_PAGE) - ECase(R_MIPS_GOT_OFST) - ECase(R_MIPS_GOT_HI16) - ECase(R_MIPS_GOT_LO16) - ECase(R_MIPS_SUB) - ECase(R_MIPS_INSERT_A) - ECase(R_MIPS_INSERT_B) - ECase(R_MIPS_DELETE) - ECase(R_MIPS_HIGHER) - ECase(R_MIPS_HIGHEST) - ECase(R_MIPS_CALL_HI16) - ECase(R_MIPS_CALL_LO16) - ECase(R_MIPS_SCN_DISP) - ECase(R_MIPS_REL16) - ECase(R_MIPS_ADD_IMMEDIATE) - ECase(R_MIPS_PJUMP) - ECase(R_MIPS_RELGOT) - ECase(R_MIPS_JALR) - ECase(R_MIPS_TLS_DTPMOD32) - ECase(R_MIPS_TLS_DTPREL32) - ECase(R_MIPS_TLS_DTPMOD64) - ECase(R_MIPS_TLS_DTPREL64) - ECase(R_MIPS_TLS_GD) - ECase(R_MIPS_TLS_LDM) - ECase(R_MIPS_TLS_DTPREL_HI16) - ECase(R_MIPS_TLS_DTPREL_LO16) - ECase(R_MIPS_TLS_GOTTPREL) - ECase(R_MIPS_TLS_TPREL32) - ECase(R_MIPS_TLS_TPREL64) - ECase(R_MIPS_TLS_TPREL_HI16) - ECase(R_MIPS_TLS_TPREL_LO16) - ECase(R_MIPS_GLOB_DAT) - ECase(R_MIPS_PC21_S2) - ECase(R_MIPS_PC26_S2) - ECase(R_MIPS_PC18_S3) - ECase(R_MIPS_PC19_S2) - ECase(R_MIPS_PCHI16) - ECase(R_MIPS_PCLO16) - ECase(R_MIPS16_GOT16) - ECase(R_MIPS16_HI16) - ECase(R_MIPS16_LO16) - ECase(R_MIPS_COPY) - ECase(R_MIPS_JUMP_SLOT) - ECase(R_MICROMIPS_26_S1) - ECase(R_MICROMIPS_HI16) - ECase(R_MICROMIPS_LO16) - ECase(R_MICROMIPS_GOT16) - ECase(R_MICROMIPS_PC16_S1) - ECase(R_MICROMIPS_CALL16) - ECase(R_MICROMIPS_GOT_DISP) - ECase(R_MICROMIPS_GOT_PAGE) - ECase(R_MICROMIPS_GOT_OFST) - ECase(R_MICROMIPS_TLS_GD) - ECase(R_MICROMIPS_TLS_LDM) - ECase(R_MICROMIPS_TLS_DTPREL_HI16) - ECase(R_MICROMIPS_TLS_DTPREL_LO16) - ECase(R_MICROMIPS_TLS_TPREL_HI16) - ECase(R_MICROMIPS_TLS_TPREL_LO16) - ECase(R_MIPS_NUM) - ECase(R_MIPS_PC32) +#include "llvm/Support/ELFRelocs/Mips.def" break; case ELF::EM_HEXAGON: - ECase(R_HEX_NONE) - ECase(R_HEX_B22_PCREL) - ECase(R_HEX_B15_PCREL) - ECase(R_HEX_B7_PCREL) - ECase(R_HEX_LO16) - ECase(R_HEX_HI16) - ECase(R_HEX_32) - ECase(R_HEX_16) - ECase(R_HEX_8) - ECase(R_HEX_GPREL16_0) - ECase(R_HEX_GPREL16_1) - ECase(R_HEX_GPREL16_2) - ECase(R_HEX_GPREL16_3) - ECase(R_HEX_HL16) - ECase(R_HEX_B13_PCREL) - ECase(R_HEX_B9_PCREL) - ECase(R_HEX_B32_PCREL_X) - ECase(R_HEX_32_6_X) - ECase(R_HEX_B22_PCREL_X) - ECase(R_HEX_B15_PCREL_X) - ECase(R_HEX_B13_PCREL_X) - ECase(R_HEX_B9_PCREL_X) - ECase(R_HEX_B7_PCREL_X) - ECase(R_HEX_16_X) - ECase(R_HEX_12_X) - ECase(R_HEX_11_X) - ECase(R_HEX_10_X) - ECase(R_HEX_9_X) - ECase(R_HEX_8_X) - ECase(R_HEX_7_X) - ECase(R_HEX_6_X) - ECase(R_HEX_32_PCREL) - ECase(R_HEX_COPY) - ECase(R_HEX_GLOB_DAT) - ECase(R_HEX_JMP_SLOT) - ECase(R_HEX_RELATIVE) - ECase(R_HEX_PLT_B22_PCREL) - ECase(R_HEX_GOTREL_LO16) - ECase(R_HEX_GOTREL_HI16) - ECase(R_HEX_GOTREL_32) - ECase(R_HEX_GOT_LO16) - ECase(R_HEX_GOT_HI16) - ECase(R_HEX_GOT_32) - ECase(R_HEX_GOT_16) - ECase(R_HEX_DTPMOD_32) - ECase(R_HEX_DTPREL_LO16) - ECase(R_HEX_DTPREL_HI16) - ECase(R_HEX_DTPREL_32) - ECase(R_HEX_DTPREL_16) - ECase(R_HEX_GD_PLT_B22_PCREL) - ECase(R_HEX_GD_GOT_LO16) - ECase(R_HEX_GD_GOT_HI16) - ECase(R_HEX_GD_GOT_32) - ECase(R_HEX_GD_GOT_16) - ECase(R_HEX_IE_LO16) - ECase(R_HEX_IE_HI16) - ECase(R_HEX_IE_32) - ECase(R_HEX_IE_GOT_LO16) - ECase(R_HEX_IE_GOT_HI16) - ECase(R_HEX_IE_GOT_32) - ECase(R_HEX_IE_GOT_16) - ECase(R_HEX_TPREL_LO16) - ECase(R_HEX_TPREL_HI16) - ECase(R_HEX_TPREL_32) - ECase(R_HEX_TPREL_16) - ECase(R_HEX_6_PCREL_X) - ECase(R_HEX_GOTREL_32_6_X) - ECase(R_HEX_GOTREL_16_X) - ECase(R_HEX_GOTREL_11_X) - ECase(R_HEX_GOT_32_6_X) - ECase(R_HEX_GOT_16_X) - ECase(R_HEX_GOT_11_X) - ECase(R_HEX_DTPREL_32_6_X) - ECase(R_HEX_DTPREL_16_X) - ECase(R_HEX_DTPREL_11_X) - ECase(R_HEX_GD_GOT_32_6_X) - ECase(R_HEX_GD_GOT_16_X) - ECase(R_HEX_GD_GOT_11_X) - ECase(R_HEX_IE_32_6_X) - ECase(R_HEX_IE_16_X) - ECase(R_HEX_IE_GOT_32_6_X) - ECase(R_HEX_IE_GOT_16_X) - ECase(R_HEX_IE_GOT_11_X) - ECase(R_HEX_TPREL_32_6_X) - ECase(R_HEX_TPREL_16_X) - ECase(R_HEX_TPREL_11_X) +#include "llvm/Support/ELFRelocs/Hexagon.def" break; case ELF::EM_386: - ECase(R_386_NONE) - ECase(R_386_32) - ECase(R_386_PC32) - ECase(R_386_GOT32) - ECase(R_386_PLT32) - ECase(R_386_COPY) - ECase(R_386_GLOB_DAT) - ECase(R_386_JUMP_SLOT) - ECase(R_386_RELATIVE) - ECase(R_386_GOTOFF) - ECase(R_386_GOTPC) - ECase(R_386_32PLT) - ECase(R_386_TLS_TPOFF) - ECase(R_386_TLS_IE) - ECase(R_386_TLS_GOTIE) - ECase(R_386_TLS_LE) - ECase(R_386_TLS_GD) - ECase(R_386_TLS_LDM) - ECase(R_386_16) - ECase(R_386_PC16) - ECase(R_386_8) - ECase(R_386_PC8) - ECase(R_386_TLS_GD_32) - ECase(R_386_TLS_GD_PUSH) - ECase(R_386_TLS_GD_CALL) - ECase(R_386_TLS_GD_POP) - ECase(R_386_TLS_LDM_32) - ECase(R_386_TLS_LDM_PUSH) - ECase(R_386_TLS_LDM_CALL) - ECase(R_386_TLS_LDM_POP) - ECase(R_386_TLS_LDO_32) - ECase(R_386_TLS_IE_32) - ECase(R_386_TLS_LE_32) - ECase(R_386_TLS_DTPMOD32) - ECase(R_386_TLS_DTPOFF32) - ECase(R_386_TLS_TPOFF32) - ECase(R_386_TLS_GOTDESC) - ECase(R_386_TLS_DESC_CALL) - ECase(R_386_TLS_DESC) - ECase(R_386_IRELATIVE) - ECase(R_386_NUM) +#include "llvm/Support/ELFRelocs/i386.def" break; case ELF::EM_AARCH64: - ECase(R_AARCH64_NONE) - ECase(R_AARCH64_ABS64) - ECase(R_AARCH64_ABS32) - ECase(R_AARCH64_ABS16) - ECase(R_AARCH64_PREL64) - ECase(R_AARCH64_PREL32) - ECase(R_AARCH64_PREL16) - ECase(R_AARCH64_MOVW_UABS_G0) - ECase(R_AARCH64_MOVW_UABS_G0_NC) - ECase(R_AARCH64_MOVW_UABS_G1) - ECase(R_AARCH64_MOVW_UABS_G1_NC) - ECase(R_AARCH64_MOVW_UABS_G2) - ECase(R_AARCH64_MOVW_UABS_G2_NC) - ECase(R_AARCH64_MOVW_UABS_G3) - ECase(R_AARCH64_MOVW_SABS_G0) - ECase(R_AARCH64_MOVW_SABS_G1) - ECase(R_AARCH64_MOVW_SABS_G2) - ECase(R_AARCH64_LD_PREL_LO19) - ECase(R_AARCH64_ADR_PREL_LO21) - ECase(R_AARCH64_ADR_PREL_PG_HI21) - ECase(R_AARCH64_ADD_ABS_LO12_NC) - ECase(R_AARCH64_LDST8_ABS_LO12_NC) - ECase(R_AARCH64_TSTBR14) - ECase(R_AARCH64_CONDBR19) - ECase(R_AARCH64_JUMP26) - ECase(R_AARCH64_CALL26) - ECase(R_AARCH64_LDST16_ABS_LO12_NC) - ECase(R_AARCH64_LDST32_ABS_LO12_NC) - ECase(R_AARCH64_LDST64_ABS_LO12_NC) - ECase(R_AARCH64_LDST128_ABS_LO12_NC) - ECase(R_AARCH64_GOTREL64) - ECase(R_AARCH64_GOTREL32) - ECase(R_AARCH64_ADR_GOT_PAGE) - ECase(R_AARCH64_LD64_GOT_LO12_NC) - ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G2) - ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G1) - ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC) - ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G0) - ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC) - ECase(R_AARCH64_TLSLD_ADD_DTPREL_HI12) - ECase(R_AARCH64_TLSLD_ADD_DTPREL_LO12) - ECase(R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC) - ECase(R_AARCH64_TLSLD_LDST8_DTPREL_LO12) - ECase(R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC) - ECase(R_AARCH64_TLSLD_LDST16_DTPREL_LO12) - ECase(R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC) - ECase(R_AARCH64_TLSLD_LDST32_DTPREL_LO12) - ECase(R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC) - ECase(R_AARCH64_TLSLD_LDST64_DTPREL_LO12) - ECase(R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC) - ECase(R_AARCH64_TLSIE_MOVW_GOTTPREL_G1) - ECase(R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC) - ECase(R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21) - ECase(R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC) - ECase(R_AARCH64_TLSIE_LD_GOTTPREL_PREL19) - ECase(R_AARCH64_TLSLE_MOVW_TPREL_G2) - ECase(R_AARCH64_TLSLE_MOVW_TPREL_G1) - ECase(R_AARCH64_TLSLE_MOVW_TPREL_G1_NC) - ECase(R_AARCH64_TLSLE_MOVW_TPREL_G0) - ECase(R_AARCH64_TLSLE_MOVW_TPREL_G0_NC) - ECase(R_AARCH64_TLSLE_ADD_TPREL_HI12) - ECase(R_AARCH64_TLSLE_ADD_TPREL_LO12) - ECase(R_AARCH64_TLSLE_ADD_TPREL_LO12_NC) - ECase(R_AARCH64_TLSLE_LDST8_TPREL_LO12) - ECase(R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC) - ECase(R_AARCH64_TLSLE_LDST16_TPREL_LO12) - ECase(R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC) - ECase(R_AARCH64_TLSLE_LDST32_TPREL_LO12) - ECase(R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC) - ECase(R_AARCH64_TLSLE_LDST64_TPREL_LO12) - ECase(R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC) - ECase(R_AARCH64_TLSDESC_ADR_PAGE) - ECase(R_AARCH64_TLSDESC_LD64_LO12_NC) - ECase(R_AARCH64_TLSDESC_ADD_LO12_NC) - ECase(R_AARCH64_TLSDESC_CALL) - ECase(R_AARCH64_COPY) - ECase(R_AARCH64_GLOB_DAT) - ECase(R_AARCH64_JUMP_SLOT) - ECase(R_AARCH64_RELATIVE) - ECase(R_AARCH64_TLS_DTPREL64) - ECase(R_AARCH64_TLS_DTPMOD64) - ECase(R_AARCH64_TLS_TPREL64) - ECase(R_AARCH64_TLSDESC) - ECase(R_AARCH64_IRELATIVE) +#include "llvm/Support/ELFRelocs/AArch64.def" break; default: llvm_unreachable("Unsupported architecture"); } -#undef ECase +#undef ELF_RELOC } void MappingTraits::mapping(IO &IO, -- 2.34.1