Home | History | Annotate | Line # | Download | only in bfd
      1      1.1  christos /* ARC-specific header file for PLT support.
      2  1.1.1.7  christos    Copyright (C) 2016-2025 Free Software Foundation, Inc.
      3      1.1  christos    Contributed by Cupertino Miranda (cmiranda (at) synopsys.com).
      4      1.1  christos 
      5      1.1  christos    This file is part of BFD, the Binary File Descriptor library.
      6      1.1  christos 
      7      1.1  christos    This program is free software; you can redistribute it and/or modify
      8      1.1  christos    it under the terms of the GNU General Public License as published by
      9      1.1  christos    the Free Software Foundation; either version 3 of the License, or
     10      1.1  christos    (at your option) any later version.
     11      1.1  christos 
     12      1.1  christos    This program is distributed in the hope that it will be useful,
     13      1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14      1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15      1.1  christos    GNU General Public License for more details.
     16      1.1  christos 
     17      1.1  christos    You should have received a copy of the GNU General Public License
     18      1.1  christos    along with this program; if not, write to the Free Software
     19      1.1  christos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     20      1.1  christos    MA 02110-1301, USA.  */
     21      1.1  christos 
     22      1.1  christos #ifndef ARC_PLT_H
     23      1.1  christos #define ARC_PLT_H
     24      1.1  christos 
     25      1.1  christos /* Instructions appear in memory as a sequence of half-words (16 bit);
     26      1.1  christos    individual half-words are represented on the target in target byte order.
     27      1.1  christos    We use 'unsigned short' on the host to represent the PLT templates,
     28      1.1  christos    and translate to target byte order as we copy to the target.  */
     29      1.1  christos typedef uint16_t insn_hword;
     30      1.1  christos 
     31      1.1  christos enum plt_reloc_symbol
     32      1.1  christos {
     33      1.1  christos   LAST_RELOC = 0,
     34      1.1  christos 
     35      1.1  christos   SGOT = 1,
     36      1.1  christos 
     37      1.1  christos   RELATIVE = (1 << 8),
     38      1.1  christos   RELATIVE_INSN_32 = (1 << 9),
     39      1.1  christos   RELATIVE_INSN_24 = (1 << 10),
     40      1.1  christos 
     41      1.1  christos   MIDDLE_ENDIAN = (1 << 11)
     42      1.1  christos };
     43      1.1  christos 
     44  1.1.1.3  christos #define IS_RELATIVE(S)	    ((S & (RELATIVE | RELATIVE_INSN_24 | RELATIVE_INSN_32)) != 0)
     45  1.1.1.3  christos #define IS_INSN_32(S)	    ((S & RELATIVE_INSN_32) != 0)
     46  1.1.1.3  christos #define IS_INSN_24(S)	    ((S & RELATIVE_INSN_24) != 0)
     47      1.1  christos #define IS_MIDDLE_ENDIAN(S) ((S & MIDDLE_ENDIAN) != 0)
     48  1.1.1.3  christos #define SYM_ONLY(S)	    (S & 0xFF)
     49      1.1  christos 
     50      1.1  christos struct plt_reloc
     51      1.1  christos {
     52      1.1  christos   bfd_vma	  offset;
     53      1.1  christos   bfd_vma	  size;
     54      1.1  christos   bfd_vma	  mask;
     55      1.1  christos   enum plt_reloc_symbol symbol;
     56      1.1  christos   bfd_vma	  addend;
     57      1.1  christos };
     58      1.1  christos 
     59      1.1  christos 
     60      1.1  christos #define PLT_TYPE_START(NAME) NAME,
     61      1.1  christos #define PLT_TYPE_END(NAME)
     62      1.1  christos #define PLT_ENTRY(...)
     63      1.1  christos #define PLT_ELEM(...)
     64      1.1  christos #define ENTRY_RELOC(...)
     65      1.1  christos #define ELEM_RELOC(...)
     66      1.1  christos 
     67      1.1  christos enum plt_types_enum
     68      1.1  christos {
     69      1.1  christos   PLT_START = -1,
     70      1.1  christos #include "arc-plt.def"
     71      1.1  christos   PLT_MAX
     72      1.1  christos };
     73      1.1  christos 
     74      1.1  christos #undef PLT_TYPE_START
     75      1.1  christos #undef PLT_TYPE_END
     76      1.1  christos #undef PLT_ENTRY
     77      1.1  christos #undef PLT_ELEM
     78      1.1  christos #undef ENTRY_RELOC
     79      1.1  christos #undef ELEM_RELOC
     80      1.1  christos 
     81      1.1  christos typedef insn_hword insn_hword_array[];
     82      1.1  christos 
     83      1.1  christos struct plt_version_t
     84      1.1  christos {
     85      1.1  christos   const insn_hword_array *entry;
     86      1.1  christos   const bfd_vma		  entry_size;
     87      1.1  christos   const insn_hword_array *elem;
     88      1.1  christos   const bfd_vma		  elem_size;
     89      1.1  christos 
     90      1.1  christos   const struct plt_reloc *entry_relocs;
     91      1.1  christos   const struct plt_reloc *elem_relocs;
     92      1.1  christos };
     93      1.1  christos 
     94      1.1  christos #define PLT_TYPE_START(NAME) \
     95      1.1  christos   const insn_hword NAME##_plt_entry[] = {
     96      1.1  christos #define PLT_TYPE_END(NAME) };
     97      1.1  christos #define PLT_ENTRY(...) __VA_ARGS__,
     98      1.1  christos #define PLT_ELEM(...)
     99      1.1  christos #define ENTRY_RELOC(...)
    100      1.1  christos #define ELEM_RELOC(...)
    101      1.1  christos 
    102      1.1  christos #include "arc-plt.def"
    103      1.1  christos 
    104      1.1  christos #undef PLT_TYPE_START
    105      1.1  christos #undef PLT_TYPE_END
    106      1.1  christos #undef PLT_ENTRY
    107      1.1  christos #undef PLT_ELEM
    108      1.1  christos #undef ENTRY_RELOC
    109      1.1  christos #undef ELEM_RELOC
    110      1.1  christos 
    111      1.1  christos #define PLT_TYPE_START(NAME) \
    112      1.1  christos   const struct plt_reloc NAME##_plt_entry_relocs[] = {
    113      1.1  christos #define PLT_TYPE_END(NAME) \
    114      1.1  christos     {0, 0, 0, LAST_RELOC, 0} \
    115      1.1  christos   };
    116  1.1.1.3  christos #define PLT_ENTRY(...)
    117      1.1  christos #define PLT_ELEM(...)
    118      1.1  christos #define ENTRY_RELOC(...) { __VA_ARGS__ },
    119      1.1  christos #define ELEM_RELOC(...)
    120      1.1  christos 
    121      1.1  christos #include "arc-plt.def"
    122      1.1  christos 
    123      1.1  christos #undef PLT_TYPE_START
    124      1.1  christos #undef PLT_TYPE_END
    125      1.1  christos #undef PLT_ENTRY
    126      1.1  christos #undef PLT_ELEM
    127      1.1  christos #undef ENTRY_RELOC
    128      1.1  christos #undef ELEM_RELOC
    129      1.1  christos 
    130      1.1  christos 
    131      1.1  christos #define PLT_TYPE_START(NAME) \
    132      1.1  christos   const insn_hword NAME##_plt_elem[] = {
    133      1.1  christos #define PLT_TYPE_END(NAME) };
    134      1.1  christos #define PLT_ENTRY(...)
    135      1.1  christos #define PLT_ELEM(...) __VA_ARGS__,
    136      1.1  christos #define ENTRY_RELOC(...)
    137      1.1  christos #define ELEM_RELOC(...)
    138      1.1  christos 
    139      1.1  christos #include "arc-plt.def"
    140      1.1  christos 
    141      1.1  christos #undef PLT_TYPE_START
    142      1.1  christos #undef PLT_TYPE_END
    143      1.1  christos #undef PLT_ENTRY
    144      1.1  christos #undef PLT_ELEM
    145      1.1  christos #undef ENTRY_RELOC
    146      1.1  christos #undef ELEM_RELOC
    147      1.1  christos 
    148      1.1  christos #define PLT_TYPE_START(NAME) \
    149      1.1  christos   const struct plt_reloc NAME##_plt_elem_relocs[] = {
    150      1.1  christos #define PLT_TYPE_END(NAME) \
    151      1.1  christos     {0, 0, 0, LAST_RELOC, 0} \
    152      1.1  christos   };
    153  1.1.1.3  christos #define PLT_ENTRY(...)
    154      1.1  christos #define PLT_ELEM(...)
    155      1.1  christos #define ENTRY_RELOC(...)
    156      1.1  christos #define ELEM_RELOC(...) { __VA_ARGS__ },
    157      1.1  christos 
    158      1.1  christos #include "arc-plt.def"
    159      1.1  christos 
    160      1.1  christos #undef PLT_TYPE_START
    161      1.1  christos #undef PLT_TYPE_END
    162      1.1  christos #undef PLT_ENTRY
    163      1.1  christos #undef PLT_ELEM
    164      1.1  christos #undef ENTRY_RELOC
    165      1.1  christos #undef ELEM_RELOC
    166      1.1  christos 
    167      1.1  christos 
    168      1.1  christos #define PLT_TYPE_START(NAME) \
    169      1.1  christos   { \
    170      1.1  christos     .entry = &NAME##_plt_entry, \
    171      1.1  christos     .entry_size = sizeof (NAME##_plt_entry), \
    172      1.1  christos     .elem = &NAME##_plt_elem, \
    173      1.1  christos     .elem_size = sizeof (NAME##_plt_elem),  \
    174      1.1  christos     .entry_relocs = NAME##_plt_entry_relocs, \
    175      1.1  christos     .elem_relocs = NAME##_plt_elem_relocs
    176      1.1  christos #define PLT_TYPE_END(NAME) },
    177      1.1  christos #define PLT_ENTRY(...)
    178      1.1  christos #define PLT_ELEM(...)
    179      1.1  christos #define ENTRY_RELOC(...)
    180      1.1  christos #define ELEM_RELOC(...)
    181  1.1.1.5  christos const struct plt_version_t plt_versions[PLT_MAX] = {
    182      1.1  christos 
    183      1.1  christos #include "arc-plt.def"
    184      1.1  christos 
    185      1.1  christos };
    186      1.1  christos #undef PLT_TYPE_START
    187      1.1  christos #undef PLT_TYPE_END
    188      1.1  christos #undef PLT_ENTRY
    189      1.1  christos #undef PLT_ELEM
    190      1.1  christos #undef ENTRY_RELOC
    191      1.1  christos #undef ELEM_RELOC
    192      1.1  christos 
    193      1.1  christos 
    194      1.1  christos #endif /* ARC_PLT_H */
    195