| 1 | /* ELF32/HPPA support |
| 2 | |
| 3 | This file contains ELF32/HPPA relocation support as specified |
| 4 | in the Stratus FTX/Golf Object File Format (SED-1762) dated |
| 5 | November 19, 1992. |
| 6 | |
| 7 | Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc. |
| 8 | |
| 9 | Written by: |
| 10 | |
| 11 | Center for Software Science |
| 12 | Department of Computer Science |
| 13 | University of Utah |
| 14 | |
| 15 | This file is part of BFD, the Binary File Descriptor library. |
| 16 | |
| 17 | This program is free software; you can redistribute it and/or modify |
| 18 | it under the terms of the GNU General Public License as published by |
| 19 | the Free Software Foundation; either version 2 of the License, or |
| 20 | (at your option) any later version. |
| 21 | |
| 22 | This program is distributed in the hope that it will be useful, |
| 23 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 | GNU General Public License for more details. |
| 26 | |
| 27 | You should have received a copy of the GNU General Public License |
| 28 | along with this program; if not, write to the Free Software |
| 29 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
| 30 | |
| 31 | #ifndef _ELF32_HPPA_H |
| 32 | #define _ELF32_HPPA_H |
| 33 | |
| 34 | #include "libelf.h" |
| 35 | #include "libhppa.h" |
| 36 | #include "elf/hppa.h" |
| 37 | |
| 38 | /* ELF/HPPA relocation types */ |
| 39 | |
| 40 | typedef enum |
| 41 | { |
| 42 | /* Address relocation types |
| 43 | These relocation types do simple base + offset relocations. */ |
| 44 | |
| 45 | R_PARISC_NONE = 0x00, |
| 46 | R_PARISC_DIR32 = 0x01, |
| 47 | R_PARISC_DIR21L = 0x02, |
| 48 | R_PARISC_DIR17R = 0x03, |
| 49 | R_PARISC_DIR17F = 0x04, |
| 50 | R_PARISC_DIR14R = 0x06, |
| 51 | |
| 52 | /* PC-relative relocation types |
| 53 | Typically used for calls. |
| 54 | Note PCREL17C and PCREL17F differ only in overflow handling. |
| 55 | PCREL17C never reports a relocation error. |
| 56 | |
| 57 | When supporting argument relocations, function calls must be |
| 58 | accompanied by parameter relocation information. This information is |
| 59 | carried in the ten high-order bits of the addend field. The remaining |
| 60 | 22 bits of of the addend field are sign-extended to form the Addend. |
| 61 | |
| 62 | Note the code to build argument relocations depends on the |
| 63 | addend being zero. A consequence of this limitation is GAS |
| 64 | can not perform relocation reductions for function symbols. */ |
| 65 | R_PARISC_PCREL21L = 0x0a, |
| 66 | R_PARISC_PCREL17R = 0x0b, |
| 67 | R_PARISC_PCREL17F = 0x0c, |
| 68 | R_PARISC_PCREL17C = 0x0d, |
| 69 | R_PARISC_PCREL14R = 0x0e, |
| 70 | R_PARISC_PCREL14F = 0x0f, |
| 71 | |
| 72 | /* DP-relative relocation types. */ |
| 73 | R_PARISC_DPREL21L = 0x12, |
| 74 | R_PARISC_DPREL14R = 0x16, |
| 75 | R_PARISC_DPREL14F = 0x17, |
| 76 | |
| 77 | /* Data linkage table (DLT) relocation types |
| 78 | |
| 79 | SOM DLT_REL fixup requests are used to for static data references |
| 80 | from position-independent code within shared libraries. They are |
| 81 | similar to the GOT relocation types in some SVR4 implementations. */ |
| 82 | |
| 83 | R_PARISC_DLTREL21L = 0x1a, |
| 84 | R_PARISC_DLTREL14R = 0x1e, |
| 85 | R_PARISC_DLTREL14F = 0x1f, |
| 86 | |
| 87 | /* DLT indirect relocation types */ |
| 88 | R_PARISC_DLTIND21L = 0x22, |
| 89 | R_PARISC_DLTIND14R = 0x26, |
| 90 | R_PARISC_DLTIND14F = 0x27, |
| 91 | |
| 92 | /* Base relative relocation types. Ugh. These imply lots of state */ |
| 93 | R_PARISC_SETBASE = 0x28, |
| 94 | R_PARISC_BASEREL32 = 0x29, |
| 95 | R_PARISC_BASEREL21L = 0x2a, |
| 96 | R_PARISC_BASEREL17R = 0x2b, |
| 97 | R_PARISC_BASEREL17F = 0x2c, |
| 98 | R_PARISC_BASEREL14R = 0x2e, |
| 99 | R_PARISC_BASEREL14F = 0x2f, |
| 100 | |
| 101 | /* Segment relative relocation types. */ |
| 102 | R_PARISC_TEXTREL32 = 0x31, |
| 103 | R_PARISC_DATAREL32 = 0x39, |
| 104 | |
| 105 | /* Plabel relocation types. */ |
| 106 | R_PARISC_PLABEL32 = 0x41, |
| 107 | R_PARISC_PLABEL21L = 0x42, |
| 108 | R_PARISC_PLABEL14R = 0x46, |
| 109 | |
| 110 | /* PLT relocations. */ |
| 111 | R_PARISC_PLTIND21L = 0x82, |
| 112 | R_PARISC_PLTIND14R = 0x86, |
| 113 | R_PARISC_PLTIND14F = 0x87, |
| 114 | |
| 115 | /* Misc relocation types. */ |
| 116 | R_PARISC_COPY = 0x88, |
| 117 | R_PARISC_GLOB_DAT = 0x89, |
| 118 | R_PARISC_JMP_SLOT = 0x8a, |
| 119 | R_PARISC_RELATIVE = 0x8b, |
| 120 | R_PARISC_STUB_CALL_17 = 0x8c, |
| 121 | R_PARISC_UNIMPLEMENTED, |
| 122 | } |
| 123 | elf32_hppa_reloc_type; |
| 124 | |
| 125 | #define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1 |
| 126 | #define N_PARISC_RELOCS R_PARISC_UNIMPLEMENTED + 1 |
| 127 | |
| 128 | /* Define groups of basic relocations. FIXME: These should |
| 129 | be the only basic relocations created by GAS. The rest |
| 130 | should be internal to the BFD backend. |
| 131 | |
| 132 | The idea is both SOM and ELF define these basic relocation |
| 133 | types so they map into a SOM or ELF specific relocation |
| 134 | as appropriate. This allows GAS to share much more code |
| 135 | between the two target object formats. */ |
| 136 | |
| 137 | #define R_HPPA_NONE R_PARISC_NONE |
| 138 | #define R_HPPA R_PARISC_DIR32 |
| 139 | #define R_HPPA_GOTOFF R_PARISC_DPREL21L |
| 140 | #define R_HPPA_PCREL_CALL R_PARISC_PCREL21L |
| 141 | |
| 142 | /* HPPA symbol table extension entry types */ |
| 143 | enum elf32_hppa_symextn_types |
| 144 | { |
| 145 | PARISC_SXT_NULL, |
| 146 | PARISC_SXT_SYMNDX, |
| 147 | PARISC_SXT_ARG_RELOC, |
| 148 | }; |
| 149 | |
| 150 | /* These macros compose and decompose the value of a symextn entry: |
| 151 | |
| 152 | entry_type = ELF32_PARISC_SX_TYPE(word); |
| 153 | entry_value = ELF32_PARISC_SX_VAL(word); |
| 154 | word = ELF32_PARISC_SX_WORD(type,val); */ |
| 155 | |
| 156 | #define ELF32_PARISC_SX_TYPE(p) ((p) >> 24) |
| 157 | #define ELF32_PARISC_SX_VAL(p) ((p) & 0xFFFFFF) |
| 158 | #define ELF32_PARISC_SX_WORD(type,val) (((type) << 24) + (val & 0xFFFFFF)) |
| 159 | |
| 160 | /* The following was added facilitate implementation of the .hppa_symextn |
| 161 | section. This section is built after the symbol table is built in the |
| 162 | elf_write_object_contents routine (called from bfd_close). It is built |
| 163 | so late because it requires information that is not known until |
| 164 | the symbol and string table sections have been allocated, and |
| 165 | the symbol table has been built. */ |
| 166 | |
| 167 | /* Number of "hand-made" target specific sections. */ |
| 168 | #define ELF_TC_FAKE_SECTIONS 1 |
| 169 | #define SYMEXTN_SECTION_NAME ".PARISC.symext" |
| 170 | |
| 171 | /* FIXME. Are these external? (For example used by GAS?). If so the |
| 172 | names need to change to avoid namespace pollution, if not they should |
| 173 | be moved into elf32-hppa.c. */ |
| 174 | typedef unsigned long symext_entryS; |
| 175 | struct symext_chain |
| 176 | { |
| 177 | symext_entryS entry; |
| 178 | struct symext_chain *next; |
| 179 | }; |
| 180 | |
| 181 | typedef struct symext_chain symext_chainS; |
| 182 | |
| 183 | elf32_hppa_reloc_type **hppa_elf_gen_reloc_type |
| 184 | PARAMS ((bfd *, elf32_hppa_reloc_type, int, int)); |
| 185 | |
| 186 | asymbol * hppa_look_for_stubs_in_section |
| 187 | PARAMS ((bfd *, bfd *, bfd *, asection *, |
| 188 | int *, struct bfd_link_info *)); |
| 189 | |
| 190 | void elf_hppa_final_processing PARAMS ((void)); |
| 191 | #endif /* _ELF32_HPPA_H */ |