1 1.1 christos /* Common code for PA ELF implementations. 2 1.11 christos Copyright (C) 1999-2024 Free Software Foundation, Inc. 3 1.1 christos 4 1.1 christos This file is part of BFD, the Binary File Descriptor library. 5 1.1 christos 6 1.1 christos This program is free software; you can redistribute it and/or modify 7 1.1 christos it under the terms of the GNU General Public License as published by 8 1.1 christos the Free Software Foundation; either version 3 of the License, or 9 1.1 christos (at your option) any later version. 10 1.1 christos 11 1.1 christos This program is distributed in the hope that it will be useful, 12 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of 13 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 1.1 christos GNU General Public License for more details. 15 1.1 christos 16 1.1 christos You should have received a copy of the GNU General Public License 17 1.1 christos along with this program; if not, write to the Free Software 18 1.1 christos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 19 1.1 christos MA 02110-1301, USA. */ 20 1.1 christos 21 1.1 christos #define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1 22 1.1 christos 23 1.1 christos /* This file is included by multiple PA ELF BFD backends with different 24 1.1 christos sizes. 25 1.1 christos 26 1.1 christos Most of the routines are written to be size independent, but sometimes 27 1.1 christos external constraints require 32 or 64 bit specific code. We remap 28 1.1 christos the definitions/functions as necessary here. */ 29 1.1 christos #if ARCH_SIZE == 64 30 1.8 christos #define ELF_R_TYPE(X) ELF64_R_TYPE(X) 31 1.8 christos #define ELF_R_SYM(X) ELF64_R_SYM(X) 32 1.1 christos #define elf_hppa_reloc_final_type elf64_hppa_reloc_final_type 33 1.1 christos #define _bfd_elf_hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type 34 1.1 christos #define elf_hppa_relocate_section elf64_hppa_relocate_section 35 1.8 christos #define elf_hppa_final_link elf64_hppa_final_link 36 1.1 christos #endif 37 1.1 christos #if ARCH_SIZE == 32 38 1.8 christos #define ELF_R_TYPE(X) ELF32_R_TYPE(X) 39 1.8 christos #define ELF_R_SYM(X) ELF32_R_SYM(X) 40 1.1 christos #define elf_hppa_reloc_final_type elf32_hppa_reloc_final_type 41 1.1 christos #define _bfd_elf_hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type 42 1.1 christos #define elf_hppa_relocate_section elf32_hppa_relocate_section 43 1.8 christos #define elf_hppa_final_link elf32_hppa_final_link 44 1.1 christos #endif 45 1.1 christos 46 1.1 christos /* ELF/PA relocation howto entries. */ 47 1.1 christos 48 1.1 christos static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] = 49 1.1 christos { 50 1.8 christos #define HOW(type, size, bitsize, pc_rel, complain, mask) \ 51 1.8 christos HOWTO (type, 0, size, bitsize, pc_rel, 0, complain_overflow_ ## complain, \ 52 1.10 christos bfd_elf_generic_reloc, #type, false, 0, mask, false) 53 1.1 christos 54 1.1 christos /* The values in DIR32 are to placate the check in 55 1.1 christos _bfd_stab_section_find_nearest_line. */ 56 1.10 christos HOW (R_PARISC_NONE, 0, 0, false, dont, 0), 57 1.10 christos HOW (R_PARISC_DIR32, 4, 32, false, bitfield, 0xffffffff), 58 1.10 christos HOW (R_PARISC_DIR21L, 4, 21, false, bitfield, 0), 59 1.10 christos HOW (R_PARISC_DIR17R, 4, 17, false, bitfield, 0), 60 1.10 christos HOW (R_PARISC_DIR17F, 4, 17, false, bitfield, 0), 61 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 62 1.10 christos HOW (R_PARISC_DIR14R, 4, 14, false, bitfield, 0), 63 1.10 christos HOW (R_PARISC_DIR14F, 4, 14, false, bitfield, 0), 64 1.1 christos /* 8 */ 65 1.10 christos HOW (R_PARISC_PCREL12F, 4, 12, true, bitfield, 0), 66 1.10 christos HOW (R_PARISC_PCREL32, 4, 32, true, bitfield, 0), 67 1.10 christos HOW (R_PARISC_PCREL21L, 4, 21, true, bitfield, 0), 68 1.10 christos HOW (R_PARISC_PCREL17R, 4, 17, true, bitfield, 0), 69 1.10 christos HOW (R_PARISC_PCREL17F, 4, 17, true, bitfield, 0), 70 1.10 christos HOW (R_PARISC_PCREL17C, 4, 17, true, bitfield, 0), 71 1.10 christos HOW (R_PARISC_PCREL14R, 4, 14, true, bitfield, 0), 72 1.10 christos HOW (R_PARISC_PCREL14F, 4, 14, true, bitfield, 0), 73 1.1 christos /* 16 */ 74 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 75 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 76 1.10 christos HOW (R_PARISC_DPREL21L, 4, 21, false, bitfield, 0), 77 1.10 christos HOW (R_PARISC_DPREL14WR, 4, 14, false, bitfield, 0), 78 1.10 christos HOW (R_PARISC_DPREL14DR, 4, 14, false, bitfield, 0), 79 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 80 1.10 christos HOW (R_PARISC_DPREL14R, 4, 14, false, bitfield, 0), 81 1.10 christos HOW (R_PARISC_DPREL14F, 4, 14, false, bitfield, 0), 82 1.1 christos /* 24 */ 83 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 84 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 85 1.10 christos HOW (R_PARISC_DLTREL21L, 4, 21, false, bitfield, 0), 86 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 87 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 88 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 89 1.10 christos HOW (R_PARISC_DLTREL14R, 4, 14, false, bitfield, 0), 90 1.10 christos HOW (R_PARISC_DLTREL14F, 4, 14, false, bitfield, 0), 91 1.1 christos /* 32 */ 92 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 93 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 94 1.10 christos HOW (R_PARISC_DLTIND21L, 4, 21, false, bitfield, 0), 95 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 96 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 97 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 98 1.10 christos HOW (R_PARISC_DLTIND14R, 4, 14, false, bitfield, 0), 99 1.10 christos HOW (R_PARISC_DLTIND14F, 4, 14, false, bitfield, 0), 100 1.1 christos /* 40 */ 101 1.10 christos HOW (R_PARISC_SETBASE, 0, 0, false, bitfield, 0), 102 1.10 christos HOW (R_PARISC_SECREL32, 4, 32, false, bitfield, 0xffffffff), 103 1.10 christos HOW (R_PARISC_BASEREL21L, 4, 21, false, bitfield, 0), 104 1.10 christos HOW (R_PARISC_BASEREL17R, 4, 17, false, bitfield, 0), 105 1.10 christos HOW (R_PARISC_BASEREL17F, 4, 17, false, bitfield, 0), 106 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 107 1.10 christos HOW (R_PARISC_BASEREL14R, 4, 14, false, bitfield, 0), 108 1.10 christos HOW (R_PARISC_BASEREL14F, 4, 14, false, bitfield, 0), 109 1.1 christos /* 48 */ 110 1.10 christos HOW (R_PARISC_SEGBASE, 0, 0, false, bitfield, 0), 111 1.10 christos HOW (R_PARISC_SEGREL32, 4, 32, false, bitfield, 0), 112 1.10 christos HOW (R_PARISC_PLTOFF21L, 4, 21, false, bitfield, 0), 113 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 114 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 115 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 116 1.10 christos HOW (R_PARISC_PLTOFF14R, 4, 14, false, bitfield, 0), 117 1.10 christos HOW (R_PARISC_PLTOFF14F, 4, 14, false, bitfield, 0), 118 1.1 christos /* 56 */ 119 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 120 1.10 christos HOW (R_PARISC_LTOFF_FPTR32, 4, 32, false, bitfield, 0), 121 1.10 christos HOW (R_PARISC_LTOFF_FPTR21L, 4, 21, false, bitfield, 0), 122 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 123 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 124 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 125 1.10 christos HOW (R_PARISC_LTOFF_FPTR14R, 4, 14, false, bitfield, 0), 126 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 127 1.1 christos /* 64 */ 128 1.10 christos HOW (R_PARISC_FPTR64, 8, 64, false, bitfield, 0), 129 1.10 christos HOW (R_PARISC_PLABEL32, 4, 32, false, bitfield, 0), 130 1.10 christos HOW (R_PARISC_PLABEL21L, 4, 21, false, bitfield, 0), 131 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 132 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 133 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 134 1.10 christos HOW (R_PARISC_PLABEL14R, 4, 14, false, bitfield, 0), 135 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 136 1.1 christos /* 72 */ 137 1.10 christos HOW (R_PARISC_PCREL64, 8, 64, false, bitfield, 0), 138 1.10 christos HOW (R_PARISC_PCREL22C, 4, 22, false, bitfield, 0), 139 1.10 christos HOW (R_PARISC_PCREL22F, 4, 22, false, bitfield, 0), 140 1.10 christos HOW (R_PARISC_PCREL14WR, 4, 14, false, bitfield, 0), 141 1.10 christos HOW (R_PARISC_PCREL14DR, 4, 14, false, bitfield, 0), 142 1.10 christos HOW (R_PARISC_PCREL16F, 4, 16, false, bitfield, 0), 143 1.10 christos HOW (R_PARISC_PCREL16WF, 4, 16, false, bitfield, 0), 144 1.10 christos HOW (R_PARISC_PCREL16DF, 4, 16, false, bitfield, 0), 145 1.1 christos /* 80 */ 146 1.10 christos HOW (R_PARISC_DIR64, 8, 64, false, bitfield, 0), 147 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 148 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 149 1.10 christos HOW (R_PARISC_DIR14WR, 4, 14, false, bitfield, 0), 150 1.10 christos HOW (R_PARISC_DIR14DR, 4, 14, false, bitfield, 0), 151 1.10 christos HOW (R_PARISC_DIR16F, 4, 16, false, bitfield, 0), 152 1.10 christos HOW (R_PARISC_DIR16WF, 4, 16, false, bitfield, 0), 153 1.10 christos HOW (R_PARISC_DIR16DF, 4, 16, false, bitfield, 0), 154 1.1 christos /* 88 */ 155 1.10 christos HOW (R_PARISC_GPREL64, 8, 64, false, bitfield, 0), 156 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 157 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 158 1.10 christos HOW (R_PARISC_DLTREL14WR, 4, 14, false, bitfield, 0), 159 1.10 christos HOW (R_PARISC_DLTREL14DR, 4, 14, false, bitfield, 0), 160 1.10 christos HOW (R_PARISC_GPREL16F, 4, 16, false, bitfield, 0), 161 1.10 christos HOW (R_PARISC_GPREL16WF, 4, 16, false, bitfield, 0), 162 1.10 christos HOW (R_PARISC_GPREL16DF, 4, 16, false, bitfield, 0), 163 1.1 christos /* 96 */ 164 1.10 christos HOW (R_PARISC_LTOFF64, 8, 64, false, bitfield, 0), 165 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 166 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 167 1.10 christos HOW (R_PARISC_DLTIND14WR, 4, 14, false, bitfield, 0), 168 1.10 christos HOW (R_PARISC_DLTIND14DR, 4, 14, false, bitfield, 0), 169 1.10 christos HOW (R_PARISC_LTOFF16F, 4, 16, false, bitfield, 0), 170 1.10 christos HOW (R_PARISC_LTOFF16WF, 4, 16, false, bitfield, 0), 171 1.10 christos HOW (R_PARISC_LTOFF16DF, 4, 16, false, bitfield, 0), 172 1.1 christos /* 104 */ 173 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 174 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 175 1.10 christos HOW (R_PARISC_BASEREL14WR, 4, 14, false, bitfield, 0), 176 1.10 christos HOW (R_PARISC_BASEREL14DR, 4, 14, false, bitfield, 0), 177 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 178 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 179 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 180 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 181 1.1 christos /* 112 */ 182 1.10 christos HOW (R_PARISC_SEGREL64, 8, 64, false, bitfield, 0), 183 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 184 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 185 1.10 christos HOW (R_PARISC_PLTOFF14WR, 4, 14, false, bitfield, 0), 186 1.10 christos HOW (R_PARISC_PLTOFF14DR, 4, 14, false, bitfield, 0), 187 1.10 christos HOW (R_PARISC_PLTOFF16F, 4, 16, false, bitfield, 0), 188 1.10 christos HOW (R_PARISC_PLTOFF16WF, 4, 16, false, bitfield, 0), 189 1.10 christos HOW (R_PARISC_PLTOFF16DF, 4, 16, false, bitfield, 0), 190 1.1 christos /* 120 */ 191 1.10 christos HOW (R_PARISC_LTOFF_FPTR64, 8, 64, false, bitfield, 0), 192 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 193 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 194 1.10 christos HOW (R_PARISC_LTOFF_FPTR14WR, 4, 14, false, bitfield, 0), 195 1.10 christos HOW (R_PARISC_LTOFF_FPTR14DR, 4, 14, false, bitfield, 0), 196 1.10 christos HOW (R_PARISC_LTOFF_FPTR16F, 4, 16, false, bitfield, 0), 197 1.10 christos HOW (R_PARISC_LTOFF_FPTR16WF, 4, 16, false, bitfield, 0), 198 1.10 christos HOW (R_PARISC_LTOFF_FPTR16DF, 4, 16, false, bitfield, 0), 199 1.1 christos /* 128 */ 200 1.10 christos HOW (R_PARISC_COPY, 0, 0, false, bitfield, 0), 201 1.10 christos HOW (R_PARISC_IPLT, 0, 0, false, bitfield, 0), 202 1.10 christos HOW (R_PARISC_EPLT, 0, 0, false, bitfield, 0), 203 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 204 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 205 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 206 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 207 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 208 1.1 christos /* 136 */ 209 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 210 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 211 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 212 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 213 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 214 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 215 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 216 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 217 1.1 christos /* 144 */ 218 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 219 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 220 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 221 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 222 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 223 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 224 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 225 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 226 1.1 christos /* 152 */ 227 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 228 1.10 christos HOW (R_PARISC_TPREL32, 4, 32, false, dont, 0), 229 1.10 christos HOW (R_PARISC_TPREL21L, 4, 21, false, bitfield, 0), 230 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 231 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 232 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 233 1.10 christos HOW (R_PARISC_TPREL14R, 4, 14, false, bitfield, 0), 234 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 235 1.1 christos /* 160 */ 236 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 237 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 238 1.10 christos HOW (R_PARISC_LTOFF_TP21L, 4, 21, false, bitfield, 0), 239 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 240 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 241 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 242 1.10 christos HOW (R_PARISC_LTOFF_TP14R, 4, 14, false, bitfield, 0), 243 1.10 christos HOW (R_PARISC_LTOFF_TP14F, 4, 14, false, bitfield, 0), 244 1.1 christos /* 168 */ 245 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 246 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 247 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 248 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 249 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 250 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 251 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 252 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 253 1.1 christos /* 176 */ 254 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 255 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 256 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 257 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 258 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 259 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 260 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 261 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 262 1.1 christos /* 184 */ 263 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 264 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 265 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 266 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 267 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 268 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 269 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 270 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 271 1.1 christos /* 192 */ 272 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 273 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 274 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 275 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 276 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 277 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 278 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 279 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 280 1.1 christos /* 200 */ 281 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 282 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 283 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 284 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 285 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 286 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 287 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 288 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 289 1.1 christos /* 208 */ 290 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 291 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 292 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 293 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 294 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0), 295 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 296 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 297 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 298 1.1 christos /* 216 */ 299 1.10 christos HOW (R_PARISC_TPREL64, 8, 64, false, bitfield, 0), 300 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 301 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 302 1.10 christos HOW (R_PARISC_TPREL14WR, 4, 14, false, dont, 0), 303 1.10 christos HOW (R_PARISC_TPREL14DR, 4, 14, false, bitfield, 0), 304 1.10 christos HOW (R_PARISC_TPREL16F, 4, 16, false, bitfield, 0), 305 1.10 christos HOW (R_PARISC_TPREL16WF, 4, 16, false, dont, 0), 306 1.10 christos HOW (R_PARISC_TPREL16DF, 4, 16, false, bitfield, 0), 307 1.1 christos /* 224 */ 308 1.10 christos HOW (R_PARISC_LTOFF_TP64, 8, 64, false, bitfield, 0), 309 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 310 1.10 christos HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0), 311 1.10 christos HOW (R_PARISC_LTOFF_TP14WR, 4, 14, false, bitfield, 0), 312 1.10 christos HOW (R_PARISC_LTOFF_TP14DR, 4, 14, false, bitfield, 0), 313 1.10 christos HOW (R_PARISC_LTOFF_TP16F, 4, 16, false, dont, 0), 314 1.10 christos HOW (R_PARISC_LTOFF_TP16WF, 4, 16, false, bitfield, 0), 315 1.10 christos HOW (R_PARISC_LTOFF_TP16DF, 4, 16, false, bitfield, 0), 316 1.1 christos /* 232 */ 317 1.10 christos HOW (R_PARISC_GNU_VTENTRY, 0, 0, false, dont, 0), 318 1.10 christos HOW (R_PARISC_GNU_VTINHERIT, 0, 0, false, dont, 0), 319 1.10 christos HOW (R_PARISC_TLS_GD21L, 4, 21, false, bitfield, 0), 320 1.10 christos HOW (R_PARISC_TLS_GD14R, 4, 14, false, bitfield, 0), 321 1.10 christos HOW (R_PARISC_TLS_GDCALL, 0, 0, false, dont, 0), 322 1.10 christos HOW (R_PARISC_TLS_LDM21L, 4, 21, false, bitfield, 0), 323 1.10 christos HOW (R_PARISC_TLS_LDM14R, 4, 14, false, bitfield, 0), 324 1.10 christos HOW (R_PARISC_TLS_LDMCALL, 0, 0, false, dont, 0), 325 1.1 christos /* 240 */ 326 1.10 christos HOW (R_PARISC_TLS_LDO21L, 4, 21, false, bitfield, 0), 327 1.10 christos HOW (R_PARISC_TLS_LDO14R, 4, 14, false, bitfield, 0), 328 1.10 christos HOW (R_PARISC_TLS_DTPMOD32, 4, 32, false, bitfield, 0), 329 1.10 christos HOW (R_PARISC_TLS_DTPMOD64, 8, 64, false, bitfield, 0), 330 1.10 christos HOW (R_PARISC_TLS_DTPOFF32, 4, 32, false, bitfield, 0), 331 1.10 christos HOW (R_PARISC_TLS_DTPOFF64, 8, 64, false, bitfield, 0) 332 1.8 christos #undef HOW 333 1.1 christos }; 334 1.1 christos 335 1.1 christos #define OFFSET_14R_FROM_21L 4 336 1.1 christos #define OFFSET_14F_FROM_21L 5 337 1.1 christos 338 1.1 christos /* Return the final relocation type for the given base type, instruction 339 1.1 christos format, and field selector. */ 340 1.1 christos 341 1.1 christos elf_hppa_reloc_type 342 1.1 christos elf_hppa_reloc_final_type (bfd *abfd, 343 1.1 christos elf_hppa_reloc_type base_type, 344 1.1 christos int format, 345 1.1 christos unsigned int field) 346 1.1 christos { 347 1.1 christos elf_hppa_reloc_type final_type = base_type; 348 1.1 christos 349 1.1 christos /* Just a tangle of nested switch statements to deal with the braindamage 350 1.1 christos that a different field selector means a completely different relocation 351 1.1 christos for PA ELF. */ 352 1.1 christos switch (base_type) 353 1.1 christos { 354 1.1 christos /* We have been using generic relocation types. However, that may not 355 1.1 christos really make sense. Anyway, we need to support both R_PARISC_DIR64 356 1.1 christos and R_PARISC_DIR32 here. */ 357 1.1 christos case R_PARISC_DIR32: 358 1.1 christos case R_PARISC_DIR64: 359 1.1 christos case R_HPPA_ABS_CALL: 360 1.1 christos switch (format) 361 1.1 christos { 362 1.1 christos case 14: 363 1.1 christos switch (field) 364 1.1 christos { 365 1.1 christos case e_fsel: 366 1.1 christos final_type = R_PARISC_DIR14F; 367 1.1 christos break; 368 1.1 christos case e_rsel: 369 1.1 christos case e_rrsel: 370 1.1 christos case e_rdsel: 371 1.1 christos final_type = R_PARISC_DIR14R; 372 1.1 christos break; 373 1.1 christos case e_rtsel: 374 1.1 christos final_type = R_PARISC_DLTIND14R; 375 1.1 christos break; 376 1.1 christos case e_rtpsel: 377 1.1 christos final_type = R_PARISC_LTOFF_FPTR14DR; 378 1.1 christos break; 379 1.1 christos case e_tsel: 380 1.1 christos final_type = R_PARISC_DLTIND14F; 381 1.1 christos break; 382 1.1 christos case e_rpsel: 383 1.1 christos final_type = R_PARISC_PLABEL14R; 384 1.1 christos break; 385 1.1 christos default: 386 1.1 christos return R_PARISC_NONE; 387 1.1 christos } 388 1.1 christos break; 389 1.1 christos 390 1.1 christos case 17: 391 1.1 christos switch (field) 392 1.1 christos { 393 1.1 christos case e_fsel: 394 1.1 christos final_type = R_PARISC_DIR17F; 395 1.1 christos break; 396 1.1 christos case e_rsel: 397 1.1 christos case e_rrsel: 398 1.1 christos case e_rdsel: 399 1.1 christos final_type = R_PARISC_DIR17R; 400 1.1 christos break; 401 1.1 christos default: 402 1.1 christos return R_PARISC_NONE; 403 1.1 christos } 404 1.1 christos break; 405 1.1 christos 406 1.1 christos case 21: 407 1.1 christos switch (field) 408 1.1 christos { 409 1.1 christos case e_lsel: 410 1.1 christos case e_lrsel: 411 1.1 christos case e_ldsel: 412 1.1 christos case e_nlsel: 413 1.1 christos case e_nlrsel: 414 1.1 christos final_type = R_PARISC_DIR21L; 415 1.1 christos break; 416 1.1 christos case e_ltsel: 417 1.1 christos final_type = R_PARISC_DLTIND21L; 418 1.1 christos break; 419 1.1 christos case e_ltpsel: 420 1.1 christos final_type = R_PARISC_LTOFF_FPTR21L; 421 1.1 christos break; 422 1.1 christos case e_lpsel: 423 1.1 christos final_type = R_PARISC_PLABEL21L; 424 1.1 christos break; 425 1.1 christos default: 426 1.1 christos return R_PARISC_NONE; 427 1.1 christos } 428 1.1 christos break; 429 1.1 christos 430 1.1 christos case 32: 431 1.1 christos switch (field) 432 1.1 christos { 433 1.1 christos case e_fsel: 434 1.1 christos final_type = R_PARISC_DIR32; 435 1.1 christos /* When in 64bit mode, a 32bit relocation is supposed to 436 1.1 christos be a section relative relocation. Dwarf2 (for example) 437 1.1 christos uses 32bit section relative relocations. */ 438 1.1 christos if (bfd_arch_bits_per_address (abfd) != 32) 439 1.1 christos final_type = R_PARISC_SECREL32; 440 1.1 christos break; 441 1.1 christos case e_psel: 442 1.1 christos final_type = R_PARISC_PLABEL32; 443 1.1 christos break; 444 1.1 christos default: 445 1.1 christos return R_PARISC_NONE; 446 1.1 christos } 447 1.1 christos break; 448 1.1 christos 449 1.1 christos case 64: 450 1.1 christos switch (field) 451 1.1 christos { 452 1.1 christos case e_fsel: 453 1.1 christos final_type = R_PARISC_DIR64; 454 1.1 christos break; 455 1.1 christos case e_psel: 456 1.1 christos final_type = R_PARISC_FPTR64; 457 1.1 christos break; 458 1.1 christos default: 459 1.1 christos return R_PARISC_NONE; 460 1.1 christos } 461 1.1 christos break; 462 1.1 christos 463 1.1 christos default: 464 1.1 christos return R_PARISC_NONE; 465 1.1 christos } 466 1.1 christos break; 467 1.1 christos 468 1.1 christos case R_HPPA_GOTOFF: 469 1.1 christos switch (format) 470 1.1 christos { 471 1.1 christos case 14: 472 1.1 christos switch (field) 473 1.1 christos { 474 1.1 christos case e_rsel: 475 1.1 christos case e_rrsel: 476 1.1 christos case e_rdsel: 477 1.1 christos /* R_PARISC_DLTREL14R for elf64, R_PARISC_DPREL14R for elf32. */ 478 1.1 christos final_type = base_type + OFFSET_14R_FROM_21L; 479 1.1 christos break; 480 1.1 christos case e_fsel: 481 1.1 christos /* R_PARISC_DLTREL14F for elf64, R_PARISC_DPREL14F for elf32. */ 482 1.1 christos final_type = base_type + OFFSET_14F_FROM_21L; 483 1.1 christos break; 484 1.1 christos default: 485 1.1 christos return R_PARISC_NONE; 486 1.1 christos } 487 1.1 christos break; 488 1.1 christos 489 1.1 christos case 21: 490 1.1 christos switch (field) 491 1.1 christos { 492 1.1 christos case e_lsel: 493 1.1 christos case e_lrsel: 494 1.1 christos case e_ldsel: 495 1.1 christos case e_nlsel: 496 1.1 christos case e_nlrsel: 497 1.1 christos /* R_PARISC_DLTREL21L for elf64, R_PARISC_DPREL21L for elf32. */ 498 1.1 christos final_type = base_type; 499 1.1 christos break; 500 1.1 christos default: 501 1.1 christos return R_PARISC_NONE; 502 1.1 christos } 503 1.1 christos break; 504 1.1 christos 505 1.1 christos case 64: 506 1.1 christos switch (field) 507 1.1 christos { 508 1.1 christos case e_fsel: 509 1.1 christos final_type = R_PARISC_GPREL64; 510 1.1 christos break; 511 1.1 christos default: 512 1.1 christos return R_PARISC_NONE; 513 1.1 christos } 514 1.1 christos break; 515 1.1 christos 516 1.1 christos default: 517 1.1 christos return R_PARISC_NONE; 518 1.1 christos } 519 1.1 christos break; 520 1.1 christos 521 1.1 christos case R_HPPA_PCREL_CALL: 522 1.1 christos switch (format) 523 1.1 christos { 524 1.1 christos case 12: 525 1.1 christos switch (field) 526 1.1 christos { 527 1.1 christos case e_fsel: 528 1.1 christos final_type = R_PARISC_PCREL12F; 529 1.1 christos break; 530 1.1 christos default: 531 1.1 christos return R_PARISC_NONE; 532 1.1 christos } 533 1.1 christos break; 534 1.1 christos 535 1.1 christos case 14: 536 1.1 christos /* Contrary to appearances, these are not calls of any sort. 537 1.1 christos Rather, they are loads/stores with a pcrel reloc. */ 538 1.1 christos switch (field) 539 1.1 christos { 540 1.1 christos case e_rsel: 541 1.1 christos case e_rrsel: 542 1.1 christos case e_rdsel: 543 1.1 christos final_type = R_PARISC_PCREL14R; 544 1.1 christos break; 545 1.1 christos case e_fsel: 546 1.1 christos if (bfd_get_mach (abfd) < 25) 547 1.1 christos final_type = R_PARISC_PCREL14F; 548 1.1 christos else 549 1.1 christos final_type = R_PARISC_PCREL16F; 550 1.1 christos break; 551 1.1 christos default: 552 1.1 christos return R_PARISC_NONE; 553 1.1 christos } 554 1.1 christos break; 555 1.1 christos 556 1.1 christos case 17: 557 1.1 christos switch (field) 558 1.1 christos { 559 1.1 christos case e_rsel: 560 1.1 christos case e_rrsel: 561 1.1 christos case e_rdsel: 562 1.1 christos final_type = R_PARISC_PCREL17R; 563 1.1 christos break; 564 1.1 christos case e_fsel: 565 1.1 christos final_type = R_PARISC_PCREL17F; 566 1.1 christos break; 567 1.1 christos default: 568 1.1 christos return R_PARISC_NONE; 569 1.1 christos } 570 1.1 christos break; 571 1.1 christos 572 1.1 christos case 21: 573 1.1 christos switch (field) 574 1.1 christos { 575 1.1 christos case e_lsel: 576 1.1 christos case e_lrsel: 577 1.1 christos case e_ldsel: 578 1.1 christos case e_nlsel: 579 1.1 christos case e_nlrsel: 580 1.1 christos final_type = R_PARISC_PCREL21L; 581 1.1 christos break; 582 1.1 christos default: 583 1.1 christos return R_PARISC_NONE; 584 1.1 christos } 585 1.1 christos break; 586 1.1 christos 587 1.1 christos case 22: 588 1.1 christos switch (field) 589 1.1 christos { 590 1.1 christos case e_fsel: 591 1.1 christos final_type = R_PARISC_PCREL22F; 592 1.1 christos break; 593 1.1 christos default: 594 1.1 christos return R_PARISC_NONE; 595 1.1 christos } 596 1.1 christos break; 597 1.1 christos 598 1.1 christos case 32: 599 1.1 christos switch (field) 600 1.1 christos { 601 1.1 christos case e_fsel: 602 1.1 christos final_type = R_PARISC_PCREL32; 603 1.1 christos break; 604 1.1 christos default: 605 1.1 christos return R_PARISC_NONE; 606 1.1 christos } 607 1.1 christos break; 608 1.1 christos 609 1.1 christos case 64: 610 1.1 christos switch (field) 611 1.1 christos { 612 1.1 christos case e_fsel: 613 1.1 christos final_type = R_PARISC_PCREL64; 614 1.1 christos break; 615 1.1 christos default: 616 1.1 christos return R_PARISC_NONE; 617 1.1 christos } 618 1.1 christos break; 619 1.1 christos 620 1.1 christos default: 621 1.1 christos return R_PARISC_NONE; 622 1.1 christos } 623 1.1 christos break; 624 1.1 christos 625 1.1 christos case R_PARISC_TLS_GD21L: 626 1.1 christos switch (field) 627 1.1 christos { 628 1.1 christos case e_ltsel: 629 1.1 christos case e_lrsel: 630 1.1 christos final_type = R_PARISC_TLS_GD21L; 631 1.1 christos break; 632 1.1 christos case e_rtsel: 633 1.1 christos case e_rrsel: 634 1.1 christos final_type = R_PARISC_TLS_GD14R; 635 1.1 christos break; 636 1.1 christos default: 637 1.1 christos return R_PARISC_NONE; 638 1.1 christos } 639 1.1 christos break; 640 1.1 christos 641 1.1 christos case R_PARISC_TLS_LDM21L: 642 1.1 christos switch (field) 643 1.1 christos { 644 1.1 christos case e_ltsel: 645 1.1 christos case e_lrsel: 646 1.1 christos final_type = R_PARISC_TLS_LDM21L; 647 1.1 christos break; 648 1.1 christos case e_rtsel: 649 1.1 christos case e_rrsel: 650 1.1 christos final_type = R_PARISC_TLS_LDM14R; 651 1.1 christos break; 652 1.1 christos default: 653 1.1 christos return R_PARISC_NONE; 654 1.1 christos } 655 1.1 christos break; 656 1.1 christos 657 1.1 christos case R_PARISC_TLS_LDO21L: 658 1.1 christos switch (field) 659 1.1 christos { 660 1.1 christos case e_lrsel: 661 1.1 christos final_type = R_PARISC_TLS_LDO21L; 662 1.1 christos break; 663 1.1 christos case e_rrsel: 664 1.1 christos final_type = R_PARISC_TLS_LDO14R; 665 1.1 christos break; 666 1.1 christos default: 667 1.1 christos return R_PARISC_NONE; 668 1.1 christos } 669 1.1 christos break; 670 1.1 christos 671 1.1 christos case R_PARISC_TLS_IE21L: 672 1.1 christos switch (field) 673 1.1 christos { 674 1.1 christos case e_ltsel: 675 1.1 christos case e_lrsel: 676 1.1 christos final_type = R_PARISC_TLS_IE21L; 677 1.1 christos break; 678 1.1 christos case e_rtsel: 679 1.1 christos case e_rrsel: 680 1.1 christos final_type = R_PARISC_TLS_IE14R; 681 1.1 christos break; 682 1.1 christos default: 683 1.1 christos return R_PARISC_NONE; 684 1.1 christos } 685 1.1 christos break; 686 1.1 christos 687 1.1 christos case R_PARISC_TLS_LE21L: 688 1.1 christos switch (field) 689 1.1 christos { 690 1.1 christos case e_lrsel: 691 1.1 christos final_type = R_PARISC_TLS_LE21L; 692 1.1 christos break; 693 1.1 christos case e_rrsel: 694 1.1 christos final_type = R_PARISC_TLS_LE14R; 695 1.1 christos break; 696 1.1 christos default: 697 1.1 christos return R_PARISC_NONE; 698 1.1 christos } 699 1.1 christos break; 700 1.1 christos 701 1.1 christos case R_PARISC_SEGREL32: 702 1.1 christos switch (format) 703 1.1 christos { 704 1.1 christos case 32: 705 1.1 christos switch (field) 706 1.1 christos { 707 1.1 christos case e_fsel: 708 1.1 christos final_type = R_PARISC_SEGREL32; 709 1.1 christos break; 710 1.1 christos default: 711 1.1 christos return R_PARISC_NONE; 712 1.1 christos } 713 1.1 christos break; 714 1.1 christos 715 1.1 christos case 64: 716 1.1 christos switch (field) 717 1.1 christos { 718 1.1 christos case e_fsel: 719 1.1 christos final_type = R_PARISC_SEGREL64; 720 1.1 christos break; 721 1.1 christos default: 722 1.1 christos return R_PARISC_NONE; 723 1.1 christos } 724 1.1 christos break; 725 1.1 christos 726 1.1 christos default: 727 1.1 christos return R_PARISC_NONE; 728 1.1 christos } 729 1.1 christos break; 730 1.1 christos 731 1.1 christos case R_PARISC_GNU_VTENTRY: 732 1.1 christos case R_PARISC_GNU_VTINHERIT: 733 1.1 christos case R_PARISC_SEGBASE: 734 1.1 christos /* The defaults are fine for these cases. */ 735 1.1 christos break; 736 1.1 christos 737 1.1 christos default: 738 1.1 christos return R_PARISC_NONE; 739 1.1 christos } 740 1.1 christos 741 1.1 christos return final_type; 742 1.1 christos } 743 1.1 christos 744 1.1 christos /* Return one (or more) BFD relocations which implement the base 745 1.1 christos relocation with modifications based on format and field. */ 746 1.1 christos 747 1.1 christos elf_hppa_reloc_type ** 748 1.1 christos _bfd_elf_hppa_gen_reloc_type (bfd *abfd, 749 1.1 christos elf_hppa_reloc_type base_type, 750 1.1 christos int format, 751 1.1 christos unsigned int field, 752 1.1 christos int ignore ATTRIBUTE_UNUSED, 753 1.1 christos asymbol *sym ATTRIBUTE_UNUSED) 754 1.1 christos { 755 1.1 christos elf_hppa_reloc_type *finaltype; 756 1.1 christos elf_hppa_reloc_type **final_types; 757 1.9 christos size_t amt = sizeof (elf_hppa_reloc_type *) * 2; 758 1.1 christos 759 1.1 christos /* Allocate slots for the BFD relocation. */ 760 1.1 christos final_types = bfd_alloc (abfd, amt); 761 1.1 christos if (final_types == NULL) 762 1.1 christos return NULL; 763 1.1 christos 764 1.1 christos /* Allocate space for the relocation itself. */ 765 1.1 christos amt = sizeof (elf_hppa_reloc_type); 766 1.1 christos finaltype = bfd_alloc (abfd, amt); 767 1.1 christos if (finaltype == NULL) 768 1.1 christos return NULL; 769 1.1 christos 770 1.1 christos /* Some reasonable defaults. */ 771 1.1 christos final_types[0] = finaltype; 772 1.1 christos final_types[1] = NULL; 773 1.1 christos 774 1.1 christos *finaltype = elf_hppa_reloc_final_type (abfd, base_type, format, field); 775 1.1 christos 776 1.1 christos return final_types; 777 1.1 christos } 778 1.1 christos 779 1.1 christos /* Translate from an elf into field into a howto relocation pointer. */ 780 1.1 christos 781 1.10 christos static bool 782 1.8 christos elf_hppa_info_to_howto (bfd *abfd, 783 1.1 christos arelent *bfd_reloc, 784 1.1 christos Elf_Internal_Rela *elf_reloc) 785 1.1 christos { 786 1.8 christos unsigned int r_type = ELF32_R_TYPE (elf_reloc->r_info); 787 1.8 christos unsigned int type = r_type; 788 1.8 christos reloc_howto_type *howto = NULL; 789 1.8 christos 790 1.8 christos if (r_type < (unsigned int) R_PARISC_UNIMPLEMENTED) 791 1.8 christos { 792 1.8 christos howto = &elf_hppa_howto_table[r_type]; 793 1.8 christos type = howto->type; 794 1.8 christos } 795 1.8 christos if (type >= (unsigned int) R_PARISC_UNIMPLEMENTED) 796 1.8 christos { 797 1.8 christos /* xgettext:c-format */ 798 1.8 christos _bfd_error_handler (_("%pB: unsupported relocation type %#x"), 799 1.8 christos abfd, r_type); 800 1.8 christos bfd_set_error (bfd_error_bad_value); 801 1.10 christos return false; 802 1.8 christos } 803 1.8 christos bfd_reloc->howto = howto; 804 1.10 christos return true; 805 1.1 christos } 806 1.1 christos 807 1.1 christos /* Translate from an elf into field into a howto relocation pointer. */ 808 1.1 christos 809 1.10 christos static bool 810 1.8 christos elf_hppa_info_to_howto_rel (bfd *abfd, 811 1.1 christos arelent *bfd_reloc, 812 1.1 christos Elf_Internal_Rela *elf_reloc) 813 1.1 christos { 814 1.8 christos unsigned int r_type = ELF_R_TYPE (elf_reloc->r_info); 815 1.8 christos unsigned int type = r_type; 816 1.8 christos reloc_howto_type *howto = NULL; 817 1.8 christos 818 1.8 christos if (r_type < (unsigned int) R_PARISC_UNIMPLEMENTED) 819 1.8 christos { 820 1.8 christos howto = &elf_hppa_howto_table[r_type]; 821 1.8 christos type = howto->type; 822 1.8 christos } 823 1.8 christos if (type >= (unsigned int) R_PARISC_UNIMPLEMENTED) 824 1.8 christos { 825 1.8 christos /* xgettext:c-format */ 826 1.8 christos _bfd_error_handler (_("%pB: unsupported relocation type %#x"), 827 1.8 christos abfd, r_type); 828 1.8 christos bfd_set_error (bfd_error_bad_value); 829 1.10 christos return false; 830 1.8 christos } 831 1.8 christos bfd_reloc->howto = howto; 832 1.10 christos return true; 833 1.1 christos } 834 1.1 christos 835 1.1 christos /* Return the address of the howto table entry to perform the CODE 836 1.1 christos relocation for an ARCH machine. */ 837 1.1 christos 838 1.1 christos static reloc_howto_type * 839 1.1 christos elf_hppa_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, 840 1.1 christos bfd_reloc_code_real_type code) 841 1.1 christos { 842 1.1 christos if ((int) code < (int) R_PARISC_UNIMPLEMENTED) 843 1.1 christos { 844 1.1 christos BFD_ASSERT ((int) elf_hppa_howto_table[(int) code].type == (int) code); 845 1.1 christos return &elf_hppa_howto_table[(int) code]; 846 1.1 christos } 847 1.1 christos return NULL; 848 1.1 christos } 849 1.1 christos 850 1.1 christos static reloc_howto_type * 851 1.1 christos elf_hppa_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, 852 1.1 christos const char *r_name) 853 1.1 christos { 854 1.1 christos unsigned int i; 855 1.1 christos 856 1.1 christos for (i = 0; 857 1.1 christos i < sizeof (elf_hppa_howto_table) / sizeof (elf_hppa_howto_table[0]); 858 1.1 christos i++) 859 1.1 christos if (elf_hppa_howto_table[i].name != NULL 860 1.1 christos && strcasecmp (elf_hppa_howto_table[i].name, r_name) == 0) 861 1.1 christos return &elf_hppa_howto_table[i]; 862 1.1 christos 863 1.1 christos return NULL; 864 1.1 christos } 865 1.1 christos 866 1.1 christos /* Return TRUE if SYM represents a local label symbol. */ 867 1.1 christos 868 1.10 christos static bool 869 1.1 christos elf_hppa_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name) 870 1.1 christos { 871 1.1 christos if (name[0] == 'L' && name[1] == '$') 872 1.10 christos return true; 873 1.1 christos return _bfd_elf_is_local_label_name (abfd, name); 874 1.1 christos } 875 1.1 christos 876 1.1 christos /* Set the correct type for an ELF section. We do this by the 877 1.1 christos section name, which is a hack, but ought to work. */ 878 1.1 christos 879 1.10 christos static bool 880 1.1 christos elf_hppa_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec) 881 1.1 christos { 882 1.1 christos const char *name; 883 1.1 christos 884 1.9 christos name = bfd_section_name (sec); 885 1.1 christos 886 1.1 christos if (strcmp (name, ".PARISC.unwind") == 0) 887 1.1 christos { 888 1.1 christos int indx; 889 1.1 christos asection *asec; 890 1.1 christos 891 1.1 christos #if ARCH_SIZE == 64 892 1.8 christos hdr->sh_type = SHT_PARISC_UNWIND; 893 1.1 christos #else 894 1.8 christos /* Note - it is not clear why this is not SHT_PARISC_UNWIND as well. 895 1.8 christos Presumably it is a historical constraint, so leave it as it is. */ 896 1.8 christos hdr->sh_type = SHT_PROGBITS; 897 1.1 christos #endif 898 1.1 christos /* ?!? How are unwinds supposed to work for symbols in arbitrary 899 1.1 christos sections? Or what if we have multiple .text sections in a single 900 1.1 christos .o file? HP really messed up on this one. 901 1.1 christos 902 1.1 christos Ugh. We can not use elf_section_data (sec)->this_idx at this 903 1.1 christos point because it is not initialized yet. 904 1.1 christos 905 1.1 christos So we (gasp) recompute it here. Hopefully nobody ever changes the 906 1.1 christos way sections are numbered in elf.c! */ 907 1.1 christos for (asec = abfd->sections, indx = 1; asec; asec = asec->next, indx++) 908 1.1 christos { 909 1.1 christos if (asec->name && strcmp (asec->name, ".text") == 0) 910 1.1 christos { 911 1.1 christos hdr->sh_info = indx; 912 1.7 christos hdr->sh_flags |= SHF_INFO_LINK; 913 1.1 christos break; 914 1.1 christos } 915 1.1 christos } 916 1.1 christos 917 1.8 christos /* The unwind table entries are 16 bytes long, so it is not clear 918 1.8 christos why this field is set to 4. (The ELF spec says that the sh_entsize 919 1.8 christos field is a byte quantity, but this is a processor specific section, 920 1.8 christos so it is allowed to change the rules). Leave as it is for now. */ 921 1.1 christos hdr->sh_entsize = 4; 922 1.1 christos } 923 1.10 christos return true; 924 1.1 christos } 925 1.1 christos 926 1.10 christos static bool 927 1.9 christos elf_hppa_final_write_processing (bfd *abfd) 928 1.1 christos { 929 1.1 christos int mach = bfd_get_mach (abfd); 930 1.1 christos 931 1.1 christos elf_elfheader (abfd)->e_flags &= ~(EF_PARISC_ARCH | EF_PARISC_TRAPNIL 932 1.1 christos | EF_PARISC_EXT | EF_PARISC_LSB 933 1.1 christos | EF_PARISC_WIDE | EF_PARISC_NO_KABP 934 1.1 christos | EF_PARISC_LAZYSWAP); 935 1.1 christos 936 1.1 christos if (mach == 10) 937 1.1 christos elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_0; 938 1.1 christos else if (mach == 11) 939 1.1 christos elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_1; 940 1.1 christos else if (mach == 20) 941 1.1 christos elf_elfheader (abfd)->e_flags |= EFA_PARISC_2_0; 942 1.1 christos else if (mach == 25) 943 1.1 christos elf_elfheader (abfd)->e_flags |= (EF_PARISC_WIDE 944 1.1 christos | EFA_PARISC_2_0 945 1.1 christos /* The GNU tools have trapped without 946 1.1 christos option since 1993, so need to take 947 1.1 christos a step backwards with the ELF 948 1.1 christos based toolchains. */ 949 1.1 christos | EF_PARISC_TRAPNIL); 950 1.9 christos return _bfd_elf_final_write_processing (abfd); 951 1.1 christos } 952 1.1 christos 953 1.1 christos /* Comparison function for qsort to sort unwind section during a 954 1.1 christos final link. */ 955 1.1 christos 956 1.1 christos static int 957 1.1 christos hppa_unwind_entry_compare (const void *a, const void *b) 958 1.1 christos { 959 1.1 christos const bfd_byte *ap, *bp; 960 1.1 christos unsigned long av, bv; 961 1.1 christos 962 1.1 christos ap = a; 963 1.1 christos av = (unsigned long) ap[0] << 24; 964 1.1 christos av |= (unsigned long) ap[1] << 16; 965 1.1 christos av |= (unsigned long) ap[2] << 8; 966 1.1 christos av |= (unsigned long) ap[3]; 967 1.1 christos 968 1.1 christos bp = b; 969 1.1 christos bv = (unsigned long) bp[0] << 24; 970 1.1 christos bv |= (unsigned long) bp[1] << 16; 971 1.1 christos bv |= (unsigned long) bp[2] << 8; 972 1.1 christos bv |= (unsigned long) bp[3]; 973 1.1 christos 974 1.1 christos return av < bv ? -1 : av > bv ? 1 : 0; 975 1.1 christos } 976 1.1 christos 977 1.10 christos static bool 978 1.1 christos elf_hppa_sort_unwind (bfd *abfd) 979 1.1 christos { 980 1.1 christos asection *s; 981 1.1 christos 982 1.1 christos /* Magic section names, but this is much safer than having 983 1.1 christos relocate_section remember where SEGREL32 relocs occurred. 984 1.1 christos Consider what happens if someone inept creates a linker script 985 1.1 christos that puts unwind information in .text. */ 986 1.1 christos s = bfd_get_section_by_name (abfd, ".PARISC.unwind"); 987 1.11 christos if (s != NULL && (s->flags & SEC_HAS_CONTENTS) != 0) 988 1.11 christos 989 1.1 christos { 990 1.1 christos bfd_size_type size; 991 1.1 christos bfd_byte *contents; 992 1.1 christos 993 1.1 christos if (!bfd_malloc_and_get_section (abfd, s, &contents)) 994 1.10 christos return false; 995 1.1 christos 996 1.1 christos size = s->size; 997 1.1 christos qsort (contents, (size_t) (size / 16), 16, hppa_unwind_entry_compare); 998 1.1 christos 999 1.1 christos if (! bfd_set_section_contents (abfd, s, contents, (file_ptr) 0, size)) 1000 1.10 christos return false; 1001 1.1 christos } 1002 1.1 christos 1003 1.10 christos return true; 1004 1.1 christos } 1005 1.1 christos 1006 1.1 christos /* What to do when ld finds relocations against symbols defined in 1007 1.1 christos discarded sections. */ 1008 1.1 christos 1009 1.1 christos static unsigned int 1010 1.1 christos elf_hppa_action_discarded (asection *sec) 1011 1.1 christos { 1012 1.6 christos /* Ignore relocations in .data.rel.ro.local. This section can contain 1013 1.6 christos PLABEL32 relocations to functions in discarded COMDAT groups. */ 1014 1.6 christos if (strcmp (".data.rel.ro.local", sec->name) == 0) 1015 1.6 christos return 0; 1016 1.6 christos 1017 1.1 christos if (strcmp (".PARISC.unwind", sec->name) == 0) 1018 1.1 christos return 0; 1019 1.1 christos 1020 1.1 christos return _bfd_elf_default_action_discarded (sec); 1021 1.1 christos } 1022