From b9f9bb478481193adbca1546d32cb60e73a0a826 Mon Sep 17 00:00:00 2001 From: Leslie Zhai Date: Wed, 13 Sep 2017 01:49:49 +0000 Subject: [PATCH] [ARC] Prepare the implementation of relocation for LLD Reviewers: ruiu, kparzysz, petecoup, rafael Reviewed By: kparzysz Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37556 llvm-svn: 313109 --- include/llvm/BinaryFormat/ELF.h | 21 ++++++ include/llvm/BinaryFormat/ELFRelocs/ARC.def | 74 +++++++++++++++++++++ include/llvm/module.modulemap | 1 + lib/Object/ELF.cpp | 8 +++ lib/ObjectYAML/ELFYAML.cpp | 3 + 5 files changed, 107 insertions(+) create mode 100644 include/llvm/BinaryFormat/ELFRelocs/ARC.def diff --git a/include/llvm/BinaryFormat/ELF.h b/include/llvm/BinaryFormat/ELF.h index a4450ee13b4..c22cb19391d 100644 --- a/include/llvm/BinaryFormat/ELF.h +++ b/include/llvm/BinaryFormat/ELF.h @@ -430,6 +430,27 @@ enum { #include "ELFRelocs/ARM.def" }; +// ARC Specific e_flags +enum : unsigned { + EF_ARC_MACH_MSK = 0x000000ff, + EF_ARC_OSABI_MSK = 0x00000f00, + E_ARC_MACH_ARC600 = 0x00000002, + E_ARC_MACH_ARC601 = 0x00000004, + E_ARC_MACH_ARC700 = 0x00000003, + EF_ARC_CPU_ARCV2EM = 0x00000005, + EF_ARC_CPU_ARCV2HS = 0x00000006, + E_ARC_OSABI_ORIG = 0x00000000, + E_ARC_OSABI_V2 = 0x00000200, + E_ARC_OSABI_V3 = 0x00000300, + E_ARC_OSABI_V4 = 0x00000400, + EF_ARC_PIC = 0x00000100 +}; + +// ELF Relocation types for ARC +enum { +#include "ELFRelocs/ARC.def" +}; + // AVR specific e_flags enum : unsigned { EF_AVR_ARCH_AVR1 = 1, diff --git a/include/llvm/BinaryFormat/ELFRelocs/ARC.def b/include/llvm/BinaryFormat/ELFRelocs/ARC.def new file mode 100644 index 00000000000..5691fb3458e --- /dev/null +++ b/include/llvm/BinaryFormat/ELFRelocs/ARC.def @@ -0,0 +1,74 @@ + +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +ELF_RELOC(R_ARC_NONE, 0) +ELF_RELOC(R_ARC_8, 1) +ELF_RELOC(R_ARC_16, 2) +ELF_RELOC(R_ARC_24, 3) +ELF_RELOC(R_ARC_32, 4) +ELF_RELOC(R_ARC_N8, 8) +ELF_RELOC(R_ARC_N16, 9) +ELF_RELOC(R_ARC_N24, 10) +ELF_RELOC(R_ARC_N32, 11) +ELF_RELOC(R_ARC_SDA, 12) +ELF_RELOC(R_ARC_SECTOFF, 13) +ELF_RELOC(R_ARC_S21H_PCREL, 14) +ELF_RELOC(R_ARC_S21W_PCREL, 15) +ELF_RELOC(R_ARC_S25H_PCREL, 16) +ELF_RELOC(R_ARC_S25W_PCREL, 17) +ELF_RELOC(R_ARC_SDA32, 18) +ELF_RELOC(R_ARC_SDA_LDST, 19) +ELF_RELOC(R_ARC_SDA_LDST1, 20) +ELF_RELOC(R_ARC_SDA_LDST2, 21) +ELF_RELOC(R_ARC_SDA16_LD, 22) +ELF_RELOC(R_ARC_SDA16_LD1, 23) +ELF_RELOC(R_ARC_SDA16_LD2, 24) +ELF_RELOC(R_ARC_S13_PCREL, 25) +ELF_RELOC(R_ARC_W, 26) +ELF_RELOC(R_ARC_32_ME, 27) +ELF_RELOC(R_ARC_32_ME_S, 105) +ELF_RELOC(R_ARC_N32_ME, 28) +ELF_RELOC(R_ARC_SECTOFF_ME, 29) +ELF_RELOC(R_ARC_SDA32_ME, 30) +ELF_RELOC(R_ARC_W_ME, 31) +ELF_RELOC(R_AC_SECTOFF_U8, 35) +ELF_RELOC(R_AC_SECTOFF_U8_1, 36) +ELF_RELOC(R_AC_SECTOFF_U8_2, 37) +ELF_RELOC(R_AC_SECTOFF_S9, 38) +ELF_RELOC(R_AC_SECTOFF_S9_1, 39) +ELF_RELOC(R_AC_SECTOFF_S9_2, 40) +ELF_RELOC(R_ARC_SECTOFF_ME_1, 41) +ELF_RELOC(R_ARC_SECTOFF_ME_2, 42) +ELF_RELOC(R_ARC_SECTOFF_1, 43) +ELF_RELOC(R_ARC_SECTOFF_2, 44) +ELF_RELOC(R_ARC_SDA_12, 45) +ELF_RELOC(R_ARC_SDA16_ST2, 48) +ELF_RELOC(R_ARC_32_PCREL, 49) +ELF_RELOC(R_ARC_PC32, 50) +ELF_RELOC(R_ARC_GOT32, 59) +ELF_RELOC(R_ARC_GOTPC32, 51) +ELF_RELOC(R_ARC_PLT32, 52) +ELF_RELOC(R_ARC_COPY, 53) +ELF_RELOC(R_ARC_GLOB_DAT, 54) +ELF_RELOC(R_ARC_JMP_SLOT, 55) +ELF_RELOC(R_ARC_RELATIVE, 56) +ELF_RELOC(R_ARC_GOTOFF, 57) +ELF_RELOC(R_ARC_GOTPC, 58) +ELF_RELOC(R_ARC_S21W_PCREL_PLT, 60) +ELF_RELOC(R_ARC_S25H_PCREL_PLT, 61) +ELF_RELOC(R_ARC_JLI_SECTOFF, 63) +ELF_RELOC(R_ARC_TLS_DTPMOD, 66) +ELF_RELOC(R_ARC_TLS_TPOFF, 68) +ELF_RELOC(R_ARC_TLS_GD_GOT, 69) +ELF_RELOC(R_ARC_TLS_GD_LD, 70) +ELF_RELOC(R_ARC_TLS_GD_CALL, 71) +ELF_RELOC(R_ARC_TLS_IE_GOT, 72) +ELF_RELOC(R_ARC_TLS_DTPOFF, 67) +ELF_RELOC(R_ARC_TLS_DTPOFF_S9, 73) +ELF_RELOC(R_ARC_TLS_LE_S9, 74) +ELF_RELOC(R_ARC_TLS_LE_32, 75) +ELF_RELOC(R_ARC_S25W_PCREL_PLT, 76) +ELF_RELOC(R_ARC_S21H_PCREL_PLT, 77) +ELF_RELOC(R_ARC_NPS_CMEM16, 78) diff --git a/include/llvm/module.modulemap b/include/llvm/module.modulemap index ada05aa14cd..4b177540a50 100644 --- a/include/llvm/module.modulemap +++ b/include/llvm/module.modulemap @@ -49,6 +49,7 @@ module LLVM_BinaryFormat { textual header "BinaryFormat/ELFRelocs/AArch64.def" textual header "BinaryFormat/ELFRelocs/AMDGPU.def" textual header "BinaryFormat/ELFRelocs/ARM.def" + textual header "BinaryFormat/ELFRelocs/ARC.def" textual header "BinaryFormat/ELFRelocs/AVR.def" textual header "BinaryFormat/ELFRelocs/BPF.def" textual header "BinaryFormat/ELFRelocs/Hexagon.def" diff --git a/lib/Object/ELF.cpp b/lib/Object/ELF.cpp index 448fb1bd6b5..130fb2d9ecc 100644 --- a/lib/Object/ELF.cpp +++ b/lib/Object/ELF.cpp @@ -58,6 +58,14 @@ StringRef llvm::object::getELFRelocationTypeName(uint32_t Machine, break; } break; + case ELF::EM_ARC_COMPACT: + case ELF::EM_ARC_COMPACT2: + switch (Type) { +#include "llvm/BinaryFormat/ELFRelocs/ARC.def" + default: + break; + } + break; case ELF::EM_AVR: switch (Type) { #include "llvm/BinaryFormat/ELFRelocs/AVR.def" diff --git a/lib/ObjectYAML/ELFYAML.cpp b/lib/ObjectYAML/ELFYAML.cpp index 20f0905ecc8..d6123499a22 100644 --- a/lib/ObjectYAML/ELFYAML.cpp +++ b/lib/ObjectYAML/ELFYAML.cpp @@ -577,6 +577,9 @@ void ScalarEnumerationTraits::enumeration( case ELF::EM_ARM: #include "llvm/BinaryFormat/ELFRelocs/ARM.def" break; + case ELF::EM_ARC: +#include "llvm/BinaryFormat/ELFRelocs/ARC.def" + break; case ELF::EM_RISCV: #include "llvm/BinaryFormat/ELFRelocs/RISCV.def" break;