Home | History | Annotate | Download | only in Hexagon
      1 //===- HexagonRelocationFunction.h ----------------------------------------===//
      2 //
      3 //                     The MCLinker Project
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 typedef struct {
     10 	const char *insnSyntax;
     11 	uint32_t insnMask;
     12 	uint32_t insnCmpMask;
     13 	uint32_t insnBitMask;
     14         bool isDuplex;
     15 } Instruction;
     16 
     17 //===--------------------------------------------------------------------===//
     18 // Relocation helper function
     19 //===--------------------------------------------------------------------===//
     20 template<typename T1, typename T2>
     21 T1 ApplyMask(T2 pMask, T1 pData) {
     22   T1 result = 0;
     23   size_t off = 0;
     24 
     25   for (size_t bit = 0; bit != sizeof (T1) * 8; ++bit) {
     26     const bool valBit = (pData >> off) & 1;
     27     const bool maskBit = (pMask >> bit) & 1;
     28     if (maskBit) {
     29       result |= static_cast<T1>(valBit) << bit;
     30       ++off;
     31     }
     32   }
     33   return result;
     34 }
     35 
     36 #define DECL_HEXAGON_APPLY_RELOC_FUNC(Name) \
     37 static HexagonRelocator::Result Name    (Relocation& pEntry, \
     38                                      HexagonRelocator& pParent);
     39 
     40 #define DECL_HEXAGON_APPLY_RELOC_FUNCS \
     41 DECL_HEXAGON_APPLY_RELOC_FUNC(none)             \
     42 DECL_HEXAGON_APPLY_RELOC_FUNC(relocB22PCREL)     \
     43 DECL_HEXAGON_APPLY_RELOC_FUNC(relocB15PCREL)     \
     44 DECL_HEXAGON_APPLY_RELOC_FUNC(relocB7PCREL)      \
     45 DECL_HEXAGON_APPLY_RELOC_FUNC(relocLO16)         \
     46 DECL_HEXAGON_APPLY_RELOC_FUNC(relocHI16)        \
     47 DECL_HEXAGON_APPLY_RELOC_FUNC(reloc32)         \
     48 DECL_HEXAGON_APPLY_RELOC_FUNC(reloc16)         \
     49 DECL_HEXAGON_APPLY_RELOC_FUNC(reloc8)         \
     50 DECL_HEXAGON_APPLY_RELOC_FUNC(relocGPREL16_0)  \
     51 DECL_HEXAGON_APPLY_RELOC_FUNC(relocGPREL16_1)  \
     52 DECL_HEXAGON_APPLY_RELOC_FUNC(relocGPREL16_2)  \
     53 DECL_HEXAGON_APPLY_RELOC_FUNC(relocGPREL16_3)  \
     54 DECL_HEXAGON_APPLY_RELOC_FUNC(relocB13PCREL)  \
     55 DECL_HEXAGON_APPLY_RELOC_FUNC(relocB9PCREL)  \
     56 DECL_HEXAGON_APPLY_RELOC_FUNC(relocB32PCRELX)  \
     57 DECL_HEXAGON_APPLY_RELOC_FUNC(reloc32_6_X)  \
     58 DECL_HEXAGON_APPLY_RELOC_FUNC(relocB22PCRELX)  \
     59 DECL_HEXAGON_APPLY_RELOC_FUNC(relocB15PCRELX)  \
     60 DECL_HEXAGON_APPLY_RELOC_FUNC(relocB13PCRELX)  \
     61 DECL_HEXAGON_APPLY_RELOC_FUNC(relocB9PCRELX)  \
     62 DECL_HEXAGON_APPLY_RELOC_FUNC(relocB7PCRELX)  \
     63 DECL_HEXAGON_APPLY_RELOC_FUNC(reloc32PCREL)  \
     64 DECL_HEXAGON_APPLY_RELOC_FUNC(relocHexNX)  \
     65 DECL_HEXAGON_APPLY_RELOC_FUNC(relocHexGOTRELLO16)  \
     66 DECL_HEXAGON_APPLY_RELOC_FUNC(relocHexGOTRELHI16)  \
     67 DECL_HEXAGON_APPLY_RELOC_FUNC(relocHexGOTREL32)  \
     68 DECL_HEXAGON_APPLY_RELOC_FUNC(relocPLTB22PCREL)  \
     69 DECL_HEXAGON_APPLY_RELOC_FUNC(relocHex6PCRELX)  \
     70 DECL_HEXAGON_APPLY_RELOC_FUNC(relocHexGOT326X)  \
     71 DECL_HEXAGON_APPLY_RELOC_FUNC(relocHexGOT1611X)  \
     72 DECL_HEXAGON_APPLY_RELOC_FUNC(unsupport)
     73 
     74 
     75 #define DECL_HEXAGON_APPLY_RELOC_FUNC_PTRS \
     76   { &none,                0, "R_HEX_NONE"                        }, \
     77   { &relocB22PCREL,       1, "R_HEX_B22_PCREL"                   }, \
     78   { &relocB15PCREL,       2, "R_HEX_B15_PCREL"                   }, \
     79   { &relocB7PCREL,        3, "R_HEX_B7_PCREL"                    }, \
     80   { &relocLO16,           4, "R_HEX_LO16"                        }, \
     81   { &relocHI16,           5, "R_HEX_HI16"                        }, \
     82   { &reloc32,             6, "R_HEX_32"                          }, \
     83   { &reloc16,             7, "R_HEX_16"                          }, \
     84   { &reloc8,              8, "R_HEX_8"                           }, \
     85   { &relocGPREL16_0,      9, "R_HEX_GPREL16_0"                   }, \
     86   { &relocGPREL16_1,      10, "R_HEX_GPREL16_1"                  }, \
     87   { &relocGPREL16_2,      11, "R_HEX_GPREL16_2"                  }, \
     88   { &relocGPREL16_3,      12, "R_HEX_GPREL16_3"                  }, \
     89   { &unsupport,           13, "R_HEX_HL16"                       }, \
     90   { &relocB13PCREL,       14, "R_HEX_B13_PCREL"                  }, \
     91   { &relocB9PCREL,        15, "R_HEX_B9_PCREL"                   }, \
     92   { &relocB32PCRELX,      16, "R_HEX_B32_PCREL_X"                }, \
     93   { &reloc32_6_X,         17, "R_HEX_32_6_X"                     }, \
     94   { &relocB22PCRELX,      18, "R_HEX_B22_PCREL_X"                }, \
     95   { &relocB15PCRELX,      19, "R_HEX_B15_PCREL_X"                }, \
     96   { &relocB13PCRELX,      20, "R_HEX_B13_PCREL_X"                }, \
     97   { &relocB9PCRELX,       21, "R_HEX_B9_PCREL_X"                 }, \
     98   { &relocB7PCRELX,       22, "R_HEX_B7_PCREL_X"                 }, \
     99   { &relocHexNX,          23, "R_HEX_16_X"                       }, \
    100   { &relocHexNX,          24, "R_HEX_12_X"                       }, \
    101   { &relocHexNX,          25, "R_HEX_11_X"                       }, \
    102   { &relocHexNX,          26, "R_HEX_10_X"                       }, \
    103   { &relocHexNX,          27, "R_HEX_9_X"                        }, \
    104   { &relocHexNX,          28, "R_HEX_8_X"                        }, \
    105   { &relocHexNX,          29, "R_HEX_7_X"                        }, \
    106   { &relocHexNX,          30, "R_HEX_6_X"                        }, \
    107   { &reloc32PCREL,        31, "R_HEX_32_PCREL"                   }, \
    108   { &unsupport,           32, "R_HEX_COPY"                       }, \
    109   { &unsupport,           33, "R_HEX_GLOB_DAT"                   }, \
    110   { &unsupport,           34, "R_HEX_JMP_SLOT"                   }, \
    111   { &unsupport,           35, "R_HEX_RELATIVE"                   }, \
    112   { &relocPLTB22PCREL,    36, "R_HEX_PLT_B22_PCREL"              }, \
    113   { &relocHexGOTRELLO16,  37, "R_HEX_GOTREL_LO16"                }, \
    114   { &relocHexGOTRELHI16,  38, "R_HEX_GOTREL_HI16"                }, \
    115   { &relocHexGOTREL32,    39, "R_HEX_GOTREL_32"                  }, \
    116   { &unsupport,           40, "R_HEX_GOT_LO16"                   }, \
    117   { &unsupport,           41, "R_HEX_GOT_HI16"                   }, \
    118   { &unsupport,           42, "R_HEX_GOT_32"                     }, \
    119   { &unsupport,           43, "R_HEX_GOT_16"                     }, \
    120   { &unsupport,           44, "R_HEX_DTPMOD_32"                  }, \
    121   { &unsupport,           45, "R_HEX_DTPREL_LO16"                }, \
    122   { &unsupport,           46, "R_HEX_DTPREL_HI16"                }, \
    123   { &unsupport,           47, "R_HEX_DTPREL_32"                  }, \
    124   { &unsupport,           48, "R_HEX_DTPREL_16"                  }, \
    125   { &unsupport,           49, "R_HEX_GD_PLT_B22_PCREL"           }, \
    126   { &unsupport,           50, "R_HEX_GD_GOT_LO16"                }, \
    127   { &unsupport,           51, "R_HEX_GD_GOT_HI16"                }, \
    128   { &unsupport,           52, "R_HEX_GD_GOT_32"                  }, \
    129   { &unsupport,           53, "R_HEX_GD_GOT_16"                  }, \
    130   { &unsupport,           54, "R_HEX_IE_LO16"                    }, \
    131   { &unsupport,           55, "R_HEX_IE_HI16"                    }, \
    132   { &unsupport,           56, "R_HEX_IE_32"                      }, \
    133   { &unsupport,           57, "R_HEX_IE_GOT_LO16"                }, \
    134   { &unsupport,           58, "R_HEX_IE_GOT_HI16"                }, \
    135   { &unsupport,           59, "R_HEX_IE_GOT_32"                  }, \
    136   { &unsupport,           60, "R_HEX_IE_GOT_16"                  }, \
    137   { &unsupport,           61, "R_HEX_TPREL_LO16"                 }, \
    138   { &unsupport,           62, "R_HEX_TPREL_HI16"                 }, \
    139   { &unsupport,           63, "R_HEX_TPREL_32"                   }, \
    140   { &unsupport,           64, "R_HEX_TPREL_16"                   }, \
    141   { &relocHex6PCRELX,     65, "R_HEX_6_PCREL_X"                  }, \
    142   { &unsupport,           66, "R_HEX_GOTREL_32_6_X"              }, \
    143   { &unsupport,           67, "R_HEX_GOTREL_16_X"                }, \
    144   { &unsupport,           68, "R_HEX_GOTREL_11_X"                }, \
    145   { &relocHexGOT326X,     69, "R_HEX_GOT_32_6_X"                 }, \
    146   { &relocHexGOT1611X,    70, "R_HEX_GOT_16_X"                   }, \
    147   { &relocHexGOT1611X,    71, "R_HEX_GOT_11_X"                   }, \
    148   { &unsupport,           72, "R_HEX_DTPREL_32_6_X"              }, \
    149   { &unsupport,           73, "R_HEX_DTPREL_16_X"                }, \
    150   { &unsupport,           74, "R_HEX_DTPREL_11_X"                }, \
    151   { &unsupport,           75, "R_HEX_GD_GOT_32_6_X"              }, \
    152   { &unsupport,           76, "R_HEX_GD_GOT_16_X"                }, \
    153   { &unsupport,           77, "R_HEX_GD_GOT_11_X"                }, \
    154   { &unsupport,           78, "R_HEX_IE_32_6_X"                  }, \
    155   { &unsupport,           79, "R_HEX_IE_16_X"                    }, \
    156   { &unsupport,           80, "R_HEX_IE_GOT_32_6_X"              }, \
    157   { &unsupport,           81, "R_HEX_IE_GOT_16_X"                }, \
    158   { &unsupport,           82, "R_HEX_IE_GOT_11_X"                }, \
    159   { &unsupport,           83, "R_HEX_TPREL_32_6_X"               }, \
    160   { &unsupport,           84, "R_HEX_TPREL_16_X"                 }, \
    161   { &unsupport,           85, "R_HEX_TPREL_11_X"                 }
    162