| 1 | /* V850-specific support for 32-bit ELF
|
|---|
| 2 | Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
|
|---|
| 3 | Free Software Foundation, Inc.
|
|---|
| 4 |
|
|---|
| 5 | This file is part of BFD, the Binary File Descriptor library.
|
|---|
| 6 |
|
|---|
| 7 | This program is free software; you can redistribute it and/or modify
|
|---|
| 8 | it under the terms of the GNU General Public License as published by
|
|---|
| 9 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 10 | (at your option) any later version.
|
|---|
| 11 |
|
|---|
| 12 | This program is distributed in the hope that it will be useful,
|
|---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 15 | GNU General Public License for more details.
|
|---|
| 16 |
|
|---|
| 17 | You should have received a copy of the GNU General Public License
|
|---|
| 18 | along with this program; if not, write to the Free Software
|
|---|
| 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|---|
| 20 |
|
|---|
| 21 | /* XXX FIXME: This code is littered with 32bit int, 16bit short, 8bit char
|
|---|
| 22 | dependencies. As is the gas & simulator code for the v850. */
|
|---|
| 23 |
|
|---|
| 24 | #include "bfd.h"
|
|---|
| 25 | #include "sysdep.h"
|
|---|
| 26 | #include "bfdlink.h"
|
|---|
| 27 | #include "libbfd.h"
|
|---|
| 28 | #include "elf-bfd.h"
|
|---|
| 29 | #include "elf/v850.h"
|
|---|
| 30 | #include "libiberty.h"
|
|---|
| 31 |
|
|---|
| 32 | /* Sign-extend a 24-bit number. */
|
|---|
| 33 | #define SEXT24(x) ((((x) & 0xffffff) ^ 0x800000) - 0x800000)
|
|---|
| 34 |
|
|---|
| 35 | static reloc_howto_type *v850_elf_reloc_type_lookup
|
|---|
| 36 | PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
|
|---|
| 37 | static void v850_elf_info_to_howto_rel
|
|---|
| 38 | PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
|
|---|
| 39 | static void v850_elf_info_to_howto_rela
|
|---|
| 40 | PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
|
|---|
| 41 | static bfd_reloc_status_type v850_elf_reloc
|
|---|
| 42 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
|---|
| 43 | static bfd_boolean v850_elf_is_local_label_name
|
|---|
| 44 | PARAMS ((bfd *, const char *));
|
|---|
| 45 | static bfd_boolean v850_elf_relocate_section
|
|---|
| 46 | PARAMS((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
|---|
| 47 | Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
|
|---|
| 48 | static bfd_reloc_status_type v850_elf_perform_relocation
|
|---|
| 49 | PARAMS ((bfd *, unsigned int, bfd_vma, bfd_byte *));
|
|---|
| 50 | static bfd_boolean v850_elf_check_relocs
|
|---|
| 51 | PARAMS ((bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *));
|
|---|
| 52 | static void remember_hi16s_reloc
|
|---|
| 53 | PARAMS ((bfd *, bfd_vma, bfd_byte *));
|
|---|
| 54 | static bfd_byte * find_remembered_hi16s_reloc
|
|---|
| 55 | PARAMS ((bfd_vma, bfd_boolean *));
|
|---|
| 56 | static bfd_reloc_status_type v850_elf_final_link_relocate
|
|---|
| 57 | PARAMS ((reloc_howto_type *, bfd *, bfd *, asection *, bfd_byte *, bfd_vma,
|
|---|
| 58 | bfd_vma, bfd_vma, struct bfd_link_info *, asection *, int));
|
|---|
| 59 | static bfd_boolean v850_elf_object_p
|
|---|
| 60 | PARAMS ((bfd *));
|
|---|
| 61 | static bfd_boolean v850_elf_fake_sections
|
|---|
| 62 | PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
|
|---|
| 63 | static void v850_elf_final_write_processing
|
|---|
| 64 | PARAMS ((bfd *, bfd_boolean));
|
|---|
| 65 | static bfd_boolean v850_elf_set_private_flags
|
|---|
| 66 | PARAMS ((bfd *, flagword));
|
|---|
| 67 | static bfd_boolean v850_elf_merge_private_bfd_data
|
|---|
| 68 | PARAMS ((bfd *, bfd *));
|
|---|
| 69 | static bfd_boolean v850_elf_print_private_bfd_data
|
|---|
| 70 | PARAMS ((bfd *, PTR));
|
|---|
| 71 | static bfd_boolean v850_elf_section_from_bfd_section
|
|---|
| 72 | PARAMS ((bfd *, asection *, int *));
|
|---|
| 73 | static void v850_elf_symbol_processing
|
|---|
| 74 | PARAMS ((bfd *, asymbol *));
|
|---|
| 75 | static bfd_boolean v850_elf_add_symbol_hook
|
|---|
| 76 | PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
|
|---|
| 77 | const char **, flagword *, asection **, bfd_vma *));
|
|---|
| 78 | static bfd_boolean v850_elf_link_output_symbol_hook
|
|---|
| 79 | PARAMS ((bfd *, struct bfd_link_info *, const char *,
|
|---|
| 80 | Elf_Internal_Sym *, asection *));
|
|---|
| 81 | static bfd_boolean v850_elf_section_from_shdr
|
|---|
| 82 | PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
|
|---|
| 83 | static bfd_boolean v850_elf_gc_sweep_hook
|
|---|
| 84 | PARAMS ((bfd *, struct bfd_link_info *, asection *,
|
|---|
| 85 | const Elf_Internal_Rela *));
|
|---|
| 86 | static asection * v850_elf_gc_mark_hook
|
|---|
| 87 | PARAMS ((asection *, struct bfd_link_info *,
|
|---|
| 88 | Elf_Internal_Rela *, struct elf_link_hash_entry *,
|
|---|
| 89 | Elf_Internal_Sym *));
|
|---|
| 90 | static bfd_reloc_status_type v850_elf_ignore_reloc
|
|---|
| 91 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
|---|
| 92 | static bfd_boolean v850_elf_relax_delete_bytes
|
|---|
| 93 | PARAMS ((bfd *, asection *, bfd_vma, bfd_vma, int));
|
|---|
| 94 | static bfd_boolean v850_elf_relax_section
|
|---|
| 95 | PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *));
|
|---|
| 96 |
|
|---|
| 97 | /* Note: It is REQUIRED that the 'type' value of each entry
|
|---|
| 98 | in this array match the index of the entry in the array. */
|
|---|
| 99 | static reloc_howto_type v850_elf_howto_table[] =
|
|---|
| 100 | {
|
|---|
| 101 | /* This reloc does nothing. */
|
|---|
| 102 | HOWTO (R_V850_NONE, /* type */
|
|---|
| 103 | 0, /* rightshift */
|
|---|
| 104 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 105 | 32, /* bitsize */
|
|---|
| 106 | FALSE, /* pc_relative */
|
|---|
| 107 | 0, /* bitpos */
|
|---|
| 108 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 109 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 110 | "R_V850_NONE", /* name */
|
|---|
| 111 | FALSE, /* partial_inplace */
|
|---|
| 112 | 0, /* src_mask */
|
|---|
| 113 | 0, /* dst_mask */
|
|---|
| 114 | FALSE), /* pcrel_offset */
|
|---|
| 115 |
|
|---|
| 116 | /* A PC relative 9 bit branch. */
|
|---|
| 117 | HOWTO (R_V850_9_PCREL, /* type */
|
|---|
| 118 | 2, /* rightshift */
|
|---|
| 119 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 120 | 26, /* bitsize */
|
|---|
| 121 | TRUE, /* pc_relative */
|
|---|
| 122 | 0, /* bitpos */
|
|---|
| 123 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 124 | v850_elf_reloc, /* special_function */
|
|---|
| 125 | "R_V850_9_PCREL", /* name */
|
|---|
| 126 | FALSE, /* partial_inplace */
|
|---|
| 127 | 0x00ffffff, /* src_mask */
|
|---|
| 128 | 0x00ffffff, /* dst_mask */
|
|---|
| 129 | TRUE), /* pcrel_offset */
|
|---|
| 130 |
|
|---|
| 131 | /* A PC relative 22 bit branch. */
|
|---|
| 132 | HOWTO (R_V850_22_PCREL, /* type */
|
|---|
| 133 | 2, /* rightshift */
|
|---|
| 134 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 135 | 22, /* bitsize */
|
|---|
| 136 | TRUE, /* pc_relative */
|
|---|
| 137 | 7, /* bitpos */
|
|---|
| 138 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 139 | v850_elf_reloc, /* special_function */
|
|---|
| 140 | "R_V850_22_PCREL", /* name */
|
|---|
| 141 | FALSE, /* partial_inplace */
|
|---|
| 142 | 0x07ffff80, /* src_mask */
|
|---|
| 143 | 0x07ffff80, /* dst_mask */
|
|---|
| 144 | TRUE), /* pcrel_offset */
|
|---|
| 145 |
|
|---|
| 146 | /* High 16 bits of symbol value. */
|
|---|
| 147 | HOWTO (R_V850_HI16_S, /* type */
|
|---|
| 148 | 0, /* rightshift */
|
|---|
| 149 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 150 | 16, /* bitsize */
|
|---|
| 151 | FALSE, /* pc_relative */
|
|---|
| 152 | 0, /* bitpos */
|
|---|
| 153 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 154 | v850_elf_reloc, /* special_function */
|
|---|
| 155 | "R_V850_HI16_S", /* name */
|
|---|
| 156 | FALSE, /* partial_inplace */
|
|---|
| 157 | 0xffff, /* src_mask */
|
|---|
| 158 | 0xffff, /* dst_mask */
|
|---|
| 159 | FALSE), /* pcrel_offset */
|
|---|
| 160 |
|
|---|
| 161 | /* High 16 bits of symbol value. */
|
|---|
| 162 | HOWTO (R_V850_HI16, /* type */
|
|---|
| 163 | 0, /* rightshift */
|
|---|
| 164 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 165 | 16, /* bitsize */
|
|---|
| 166 | FALSE, /* pc_relative */
|
|---|
| 167 | 0, /* bitpos */
|
|---|
| 168 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 169 | v850_elf_reloc, /* special_function */
|
|---|
| 170 | "R_V850_HI16", /* name */
|
|---|
| 171 | FALSE, /* partial_inplace */
|
|---|
| 172 | 0xffff, /* src_mask */
|
|---|
| 173 | 0xffff, /* dst_mask */
|
|---|
| 174 | FALSE), /* pcrel_offset */
|
|---|
| 175 |
|
|---|
| 176 | /* Low 16 bits of symbol value. */
|
|---|
| 177 | HOWTO (R_V850_LO16, /* type */
|
|---|
| 178 | 0, /* rightshift */
|
|---|
| 179 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 180 | 16, /* bitsize */
|
|---|
| 181 | FALSE, /* pc_relative */
|
|---|
| 182 | 0, /* bitpos */
|
|---|
| 183 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 184 | v850_elf_reloc, /* special_function */
|
|---|
| 185 | "R_V850_LO16", /* name */
|
|---|
| 186 | FALSE, /* partial_inplace */
|
|---|
| 187 | 0xffff, /* src_mask */
|
|---|
| 188 | 0xffff, /* dst_mask */
|
|---|
| 189 | FALSE), /* pcrel_offset */
|
|---|
| 190 |
|
|---|
| 191 | /* Simple 32bit reloc. */
|
|---|
| 192 | HOWTO (R_V850_ABS32, /* type */
|
|---|
| 193 | 0, /* rightshift */
|
|---|
| 194 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 195 | 32, /* bitsize */
|
|---|
| 196 | FALSE, /* pc_relative */
|
|---|
| 197 | 0, /* bitpos */
|
|---|
| 198 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 199 | v850_elf_reloc, /* special_function */
|
|---|
| 200 | "R_V850_ABS32", /* name */
|
|---|
| 201 | FALSE, /* partial_inplace */
|
|---|
| 202 | 0xffffffff, /* src_mask */
|
|---|
| 203 | 0xffffffff, /* dst_mask */
|
|---|
| 204 | FALSE), /* pcrel_offset */
|
|---|
| 205 |
|
|---|
| 206 | /* Simple 16bit reloc. */
|
|---|
| 207 | HOWTO (R_V850_16, /* type */
|
|---|
| 208 | 0, /* rightshift */
|
|---|
| 209 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 210 | 16, /* bitsize */
|
|---|
| 211 | FALSE, /* pc_relative */
|
|---|
| 212 | 0, /* bitpos */
|
|---|
| 213 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 214 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 215 | "R_V850_16", /* name */
|
|---|
| 216 | FALSE, /* partial_inplace */
|
|---|
| 217 | 0xffff, /* src_mask */
|
|---|
| 218 | 0xffff, /* dst_mask */
|
|---|
| 219 | FALSE), /* pcrel_offset */
|
|---|
| 220 |
|
|---|
| 221 | /* Simple 8bit reloc. */
|
|---|
| 222 | HOWTO (R_V850_8, /* type */
|
|---|
| 223 | 0, /* rightshift */
|
|---|
| 224 | 0, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 225 | 8, /* bitsize */
|
|---|
| 226 | FALSE, /* pc_relative */
|
|---|
| 227 | 0, /* bitpos */
|
|---|
| 228 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 229 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 230 | "R_V850_8", /* name */
|
|---|
| 231 | FALSE, /* partial_inplace */
|
|---|
| 232 | 0xff, /* src_mask */
|
|---|
| 233 | 0xff, /* dst_mask */
|
|---|
| 234 | FALSE), /* pcrel_offset */
|
|---|
| 235 |
|
|---|
| 236 | /* 16 bit offset from the short data area pointer. */
|
|---|
| 237 | HOWTO (R_V850_SDA_16_16_OFFSET, /* type */
|
|---|
| 238 | 0, /* rightshift */
|
|---|
| 239 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 240 | 16, /* bitsize */
|
|---|
| 241 | FALSE, /* pc_relative */
|
|---|
| 242 | 0, /* bitpos */
|
|---|
| 243 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 244 | v850_elf_reloc, /* special_function */
|
|---|
| 245 | "R_V850_SDA_16_16_OFFSET", /* name */
|
|---|
| 246 | FALSE, /* partial_inplace */
|
|---|
| 247 | 0xffff, /* src_mask */
|
|---|
| 248 | 0xffff, /* dst_mask */
|
|---|
| 249 | FALSE), /* pcrel_offset */
|
|---|
| 250 |
|
|---|
| 251 | /* 15 bit offset from the short data area pointer. */
|
|---|
| 252 | HOWTO (R_V850_SDA_15_16_OFFSET, /* type */
|
|---|
| 253 | 1, /* rightshift */
|
|---|
| 254 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 255 | 16, /* bitsize */
|
|---|
| 256 | FALSE, /* pc_relative */
|
|---|
| 257 | 1, /* bitpos */
|
|---|
| 258 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 259 | v850_elf_reloc, /* special_function */
|
|---|
| 260 | "R_V850_SDA_15_16_OFFSET", /* name */
|
|---|
| 261 | FALSE, /* partial_inplace */
|
|---|
| 262 | 0xfffe, /* src_mask */
|
|---|
| 263 | 0xfffe, /* dst_mask */
|
|---|
| 264 | FALSE), /* pcrel_offset */
|
|---|
| 265 |
|
|---|
| 266 | /* 16 bit offset from the zero data area pointer. */
|
|---|
| 267 | HOWTO (R_V850_ZDA_16_16_OFFSET, /* type */
|
|---|
| 268 | 0, /* rightshift */
|
|---|
| 269 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 270 | 16, /* bitsize */
|
|---|
| 271 | FALSE, /* pc_relative */
|
|---|
| 272 | 0, /* bitpos */
|
|---|
| 273 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 274 | v850_elf_reloc, /* special_function */
|
|---|
| 275 | "R_V850_ZDA_16_16_OFFSET", /* name */
|
|---|
| 276 | FALSE, /* partial_inplace */
|
|---|
| 277 | 0xffff, /* src_mask */
|
|---|
| 278 | 0xffff, /* dst_mask */
|
|---|
| 279 | FALSE), /* pcrel_offset */
|
|---|
| 280 |
|
|---|
| 281 | /* 15 bit offset from the zero data area pointer. */
|
|---|
| 282 | HOWTO (R_V850_ZDA_15_16_OFFSET, /* type */
|
|---|
| 283 | 1, /* rightshift */
|
|---|
| 284 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 285 | 16, /* bitsize */
|
|---|
| 286 | FALSE, /* pc_relative */
|
|---|
| 287 | 1, /* bitpos */
|
|---|
| 288 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 289 | v850_elf_reloc, /* special_function */
|
|---|
| 290 | "R_V850_ZDA_15_16_OFFSET", /* name */
|
|---|
| 291 | FALSE, /* partial_inplace */
|
|---|
| 292 | 0xfffe, /* src_mask */
|
|---|
| 293 | 0xfffe, /* dst_mask */
|
|---|
| 294 | FALSE), /* pcrel_offset */
|
|---|
| 295 |
|
|---|
| 296 | /* 6 bit offset from the tiny data area pointer. */
|
|---|
| 297 | HOWTO (R_V850_TDA_6_8_OFFSET, /* type */
|
|---|
| 298 | 2, /* rightshift */
|
|---|
| 299 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 300 | 8, /* bitsize */
|
|---|
| 301 | FALSE, /* pc_relative */
|
|---|
| 302 | 1, /* bitpos */
|
|---|
| 303 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 304 | v850_elf_reloc, /* special_function */
|
|---|
| 305 | "R_V850_TDA_6_8_OFFSET", /* name */
|
|---|
| 306 | FALSE, /* partial_inplace */
|
|---|
| 307 | 0x7e, /* src_mask */
|
|---|
| 308 | 0x7e, /* dst_mask */
|
|---|
| 309 | FALSE), /* pcrel_offset */
|
|---|
| 310 |
|
|---|
| 311 | /* 8 bit offset from the tiny data area pointer. */
|
|---|
| 312 | HOWTO (R_V850_TDA_7_8_OFFSET, /* type */
|
|---|
| 313 | 1, /* rightshift */
|
|---|
| 314 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 315 | 8, /* bitsize */
|
|---|
| 316 | FALSE, /* pc_relative */
|
|---|
| 317 | 0, /* bitpos */
|
|---|
| 318 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 319 | v850_elf_reloc, /* special_function */
|
|---|
| 320 | "R_V850_TDA_7_8_OFFSET", /* name */
|
|---|
| 321 | FALSE, /* partial_inplace */
|
|---|
| 322 | 0x7f, /* src_mask */
|
|---|
| 323 | 0x7f, /* dst_mask */
|
|---|
| 324 | FALSE), /* pcrel_offset */
|
|---|
| 325 |
|
|---|
| 326 | /* 7 bit offset from the tiny data area pointer. */
|
|---|
| 327 | HOWTO (R_V850_TDA_7_7_OFFSET, /* type */
|
|---|
| 328 | 0, /* rightshift */
|
|---|
| 329 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 330 | 7, /* bitsize */
|
|---|
| 331 | FALSE, /* pc_relative */
|
|---|
| 332 | 0, /* bitpos */
|
|---|
| 333 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 334 | v850_elf_reloc, /* special_function */
|
|---|
| 335 | "R_V850_TDA_7_7_OFFSET", /* name */
|
|---|
| 336 | FALSE, /* partial_inplace */
|
|---|
| 337 | 0x7f, /* src_mask */
|
|---|
| 338 | 0x7f, /* dst_mask */
|
|---|
| 339 | FALSE), /* pcrel_offset */
|
|---|
| 340 |
|
|---|
| 341 | /* 16 bit offset from the tiny data area pointer! */
|
|---|
| 342 | HOWTO (R_V850_TDA_16_16_OFFSET, /* type */
|
|---|
| 343 | 0, /* rightshift */
|
|---|
| 344 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 345 | 16, /* bitsize */
|
|---|
| 346 | FALSE, /* pc_relative */
|
|---|
| 347 | 0, /* bitpos */
|
|---|
| 348 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 349 | v850_elf_reloc, /* special_function */
|
|---|
| 350 | "R_V850_TDA_16_16_OFFSET", /* name */
|
|---|
| 351 | FALSE, /* partial_inplace */
|
|---|
| 352 | 0xffff, /* src_mask */
|
|---|
| 353 | 0xfff, /* dst_mask */
|
|---|
| 354 | FALSE), /* pcrel_offset */
|
|---|
| 355 |
|
|---|
| 356 | /* 5 bit offset from the tiny data area pointer. */
|
|---|
| 357 | HOWTO (R_V850_TDA_4_5_OFFSET, /* type */
|
|---|
| 358 | 1, /* rightshift */
|
|---|
| 359 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 360 | 5, /* bitsize */
|
|---|
| 361 | FALSE, /* pc_relative */
|
|---|
| 362 | 0, /* bitpos */
|
|---|
| 363 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 364 | v850_elf_reloc, /* special_function */
|
|---|
| 365 | "R_V850_TDA_4_5_OFFSET", /* name */
|
|---|
| 366 | FALSE, /* partial_inplace */
|
|---|
| 367 | 0x0f, /* src_mask */
|
|---|
| 368 | 0x0f, /* dst_mask */
|
|---|
| 369 | FALSE), /* pcrel_offset */
|
|---|
| 370 |
|
|---|
| 371 | /* 4 bit offset from the tiny data area pointer. */
|
|---|
| 372 | HOWTO (R_V850_TDA_4_4_OFFSET, /* type */
|
|---|
| 373 | 0, /* rightshift */
|
|---|
| 374 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 375 | 4, /* bitsize */
|
|---|
| 376 | FALSE, /* pc_relative */
|
|---|
| 377 | 0, /* bitpos */
|
|---|
| 378 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 379 | v850_elf_reloc, /* special_function */
|
|---|
| 380 | "R_V850_TDA_4_4_OFFSET", /* name */
|
|---|
| 381 | FALSE, /* partial_inplace */
|
|---|
| 382 | 0x0f, /* src_mask */
|
|---|
| 383 | 0x0f, /* dst_mask */
|
|---|
| 384 | FALSE), /* pcrel_offset */
|
|---|
| 385 |
|
|---|
| 386 | /* 16 bit offset from the short data area pointer. */
|
|---|
| 387 | HOWTO (R_V850_SDA_16_16_SPLIT_OFFSET, /* type */
|
|---|
| 388 | 0, /* rightshift */
|
|---|
| 389 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 390 | 16, /* bitsize */
|
|---|
| 391 | FALSE, /* pc_relative */
|
|---|
| 392 | 0, /* bitpos */
|
|---|
| 393 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 394 | v850_elf_reloc, /* special_function */
|
|---|
| 395 | "R_V850_SDA_16_16_SPLIT_OFFSET",/* name */
|
|---|
| 396 | FALSE, /* partial_inplace */
|
|---|
| 397 | 0xfffe0020, /* src_mask */
|
|---|
| 398 | 0xfffe0020, /* dst_mask */
|
|---|
| 399 | FALSE), /* pcrel_offset */
|
|---|
| 400 |
|
|---|
| 401 | /* 16 bit offset from the zero data area pointer. */
|
|---|
| 402 | HOWTO (R_V850_ZDA_16_16_SPLIT_OFFSET, /* type */
|
|---|
| 403 | 0, /* rightshift */
|
|---|
| 404 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 405 | 16, /* bitsize */
|
|---|
| 406 | FALSE, /* pc_relative */
|
|---|
| 407 | 0, /* bitpos */
|
|---|
| 408 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 409 | v850_elf_reloc, /* special_function */
|
|---|
| 410 | "R_V850_ZDA_16_16_SPLIT_OFFSET",/* name */
|
|---|
| 411 | FALSE, /* partial_inplace */
|
|---|
| 412 | 0xfffe0020, /* src_mask */
|
|---|
| 413 | 0xfffe0020, /* dst_mask */
|
|---|
| 414 | FALSE), /* pcrel_offset */
|
|---|
| 415 |
|
|---|
| 416 | /* 6 bit offset from the call table base pointer. */
|
|---|
| 417 | HOWTO (R_V850_CALLT_6_7_OFFSET, /* type */
|
|---|
| 418 | 0, /* rightshift */
|
|---|
| 419 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 420 | 7, /* bitsize */
|
|---|
| 421 | FALSE, /* pc_relative */
|
|---|
| 422 | 0, /* bitpos */
|
|---|
| 423 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 424 | v850_elf_reloc, /* special_function */
|
|---|
| 425 | "R_V850_CALLT_6_7_OFFSET", /* name */
|
|---|
| 426 | FALSE, /* partial_inplace */
|
|---|
| 427 | 0x3f, /* src_mask */
|
|---|
| 428 | 0x3f, /* dst_mask */
|
|---|
| 429 | FALSE), /* pcrel_offset */
|
|---|
| 430 |
|
|---|
| 431 | /* 16 bit offset from the call table base pointer. */
|
|---|
| 432 | HOWTO (R_V850_CALLT_16_16_OFFSET, /* type */
|
|---|
| 433 | 0, /* rightshift */
|
|---|
| 434 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 435 | 16, /* bitsize */
|
|---|
| 436 | FALSE, /* pc_relative */
|
|---|
| 437 | 0, /* bitpos */
|
|---|
| 438 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 439 | v850_elf_reloc, /* special_function */
|
|---|
| 440 | "R_V850_CALLT_16_16_OFFSET", /* name */
|
|---|
| 441 | FALSE, /* partial_inplace */
|
|---|
| 442 | 0xffff, /* src_mask */
|
|---|
| 443 | 0xffff, /* dst_mask */
|
|---|
| 444 | FALSE), /* pcrel_offset */
|
|---|
| 445 |
|
|---|
| 446 | /* GNU extension to record C++ vtable hierarchy */
|
|---|
| 447 | HOWTO (R_V850_GNU_VTINHERIT, /* type */
|
|---|
| 448 | 0, /* rightshift */
|
|---|
| 449 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 450 | 0, /* bitsize */
|
|---|
| 451 | FALSE, /* pc_relative */
|
|---|
| 452 | 0, /* bitpos */
|
|---|
| 453 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 454 | NULL, /* special_function */
|
|---|
| 455 | "R_V850_GNU_VTINHERIT", /* name */
|
|---|
| 456 | FALSE, /* partial_inplace */
|
|---|
| 457 | 0, /* src_mask */
|
|---|
| 458 | 0, /* dst_mask */
|
|---|
| 459 | FALSE), /* pcrel_offset */
|
|---|
| 460 |
|
|---|
| 461 | /* GNU extension to record C++ vtable member usage */
|
|---|
| 462 | HOWTO (R_V850_GNU_VTENTRY, /* type */
|
|---|
| 463 | 0, /* rightshift */
|
|---|
| 464 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 465 | 0, /* bitsize */
|
|---|
| 466 | FALSE, /* pc_relative */
|
|---|
| 467 | 0, /* bitpos */
|
|---|
| 468 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 469 | _bfd_elf_rel_vtable_reloc_fn, /* special_function */
|
|---|
| 470 | "R_V850_GNU_VTENTRY", /* name */
|
|---|
| 471 | FALSE, /* partial_inplace */
|
|---|
| 472 | 0, /* src_mask */
|
|---|
| 473 | 0, /* dst_mask */
|
|---|
| 474 | FALSE), /* pcrel_offset */
|
|---|
| 475 |
|
|---|
| 476 | /* Indicates a .longcall pseudo-op. The compiler will generate a .longcall
|
|---|
| 477 | pseudo-op when it finds a function call which can be relaxed. */
|
|---|
| 478 | HOWTO (R_V850_LONGCALL, /* type */
|
|---|
| 479 | 0, /* rightshift */
|
|---|
| 480 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 481 | 32, /* bitsize */
|
|---|
| 482 | TRUE, /* pc_relative */
|
|---|
| 483 | 0, /* bitpos */
|
|---|
| 484 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 485 | v850_elf_ignore_reloc, /* special_function */
|
|---|
| 486 | "R_V850_LONGCALL", /* name */
|
|---|
| 487 | FALSE, /* partial_inplace */
|
|---|
| 488 | 0, /* src_mask */
|
|---|
| 489 | 0, /* dst_mask */
|
|---|
| 490 | TRUE), /* pcrel_offset */
|
|---|
| 491 |
|
|---|
| 492 | /* Indicates a .longjump pseudo-op. The compiler will generate a
|
|---|
| 493 | .longjump pseudo-op when it finds a branch which can be relaxed. */
|
|---|
| 494 | HOWTO (R_V850_LONGJUMP, /* type */
|
|---|
| 495 | 0, /* rightshift */
|
|---|
| 496 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 497 | 32, /* bitsize */
|
|---|
| 498 | TRUE, /* pc_relative */
|
|---|
| 499 | 0, /* bitpos */
|
|---|
| 500 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 501 | v850_elf_ignore_reloc, /* special_function */
|
|---|
| 502 | "R_V850_LONGJUMP", /* name */
|
|---|
| 503 | FALSE, /* partial_inplace */
|
|---|
| 504 | 0, /* src_mask */
|
|---|
| 505 | 0, /* dst_mask */
|
|---|
| 506 | TRUE), /* pcrel_offset */
|
|---|
| 507 |
|
|---|
| 508 | HOWTO (R_V850_ALIGN, /* type */
|
|---|
| 509 | 0, /* rightshift */
|
|---|
| 510 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 511 | 0, /* bitsize */
|
|---|
| 512 | FALSE, /* pc_relative */
|
|---|
| 513 | 0, /* bitpos */
|
|---|
| 514 | complain_overflow_unsigned, /* complain_on_overflow */
|
|---|
| 515 | v850_elf_ignore_reloc, /* special_function */
|
|---|
| 516 | "R_V850_ALIGN", /* name */
|
|---|
| 517 | FALSE, /* partial_inplace */
|
|---|
| 518 | 0, /* src_mask */
|
|---|
| 519 | 0, /* dst_mask */
|
|---|
| 520 | TRUE), /* pcrel_offset */
|
|---|
| 521 |
|
|---|
| 522 | /* Simple pc-relative 32bit reloc. */
|
|---|
| 523 | HOWTO (R_V850_REL32, /* type */
|
|---|
| 524 | 0, /* rightshift */
|
|---|
| 525 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 526 | 32, /* bitsize */
|
|---|
| 527 | TRUE, /* pc_relative */
|
|---|
| 528 | 0, /* bitpos */
|
|---|
| 529 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 530 | v850_elf_reloc, /* special_function */
|
|---|
| 531 | "R_V850_REL32", /* name */
|
|---|
| 532 | FALSE, /* partial_inplace */
|
|---|
| 533 | 0xffffffff, /* src_mask */
|
|---|
| 534 | 0xffffffff, /* dst_mask */
|
|---|
| 535 | FALSE), /* pcrel_offset */
|
|---|
| 536 | };
|
|---|
| 537 |
|
|---|
| 538 | /* Map BFD reloc types to V850 ELF reloc types. */
|
|---|
| 539 |
|
|---|
| 540 | struct v850_elf_reloc_map
|
|---|
| 541 | {
|
|---|
| 542 | /* BFD_RELOC_V850_CALLT_16_16_OFFSET is 258, which will not fix in an
|
|---|
| 543 | unsigned char. */
|
|---|
| 544 | bfd_reloc_code_real_type bfd_reloc_val;
|
|---|
| 545 | unsigned int elf_reloc_val;
|
|---|
| 546 | };
|
|---|
| 547 |
|
|---|
| 548 | static const struct v850_elf_reloc_map v850_elf_reloc_map[] =
|
|---|
| 549 | {
|
|---|
| 550 | { BFD_RELOC_NONE, R_V850_NONE },
|
|---|
| 551 | { BFD_RELOC_V850_9_PCREL, R_V850_9_PCREL },
|
|---|
| 552 | { BFD_RELOC_V850_22_PCREL, R_V850_22_PCREL },
|
|---|
| 553 | { BFD_RELOC_HI16_S, R_V850_HI16_S },
|
|---|
| 554 | { BFD_RELOC_HI16, R_V850_HI16 },
|
|---|
| 555 | { BFD_RELOC_LO16, R_V850_LO16 },
|
|---|
| 556 | { BFD_RELOC_32, R_V850_ABS32 },
|
|---|
| 557 | { BFD_RELOC_32_PCREL, R_V850_REL32 },
|
|---|
| 558 | { BFD_RELOC_16, R_V850_16 },
|
|---|
| 559 | { BFD_RELOC_8, R_V850_8 },
|
|---|
| 560 | { BFD_RELOC_V850_SDA_16_16_OFFSET, R_V850_SDA_16_16_OFFSET },
|
|---|
| 561 | { BFD_RELOC_V850_SDA_15_16_OFFSET, R_V850_SDA_15_16_OFFSET },
|
|---|
| 562 | { BFD_RELOC_V850_ZDA_16_16_OFFSET, R_V850_ZDA_16_16_OFFSET },
|
|---|
| 563 | { BFD_RELOC_V850_ZDA_15_16_OFFSET, R_V850_ZDA_15_16_OFFSET },
|
|---|
| 564 | { BFD_RELOC_V850_TDA_6_8_OFFSET, R_V850_TDA_6_8_OFFSET },
|
|---|
| 565 | { BFD_RELOC_V850_TDA_7_8_OFFSET, R_V850_TDA_7_8_OFFSET },
|
|---|
| 566 | { BFD_RELOC_V850_TDA_7_7_OFFSET, R_V850_TDA_7_7_OFFSET },
|
|---|
| 567 | { BFD_RELOC_V850_TDA_16_16_OFFSET, R_V850_TDA_16_16_OFFSET },
|
|---|
| 568 | { BFD_RELOC_V850_TDA_4_5_OFFSET, R_V850_TDA_4_5_OFFSET },
|
|---|
| 569 | { BFD_RELOC_V850_TDA_4_4_OFFSET, R_V850_TDA_4_4_OFFSET },
|
|---|
| 570 | { BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET, R_V850_SDA_16_16_SPLIT_OFFSET },
|
|---|
| 571 | { BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET, R_V850_ZDA_16_16_SPLIT_OFFSET },
|
|---|
| 572 | { BFD_RELOC_V850_CALLT_6_7_OFFSET, R_V850_CALLT_6_7_OFFSET },
|
|---|
| 573 | { BFD_RELOC_V850_CALLT_16_16_OFFSET, R_V850_CALLT_16_16_OFFSET },
|
|---|
| 574 | { BFD_RELOC_VTABLE_INHERIT, R_V850_GNU_VTINHERIT },
|
|---|
| 575 | { BFD_RELOC_VTABLE_ENTRY, R_V850_GNU_VTENTRY },
|
|---|
| 576 | { BFD_RELOC_V850_LONGCALL, R_V850_LONGCALL },
|
|---|
| 577 | { BFD_RELOC_V850_LONGJUMP, R_V850_LONGJUMP },
|
|---|
| 578 | { BFD_RELOC_V850_ALIGN, R_V850_ALIGN },
|
|---|
| 579 |
|
|---|
| 580 | };
|
|---|
| 581 | |
|---|
| 582 |
|
|---|
| 583 | /* Map a bfd relocation into the appropriate howto structure. */
|
|---|
| 584 |
|
|---|
| 585 | static reloc_howto_type *
|
|---|
| 586 | v850_elf_reloc_type_lookup (abfd, code)
|
|---|
| 587 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 588 | bfd_reloc_code_real_type code;
|
|---|
| 589 | {
|
|---|
| 590 | unsigned int i;
|
|---|
| 591 |
|
|---|
| 592 | for (i = ARRAY_SIZE (v850_elf_reloc_map); i --;)
|
|---|
| 593 | if (v850_elf_reloc_map[i].bfd_reloc_val == code)
|
|---|
| 594 | {
|
|---|
| 595 | unsigned int elf_reloc_val = v850_elf_reloc_map[i].elf_reloc_val;
|
|---|
| 596 |
|
|---|
| 597 | BFD_ASSERT (v850_elf_howto_table[elf_reloc_val].type == elf_reloc_val);
|
|---|
| 598 |
|
|---|
| 599 | return v850_elf_howto_table + elf_reloc_val;
|
|---|
| 600 | }
|
|---|
| 601 |
|
|---|
| 602 | return NULL;
|
|---|
| 603 | }
|
|---|
| 604 | |
|---|
| 605 |
|
|---|
| 606 | /* Set the howto pointer for an V850 ELF reloc. */
|
|---|
| 607 |
|
|---|
| 608 | static void
|
|---|
| 609 | v850_elf_info_to_howto_rel (abfd, cache_ptr, dst)
|
|---|
| 610 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 611 | arelent *cache_ptr;
|
|---|
| 612 | Elf_Internal_Rela *dst;
|
|---|
| 613 | {
|
|---|
| 614 | unsigned int r_type;
|
|---|
| 615 |
|
|---|
| 616 | r_type = ELF32_R_TYPE (dst->r_info);
|
|---|
| 617 | BFD_ASSERT (r_type < (unsigned int) R_V850_max);
|
|---|
| 618 | cache_ptr->howto = &v850_elf_howto_table[r_type];
|
|---|
| 619 | }
|
|---|
| 620 |
|
|---|
| 621 | /* Set the howto pointer for a V850 ELF reloc (type RELA). */
|
|---|
| 622 | static void
|
|---|
| 623 | v850_elf_info_to_howto_rela (abfd, cache_ptr, dst)
|
|---|
| 624 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 625 | arelent * cache_ptr;
|
|---|
| 626 | Elf_Internal_Rela *dst;
|
|---|
| 627 | {
|
|---|
| 628 | unsigned int r_type;
|
|---|
| 629 |
|
|---|
| 630 | r_type = ELF32_R_TYPE (dst->r_info);
|
|---|
| 631 | BFD_ASSERT (r_type < (unsigned int) R_V850_max);
|
|---|
| 632 | cache_ptr->howto = &v850_elf_howto_table[r_type];
|
|---|
| 633 | }
|
|---|
| 634 | |
|---|
| 635 |
|
|---|
| 636 | /* Look through the relocs for a section during the first phase, and
|
|---|
| 637 | allocate space in the global offset table or procedure linkage
|
|---|
| 638 | table. */
|
|---|
| 639 |
|
|---|
| 640 | static bfd_boolean
|
|---|
| 641 | v850_elf_check_relocs (abfd, info, sec, relocs)
|
|---|
| 642 | bfd *abfd;
|
|---|
| 643 | struct bfd_link_info *info;
|
|---|
| 644 | asection *sec;
|
|---|
| 645 | const Elf_Internal_Rela *relocs;
|
|---|
| 646 | {
|
|---|
| 647 | bfd_boolean ret = TRUE;
|
|---|
| 648 | bfd *dynobj;
|
|---|
| 649 | Elf_Internal_Shdr *symtab_hdr;
|
|---|
| 650 | struct elf_link_hash_entry **sym_hashes;
|
|---|
| 651 | const Elf_Internal_Rela *rel;
|
|---|
| 652 | const Elf_Internal_Rela *rel_end;
|
|---|
| 653 | asection *sreloc;
|
|---|
| 654 | enum v850_reloc_type r_type;
|
|---|
| 655 | int other = 0;
|
|---|
| 656 | const char *common = (const char *)0;
|
|---|
| 657 |
|
|---|
| 658 | if (info->relocateable)
|
|---|
| 659 | return TRUE;
|
|---|
| 660 |
|
|---|
| 661 | #ifdef DEBUG
|
|---|
| 662 | fprintf (stderr, "v850_elf_check_relocs called for section %s in %s\n",
|
|---|
| 663 | bfd_get_section_name (abfd, sec),
|
|---|
| 664 | bfd_archive_filename (abfd));
|
|---|
| 665 | #endif
|
|---|
| 666 |
|
|---|
| 667 | dynobj = elf_hash_table (info)->dynobj;
|
|---|
| 668 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
|
|---|
| 669 | sym_hashes = elf_sym_hashes (abfd);
|
|---|
| 670 | sreloc = NULL;
|
|---|
| 671 |
|
|---|
| 672 | rel_end = relocs + sec->reloc_count;
|
|---|
| 673 | for (rel = relocs; rel < rel_end; rel++)
|
|---|
| 674 | {
|
|---|
| 675 | unsigned long r_symndx;
|
|---|
| 676 | struct elf_link_hash_entry *h;
|
|---|
| 677 |
|
|---|
| 678 | r_symndx = ELF32_R_SYM (rel->r_info);
|
|---|
| 679 | if (r_symndx < symtab_hdr->sh_info)
|
|---|
| 680 | h = NULL;
|
|---|
| 681 | else
|
|---|
| 682 | h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
|---|
| 683 |
|
|---|
| 684 | r_type = (enum v850_reloc_type) ELF32_R_TYPE (rel->r_info);
|
|---|
| 685 | switch (r_type)
|
|---|
| 686 | {
|
|---|
| 687 | default:
|
|---|
| 688 | case R_V850_NONE:
|
|---|
| 689 | case R_V850_9_PCREL:
|
|---|
| 690 | case R_V850_22_PCREL:
|
|---|
| 691 | case R_V850_HI16_S:
|
|---|
| 692 | case R_V850_HI16:
|
|---|
| 693 | case R_V850_LO16:
|
|---|
| 694 | case R_V850_ABS32:
|
|---|
| 695 | case R_V850_REL32:
|
|---|
| 696 | case R_V850_16:
|
|---|
| 697 | case R_V850_8:
|
|---|
| 698 | case R_V850_CALLT_6_7_OFFSET:
|
|---|
| 699 | case R_V850_CALLT_16_16_OFFSET:
|
|---|
| 700 | break;
|
|---|
| 701 |
|
|---|
| 702 | /* This relocation describes the C++ object vtable hierarchy.
|
|---|
| 703 | Reconstruct it for later use during GC. */
|
|---|
| 704 | case R_V850_GNU_VTINHERIT:
|
|---|
| 705 | if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
|
|---|
| 706 | return FALSE;
|
|---|
| 707 | break;
|
|---|
| 708 |
|
|---|
| 709 | /* This relocation describes which C++ vtable entries
|
|---|
| 710 | are actually used. Record for later use during GC. */
|
|---|
| 711 | case R_V850_GNU_VTENTRY:
|
|---|
| 712 | if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
|
|---|
| 713 | return FALSE;
|
|---|
| 714 | break;
|
|---|
| 715 |
|
|---|
| 716 | case R_V850_SDA_16_16_SPLIT_OFFSET:
|
|---|
| 717 | case R_V850_SDA_16_16_OFFSET:
|
|---|
| 718 | case R_V850_SDA_15_16_OFFSET:
|
|---|
| 719 | other = V850_OTHER_SDA;
|
|---|
| 720 | common = ".scommon";
|
|---|
| 721 | goto small_data_common;
|
|---|
| 722 |
|
|---|
| 723 | case R_V850_ZDA_16_16_SPLIT_OFFSET:
|
|---|
| 724 | case R_V850_ZDA_16_16_OFFSET:
|
|---|
| 725 | case R_V850_ZDA_15_16_OFFSET:
|
|---|
| 726 | other = V850_OTHER_ZDA;
|
|---|
| 727 | common = ".zcommon";
|
|---|
| 728 | goto small_data_common;
|
|---|
| 729 |
|
|---|
| 730 | case R_V850_TDA_4_5_OFFSET:
|
|---|
| 731 | case R_V850_TDA_4_4_OFFSET:
|
|---|
| 732 | case R_V850_TDA_6_8_OFFSET:
|
|---|
| 733 | case R_V850_TDA_7_8_OFFSET:
|
|---|
| 734 | case R_V850_TDA_7_7_OFFSET:
|
|---|
| 735 | case R_V850_TDA_16_16_OFFSET:
|
|---|
| 736 | other = V850_OTHER_TDA;
|
|---|
| 737 | common = ".tcommon";
|
|---|
| 738 | /* fall through */
|
|---|
| 739 |
|
|---|
| 740 | #define V850_OTHER_MASK (V850_OTHER_TDA | V850_OTHER_SDA | V850_OTHER_ZDA)
|
|---|
| 741 |
|
|---|
| 742 | small_data_common:
|
|---|
| 743 | if (h)
|
|---|
| 744 | {
|
|---|
| 745 | /* Flag which type of relocation was used. */
|
|---|
| 746 | h->other |= other;
|
|---|
| 747 | if ((h->other & V850_OTHER_MASK) != (other & V850_OTHER_MASK)
|
|---|
| 748 | && (h->other & V850_OTHER_ERROR) == 0)
|
|---|
| 749 | {
|
|---|
| 750 | const char * msg;
|
|---|
| 751 | static char buff[200]; /* XXX */
|
|---|
| 752 |
|
|---|
| 753 | switch (h->other & V850_OTHER_MASK)
|
|---|
| 754 | {
|
|---|
| 755 | default:
|
|---|
| 756 | msg = _("Variable `%s' cannot occupy in multiple small data regions");
|
|---|
| 757 | break;
|
|---|
| 758 | case V850_OTHER_SDA | V850_OTHER_ZDA | V850_OTHER_TDA:
|
|---|
| 759 | msg = _("Variable `%s' can only be in one of the small, zero, and tiny data regions");
|
|---|
| 760 | break;
|
|---|
| 761 | case V850_OTHER_SDA | V850_OTHER_ZDA:
|
|---|
| 762 | msg = _("Variable `%s' cannot be in both small and zero data regions simultaneously");
|
|---|
| 763 | break;
|
|---|
| 764 | case V850_OTHER_SDA | V850_OTHER_TDA:
|
|---|
| 765 | msg = _("Variable `%s' cannot be in both small and tiny data regions simultaneously");
|
|---|
| 766 | break;
|
|---|
| 767 | case V850_OTHER_ZDA | V850_OTHER_TDA:
|
|---|
| 768 | msg = _("Variable `%s' cannot be in both zero and tiny data regions simultaneously");
|
|---|
| 769 | break;
|
|---|
| 770 | }
|
|---|
| 771 |
|
|---|
| 772 | sprintf (buff, msg, h->root.root.string);
|
|---|
| 773 | info->callbacks->warning (info, buff, h->root.root.string,
|
|---|
| 774 | abfd, h->root.u.def.section,
|
|---|
| 775 | (bfd_vma) 0);
|
|---|
| 776 |
|
|---|
| 777 | bfd_set_error (bfd_error_bad_value);
|
|---|
| 778 | h->other |= V850_OTHER_ERROR;
|
|---|
| 779 | ret = FALSE;
|
|---|
| 780 | }
|
|---|
| 781 | }
|
|---|
| 782 |
|
|---|
| 783 | if (h && h->root.type == bfd_link_hash_common
|
|---|
| 784 | && h->root.u.c.p
|
|---|
| 785 | && !strcmp (bfd_get_section_name (abfd, h->root.u.c.p->section), "COMMON"))
|
|---|
| 786 | {
|
|---|
| 787 | asection * section;
|
|---|
| 788 |
|
|---|
| 789 | section = h->root.u.c.p->section = bfd_make_section_old_way (abfd, common);
|
|---|
| 790 | section->flags |= SEC_IS_COMMON;
|
|---|
| 791 | }
|
|---|
| 792 |
|
|---|
| 793 | #ifdef DEBUG
|
|---|
| 794 | fprintf (stderr, "v850_elf_check_relocs, found %s relocation for %s%s\n",
|
|---|
| 795 | v850_elf_howto_table[ (int)r_type ].name,
|
|---|
| 796 | (h && h->root.root.string) ? h->root.root.string : "<unknown>",
|
|---|
| 797 | (h->root.type == bfd_link_hash_common) ? ", symbol is common" : "");
|
|---|
| 798 | #endif
|
|---|
| 799 | break;
|
|---|
| 800 | }
|
|---|
| 801 | }
|
|---|
| 802 |
|
|---|
| 803 | return ret;
|
|---|
| 804 | }
|
|---|
| 805 |
|
|---|
| 806 | /* In the old version, when an entry was checked out from the table,
|
|---|
| 807 | it was deleted. This produced an error if the entry was needed
|
|---|
| 808 | more than once, as the second attempted retry failed.
|
|---|
| 809 |
|
|---|
| 810 | In the current version, the entry is not deleted, instead we set
|
|---|
| 811 | the field 'found' to TRUE. If a second lookup matches the same
|
|---|
| 812 | entry, then we know that the hi16s reloc has already been updated
|
|---|
| 813 | and does not need to be updated a second time.
|
|---|
| 814 |
|
|---|
| 815 | TODO - TOFIX: If it is possible that we need to restore 2 different
|
|---|
| 816 | addresses from the same table entry, where the first generates an
|
|---|
| 817 | overflow, whilst the second do not, then this code will fail. */
|
|---|
| 818 |
|
|---|
| 819 | typedef struct hi16s_location
|
|---|
| 820 | {
|
|---|
| 821 | bfd_vma addend;
|
|---|
| 822 | bfd_byte *address;
|
|---|
| 823 | unsigned long counter;
|
|---|
| 824 | bfd_boolean found;
|
|---|
| 825 | struct hi16s_location *next;
|
|---|
| 826 | }
|
|---|
| 827 | hi16s_location;
|
|---|
| 828 |
|
|---|
| 829 | static hi16s_location *previous_hi16s;
|
|---|
| 830 | static hi16s_location *free_hi16s;
|
|---|
| 831 | static unsigned long hi16s_counter;
|
|---|
| 832 |
|
|---|
| 833 | static void
|
|---|
| 834 | remember_hi16s_reloc (abfd, addend, address)
|
|---|
| 835 | bfd *abfd;
|
|---|
| 836 | bfd_vma addend;
|
|---|
| 837 | bfd_byte *address;
|
|---|
| 838 | {
|
|---|
| 839 | hi16s_location * entry = NULL;
|
|---|
| 840 | bfd_size_type amt = sizeof (* free_hi16s);
|
|---|
| 841 |
|
|---|
| 842 | /* Find a free structure. */
|
|---|
| 843 | if (free_hi16s == NULL)
|
|---|
| 844 | free_hi16s = (hi16s_location *) bfd_zalloc (abfd, amt);
|
|---|
| 845 |
|
|---|
| 846 | entry = free_hi16s;
|
|---|
| 847 | free_hi16s = free_hi16s->next;
|
|---|
| 848 |
|
|---|
| 849 | entry->addend = addend;
|
|---|
| 850 | entry->address = address;
|
|---|
| 851 | entry->counter = hi16s_counter ++;
|
|---|
| 852 | entry->found = FALSE;
|
|---|
| 853 | entry->next = previous_hi16s;
|
|---|
| 854 | previous_hi16s = entry;
|
|---|
| 855 |
|
|---|
| 856 | /* Cope with wrap around of our counter. */
|
|---|
| 857 | if (hi16s_counter == 0)
|
|---|
| 858 | {
|
|---|
| 859 | /* XXX - Assume that all counter entries differ only in their low 16 bits. */
|
|---|
| 860 | for (entry = previous_hi16s; entry != NULL; entry = entry->next)
|
|---|
| 861 | entry->counter &= 0xffff;
|
|---|
| 862 |
|
|---|
| 863 | hi16s_counter = 0x10000;
|
|---|
| 864 | }
|
|---|
| 865 |
|
|---|
| 866 | return;
|
|---|
| 867 | }
|
|---|
| 868 |
|
|---|
| 869 | static bfd_byte *
|
|---|
| 870 | find_remembered_hi16s_reloc (addend, already_found)
|
|---|
| 871 | bfd_vma addend;
|
|---|
| 872 | bfd_boolean *already_found;
|
|---|
| 873 | {
|
|---|
| 874 | hi16s_location *match = NULL;
|
|---|
| 875 | hi16s_location *entry;
|
|---|
| 876 | hi16s_location *previous = NULL;
|
|---|
| 877 | hi16s_location *prev;
|
|---|
| 878 | bfd_byte *addr;
|
|---|
| 879 |
|
|---|
| 880 | /* Search the table. Record the most recent entry that matches. */
|
|---|
| 881 | for (entry = previous_hi16s; entry; entry = entry->next)
|
|---|
| 882 | {
|
|---|
| 883 | if (entry->addend == addend
|
|---|
| 884 | && (match == NULL || match->counter < entry->counter))
|
|---|
| 885 | {
|
|---|
| 886 | previous = prev;
|
|---|
| 887 | match = entry;
|
|---|
| 888 | }
|
|---|
| 889 |
|
|---|
| 890 | prev = entry;
|
|---|
| 891 | }
|
|---|
| 892 |
|
|---|
| 893 | if (match == NULL)
|
|---|
| 894 | return NULL;
|
|---|
| 895 |
|
|---|
| 896 | /* Extract the address. */
|
|---|
| 897 | addr = match->address;
|
|---|
| 898 |
|
|---|
| 899 | /* Remeber if this entry has already been used before. */
|
|---|
| 900 | if (already_found)
|
|---|
| 901 | * already_found = match->found;
|
|---|
| 902 |
|
|---|
| 903 | /* Note that this entry has now been used. */
|
|---|
| 904 | match->found = TRUE;
|
|---|
| 905 |
|
|---|
| 906 | return addr;
|
|---|
| 907 | }
|
|---|
| 908 |
|
|---|
| 909 | /* FIXME: The code here probably ought to be removed and the code in reloc.c
|
|---|
| 910 | allowed to do its stuff instead. At least for most of the relocs, anwyay. */
|
|---|
| 911 |
|
|---|
| 912 | static bfd_reloc_status_type
|
|---|
| 913 | v850_elf_perform_relocation (abfd, r_type, addend, address)
|
|---|
| 914 | bfd *abfd;
|
|---|
| 915 | unsigned int r_type;
|
|---|
| 916 | bfd_vma addend;
|
|---|
| 917 | bfd_byte *address;
|
|---|
| 918 | {
|
|---|
| 919 | unsigned long insn;
|
|---|
| 920 | bfd_signed_vma saddend = (bfd_signed_vma) addend;
|
|---|
| 921 |
|
|---|
| 922 | switch (r_type)
|
|---|
| 923 | {
|
|---|
| 924 | default:
|
|---|
| 925 | /* fprintf (stderr, "reloc type %d not SUPPORTED\n", r_type ); */
|
|---|
| 926 | return bfd_reloc_notsupported;
|
|---|
| 927 |
|
|---|
| 928 | case R_V850_REL32:
|
|---|
| 929 | case R_V850_ABS32:
|
|---|
| 930 | bfd_put_32 (abfd, addend, address);
|
|---|
| 931 | return bfd_reloc_ok;
|
|---|
| 932 |
|
|---|
| 933 | case R_V850_22_PCREL:
|
|---|
| 934 | if (saddend > 0x1fffff || saddend < -0x200000)
|
|---|
| 935 | return bfd_reloc_overflow;
|
|---|
| 936 |
|
|---|
| 937 | if ((addend % 2) != 0)
|
|---|
| 938 | return bfd_reloc_dangerous;
|
|---|
| 939 |
|
|---|
| 940 | insn = bfd_get_32 (abfd, address);
|
|---|
| 941 | insn &= ~0xfffe003f;
|
|---|
| 942 | insn |= (((addend & 0xfffe) << 16) | ((addend & 0x3f0000) >> 16));
|
|---|
| 943 | bfd_put_32 (abfd, (bfd_vma) insn, address);
|
|---|
| 944 | return bfd_reloc_ok;
|
|---|
| 945 |
|
|---|
| 946 | case R_V850_9_PCREL:
|
|---|
| 947 | if (saddend > 0xff || saddend < -0x100)
|
|---|
| 948 | return bfd_reloc_overflow;
|
|---|
| 949 |
|
|---|
| 950 | if ((addend % 2) != 0)
|
|---|
| 951 | return bfd_reloc_dangerous;
|
|---|
| 952 |
|
|---|
| 953 | insn = bfd_get_16 (abfd, address);
|
|---|
| 954 | insn &= ~ 0xf870;
|
|---|
| 955 | insn |= ((addend & 0x1f0) << 7) | ((addend & 0x0e) << 3);
|
|---|
| 956 | break;
|
|---|
| 957 |
|
|---|
| 958 | case R_V850_HI16:
|
|---|
| 959 | addend += (bfd_get_16 (abfd, address) << 16);
|
|---|
| 960 | addend = (addend >> 16);
|
|---|
| 961 | insn = addend;
|
|---|
| 962 | break;
|
|---|
| 963 |
|
|---|
| 964 | case R_V850_HI16_S:
|
|---|
| 965 | /* Remember where this relocation took place. */
|
|---|
| 966 | remember_hi16s_reloc (abfd, addend, address);
|
|---|
| 967 |
|
|---|
| 968 | addend += (bfd_get_16 (abfd, address) << 16);
|
|---|
| 969 | addend = (addend >> 16) + ((addend & 0x8000) != 0);
|
|---|
| 970 |
|
|---|
| 971 | /* This relocation cannot overflow. */
|
|---|
| 972 | if (addend > 0x7fff)
|
|---|
| 973 | addend = 0;
|
|---|
| 974 |
|
|---|
| 975 | insn = addend;
|
|---|
| 976 | break;
|
|---|
| 977 |
|
|---|
| 978 | case R_V850_LO16:
|
|---|
| 979 | /* Calculate the sum of the value stored in the instruction and the
|
|---|
| 980 | addend and check for overflow from the low 16 bits into the high
|
|---|
| 981 | 16 bits. The assembler has already done some of this: If the
|
|---|
| 982 | value stored in the instruction has its 15th bit set, (counting
|
|---|
| 983 | from zero) then the assembler will have added 1 to the value
|
|---|
| 984 | stored in the associated HI16S reloc. So for example, these
|
|---|
| 985 | relocations:
|
|---|
| 986 |
|
|---|
| 987 | movhi hi( fred ), r0, r1
|
|---|
| 988 | movea lo( fred ), r1, r1
|
|---|
| 989 |
|
|---|
| 990 | will store 0 in the value fields for the MOVHI and MOVEA instructions
|
|---|
| 991 | and addend will be the address of fred, but for these instructions:
|
|---|
| 992 |
|
|---|
| 993 | movhi hi( fred + 0x123456), r0, r1
|
|---|
| 994 | movea lo( fred + 0x123456), r1, r1
|
|---|
| 995 |
|
|---|
| 996 | the value stored in the MOVHI instruction will be 0x12 and the value
|
|---|
| 997 | stored in the MOVEA instruction will be 0x3456. If however the
|
|---|
| 998 | instructions were:
|
|---|
| 999 |
|
|---|
| 1000 | movhi hi( fred + 0x10ffff), r0, r1
|
|---|
| 1001 | movea lo( fred + 0x10ffff), r1, r1
|
|---|
| 1002 |
|
|---|
| 1003 | then the value stored in the MOVHI instruction would be 0x11 (not
|
|---|
| 1004 | 0x10) and the value stored in the MOVEA instruction would be 0xffff.
|
|---|
| 1005 | Thus (assuming for the moment that the addend is 0), at run time the
|
|---|
| 1006 | MOVHI instruction loads 0x110000 into r1, then the MOVEA instruction
|
|---|
| 1007 | adds 0xffffffff (sign extension!) producing 0x10ffff. Similarly if
|
|---|
| 1008 | the instructions were:
|
|---|
| 1009 |
|
|---|
| 1010 | movhi hi( fred - 1), r0, r1
|
|---|
| 1011 | movea lo( fred - 1), r1, r1
|
|---|
| 1012 |
|
|---|
| 1013 | then 0 is stored in the MOVHI instruction and -1 is stored in the
|
|---|
| 1014 | MOVEA instruction.
|
|---|
| 1015 |
|
|---|
| 1016 | Overflow can occur if the addition of the value stored in the
|
|---|
| 1017 | instruction plus the addend sets the 15th bit when before it was clear.
|
|---|
| 1018 | This is because the 15th bit will be sign extended into the high part,
|
|---|
| 1019 | thus reducing its value by one, but since the 15th bit was originally
|
|---|
| 1020 | clear, the assembler will not have added 1 to the previous HI16S reloc
|
|---|
| 1021 | to compensate for this effect. For example:
|
|---|
| 1022 |
|
|---|
| 1023 | movhi hi( fred + 0x123456), r0, r1
|
|---|
| 1024 | movea lo( fred + 0x123456), r1, r1
|
|---|
| 1025 |
|
|---|
| 1026 | The value stored in HI16S reloc is 0x12, the value stored in the LO16
|
|---|
| 1027 | reloc is 0x3456. If we assume that the address of fred is 0x00007000
|
|---|
| 1028 | then the relocations become:
|
|---|
| 1029 |
|
|---|
| 1030 | HI16S: 0x0012 + (0x00007000 >> 16) = 0x12
|
|---|
| 1031 | LO16: 0x3456 + (0x00007000 & 0xffff) = 0xa456
|
|---|
| 1032 |
|
|---|
| 1033 | but when the instructions are executed, the MOVEA instruction's value
|
|---|
| 1034 | is signed extended, so the sum becomes:
|
|---|
| 1035 |
|
|---|
| 1036 | 0x00120000
|
|---|
| 1037 | + 0xffffa456
|
|---|
| 1038 | ------------
|
|---|
| 1039 | 0x0011a456 but 'fred + 0x123456' = 0x0012a456
|
|---|
| 1040 |
|
|---|
| 1041 | Note that if the 15th bit was set in the value stored in the LO16
|
|---|
| 1042 | reloc, then we do not have to do anything:
|
|---|
| 1043 |
|
|---|
| 1044 | movhi hi( fred + 0x10ffff), r0, r1
|
|---|
| 1045 | movea lo( fred + 0x10ffff), r1, r1
|
|---|
| 1046 |
|
|---|
| 1047 | HI16S: 0x0011 + (0x00007000 >> 16) = 0x11
|
|---|
| 1048 | LO16: 0xffff + (0x00007000 & 0xffff) = 0x6fff
|
|---|
| 1049 |
|
|---|
| 1050 | 0x00110000
|
|---|
| 1051 | + 0x00006fff
|
|---|
| 1052 | ------------
|
|---|
| 1053 | 0x00116fff = fred + 0x10ffff = 0x7000 + 0x10ffff
|
|---|
| 1054 |
|
|---|
| 1055 | Overflow can also occur if the computation carries into the 16th bit
|
|---|
| 1056 | and it also results in the 15th bit having the same value as the 15th
|
|---|
| 1057 | bit of the original value. What happens is that the HI16S reloc
|
|---|
| 1058 | will have already examined the 15th bit of the original value and
|
|---|
| 1059 | added 1 to the high part if the bit is set. This compensates for the
|
|---|
| 1060 | sign extension of 15th bit of the result of the computation. But now
|
|---|
| 1061 | there is a carry into the 16th bit, and this has not been allowed for.
|
|---|
| 1062 |
|
|---|
| 1063 | So, for example if fred is at address 0xf000:
|
|---|
| 1064 |
|
|---|
| 1065 | movhi hi( fred + 0xffff), r0, r1 [bit 15 of the offset is set]
|
|---|
| 1066 | movea lo( fred + 0xffff), r1, r1
|
|---|
| 1067 |
|
|---|
| 1068 | HI16S: 0x0001 + (0x0000f000 >> 16) = 0x0001
|
|---|
| 1069 | LO16: 0xffff + (0x0000f000 & 0xffff) = 0xefff (carry into bit 16 is lost)
|
|---|
| 1070 |
|
|---|
| 1071 | 0x00010000
|
|---|
| 1072 | + 0xffffefff
|
|---|
| 1073 | ------------
|
|---|
| 1074 | 0x0000efff but 'fred + 0xffff' = 0x0001efff
|
|---|
| 1075 |
|
|---|
| 1076 | Similarly, if the 15th bit remains clear, but overflow occurs into
|
|---|
| 1077 | the 16th bit then (assuming the address of fred is 0xf000):
|
|---|
| 1078 |
|
|---|
| 1079 | movhi hi( fred + 0x7000), r0, r1 [bit 15 of the offset is clear]
|
|---|
| 1080 | movea lo( fred + 0x7000), r1, r1
|
|---|
| 1081 |
|
|---|
| 1082 | HI16S: 0x0000 + (0x0000f000 >> 16) = 0x0000
|
|---|
| 1083 | LO16: 0x7000 + (0x0000f000 & 0xffff) = 0x6fff (carry into bit 16 is lost)
|
|---|
| 1084 |
|
|---|
| 1085 | 0x00000000
|
|---|
| 1086 | + 0x00006fff
|
|---|
| 1087 | ------------
|
|---|
| 1088 | 0x00006fff but 'fred + 0x7000' = 0x00016fff
|
|---|
| 1089 |
|
|---|
| 1090 | Note - there is no need to change anything if a carry occurs, and the
|
|---|
| 1091 | 15th bit changes its value from being set to being clear, as the HI16S
|
|---|
| 1092 | reloc will have already added in 1 to the high part for us:
|
|---|
| 1093 |
|
|---|
| 1094 | movhi hi( fred + 0xffff), r0, r1 [bit 15 of the offset is set]
|
|---|
| 1095 | movea lo( fred + 0xffff), r1, r1
|
|---|
| 1096 |
|
|---|
| 1097 | HI16S: 0x0001 + (0x00007000 >> 16)
|
|---|
| 1098 | LO16: 0xffff + (0x00007000 & 0xffff) = 0x6fff (carry into bit 16 is lost)
|
|---|
| 1099 |
|
|---|
| 1100 | 0x00010000
|
|---|
| 1101 | + 0x00006fff (bit 15 not set, so the top half is zero)
|
|---|
| 1102 | ------------
|
|---|
| 1103 | 0x00016fff which is right (assuming that fred is at 0x7000)
|
|---|
| 1104 |
|
|---|
| 1105 | but if the 15th bit goes from being clear to being set, then we must
|
|---|
| 1106 | once again handle overflow:
|
|---|
| 1107 |
|
|---|
| 1108 | movhi hi( fred + 0x7000), r0, r1 [bit 15 of the offset is clear]
|
|---|
| 1109 | movea lo( fred + 0x7000), r1, r1
|
|---|
| 1110 |
|
|---|
| 1111 | HI16S: 0x0000 + (0x0000ffff >> 16)
|
|---|
| 1112 | LO16: 0x7000 + (0x0000ffff & 0xffff) = 0x6fff (carry into bit 16)
|
|---|
| 1113 |
|
|---|
| 1114 | 0x00000000
|
|---|
| 1115 | + 0x00006fff (bit 15 not set, so the top half is zero)
|
|---|
| 1116 | ------------
|
|---|
| 1117 | 0x00006fff which is wrong (assuming that fred is at 0xffff). */
|
|---|
| 1118 | {
|
|---|
| 1119 | long result;
|
|---|
| 1120 |
|
|---|
| 1121 | insn = bfd_get_16 (abfd, address);
|
|---|
| 1122 | result = insn + addend;
|
|---|
| 1123 |
|
|---|
| 1124 | #define BIT15_SET(x) ((x) & 0x8000)
|
|---|
| 1125 | #define OVERFLOWS(a,i) ((((a) & 0xffff) + (i)) > 0xffff)
|
|---|
| 1126 |
|
|---|
| 1127 | if ((BIT15_SET (result) && ! BIT15_SET (addend))
|
|---|
| 1128 | || (OVERFLOWS (addend, insn)
|
|---|
| 1129 | && ((! BIT15_SET (insn)) || (BIT15_SET (addend)))))
|
|---|
| 1130 | {
|
|---|
| 1131 | bfd_boolean already_updated;
|
|---|
| 1132 | bfd_byte *hi16s_address = find_remembered_hi16s_reloc
|
|---|
| 1133 | (addend, & already_updated);
|
|---|
| 1134 |
|
|---|
| 1135 | /* Amend the matching HI16_S relocation. */
|
|---|
| 1136 | if (hi16s_address != NULL)
|
|---|
| 1137 | {
|
|---|
| 1138 | if (! already_updated)
|
|---|
| 1139 | {
|
|---|
| 1140 | insn = bfd_get_16 (abfd, hi16s_address);
|
|---|
| 1141 | insn += 1;
|
|---|
| 1142 | bfd_put_16 (abfd, (bfd_vma) insn, hi16s_address);
|
|---|
| 1143 | }
|
|---|
| 1144 | }
|
|---|
| 1145 | else
|
|---|
| 1146 | {
|
|---|
| 1147 | fprintf (stderr, _("FAILED to find previous HI16 reloc\n"));
|
|---|
| 1148 | return bfd_reloc_overflow;
|
|---|
| 1149 | }
|
|---|
| 1150 | }
|
|---|
| 1151 |
|
|---|
| 1152 | /* Do not complain if value has top bit set, as this has been anticipated. */
|
|---|
| 1153 | insn = result & 0xffff;
|
|---|
| 1154 | break;
|
|---|
| 1155 | }
|
|---|
| 1156 |
|
|---|
| 1157 | case R_V850_8:
|
|---|
| 1158 | addend += (char) bfd_get_8 (abfd, address);
|
|---|
| 1159 |
|
|---|
| 1160 | saddend = (bfd_signed_vma) addend;
|
|---|
| 1161 |
|
|---|
| 1162 | if (saddend > 0x7f || saddend < -0x80)
|
|---|
| 1163 | return bfd_reloc_overflow;
|
|---|
| 1164 |
|
|---|
| 1165 | bfd_put_8 (abfd, addend, address);
|
|---|
| 1166 | return bfd_reloc_ok;
|
|---|
| 1167 |
|
|---|
| 1168 | case R_V850_CALLT_16_16_OFFSET:
|
|---|
| 1169 | addend += bfd_get_16 (abfd, address);
|
|---|
| 1170 |
|
|---|
| 1171 | saddend = (bfd_signed_vma) addend;
|
|---|
| 1172 |
|
|---|
| 1173 | if (saddend > 0xffff || saddend < 0)
|
|---|
| 1174 | return bfd_reloc_overflow;
|
|---|
| 1175 |
|
|---|
| 1176 | insn = addend;
|
|---|
| 1177 | break;
|
|---|
| 1178 |
|
|---|
| 1179 | case R_V850_16:
|
|---|
| 1180 |
|
|---|
| 1181 | /* drop through */
|
|---|
| 1182 | case R_V850_SDA_16_16_OFFSET:
|
|---|
| 1183 | case R_V850_ZDA_16_16_OFFSET:
|
|---|
| 1184 | case R_V850_TDA_16_16_OFFSET:
|
|---|
| 1185 | addend += bfd_get_16 (abfd, address);
|
|---|
| 1186 |
|
|---|
| 1187 | saddend = (bfd_signed_vma) addend;
|
|---|
| 1188 |
|
|---|
| 1189 | if (saddend > 0x7fff || saddend < -0x8000)
|
|---|
| 1190 | return bfd_reloc_overflow;
|
|---|
| 1191 |
|
|---|
| 1192 | insn = addend;
|
|---|
| 1193 | break;
|
|---|
| 1194 |
|
|---|
| 1195 | case R_V850_SDA_15_16_OFFSET:
|
|---|
| 1196 | case R_V850_ZDA_15_16_OFFSET:
|
|---|
| 1197 | insn = bfd_get_16 (abfd, address);
|
|---|
| 1198 | addend += (insn & 0xfffe);
|
|---|
| 1199 |
|
|---|
| 1200 | saddend = (bfd_signed_vma) addend;
|
|---|
| 1201 |
|
|---|
| 1202 | if (saddend > 0x7ffe || saddend < -0x8000)
|
|---|
| 1203 | return bfd_reloc_overflow;
|
|---|
| 1204 |
|
|---|
| 1205 | if (addend & 1)
|
|---|
| 1206 | return bfd_reloc_dangerous;
|
|---|
| 1207 |
|
|---|
| 1208 | insn = (addend &~ (bfd_vma) 1) | (insn & 1);
|
|---|
| 1209 | break;
|
|---|
| 1210 |
|
|---|
| 1211 | case R_V850_TDA_6_8_OFFSET:
|
|---|
| 1212 | insn = bfd_get_16 (abfd, address);
|
|---|
| 1213 | addend += ((insn & 0x7e) << 1);
|
|---|
| 1214 |
|
|---|
| 1215 | saddend = (bfd_signed_vma) addend;
|
|---|
| 1216 |
|
|---|
| 1217 | if (saddend > 0xfc || saddend < 0)
|
|---|
| 1218 | return bfd_reloc_overflow;
|
|---|
| 1219 |
|
|---|
| 1220 | if (addend & 3)
|
|---|
| 1221 | return bfd_reloc_dangerous;
|
|---|
| 1222 |
|
|---|
| 1223 | insn &= 0xff81;
|
|---|
| 1224 | insn |= (addend >> 1);
|
|---|
| 1225 | break;
|
|---|
| 1226 |
|
|---|
| 1227 | case R_V850_TDA_7_8_OFFSET:
|
|---|
| 1228 | insn = bfd_get_16 (abfd, address);
|
|---|
| 1229 | addend += ((insn & 0x7f) << 1);
|
|---|
| 1230 |
|
|---|
| 1231 | saddend = (bfd_signed_vma) addend;
|
|---|
| 1232 |
|
|---|
| 1233 | if (saddend > 0xfe || saddend < 0)
|
|---|
| 1234 | return bfd_reloc_overflow;
|
|---|
| 1235 |
|
|---|
| 1236 | if (addend & 1)
|
|---|
| 1237 | return bfd_reloc_dangerous;
|
|---|
| 1238 |
|
|---|
| 1239 | insn &= 0xff80;
|
|---|
| 1240 | insn |= (addend >> 1);
|
|---|
| 1241 | break;
|
|---|
| 1242 |
|
|---|
| 1243 | case R_V850_TDA_7_7_OFFSET:
|
|---|
| 1244 | insn = bfd_get_16 (abfd, address);
|
|---|
| 1245 | addend += insn & 0x7f;
|
|---|
| 1246 |
|
|---|
| 1247 | saddend = (bfd_signed_vma) addend;
|
|---|
| 1248 |
|
|---|
| 1249 | if (saddend > 0x7f || saddend < 0)
|
|---|
| 1250 | return bfd_reloc_overflow;
|
|---|
| 1251 |
|
|---|
| 1252 | insn &= 0xff80;
|
|---|
| 1253 | insn |= addend;
|
|---|
| 1254 | break;
|
|---|
| 1255 |
|
|---|
| 1256 | case R_V850_TDA_4_5_OFFSET:
|
|---|
| 1257 | insn = bfd_get_16 (abfd, address);
|
|---|
| 1258 | addend += ((insn & 0xf) << 1);
|
|---|
| 1259 |
|
|---|
| 1260 | saddend = (bfd_signed_vma) addend;
|
|---|
| 1261 |
|
|---|
| 1262 | if (saddend > 0x1e || saddend < 0)
|
|---|
| 1263 | return bfd_reloc_overflow;
|
|---|
| 1264 |
|
|---|
| 1265 | if (addend & 1)
|
|---|
| 1266 | return bfd_reloc_dangerous;
|
|---|
| 1267 |
|
|---|
| 1268 | insn &= 0xfff0;
|
|---|
| 1269 | insn |= (addend >> 1);
|
|---|
| 1270 | break;
|
|---|
| 1271 |
|
|---|
| 1272 | case R_V850_TDA_4_4_OFFSET:
|
|---|
| 1273 | insn = bfd_get_16 (abfd, address);
|
|---|
| 1274 | addend += insn & 0xf;
|
|---|
| 1275 |
|
|---|
| 1276 | saddend = (bfd_signed_vma) addend;
|
|---|
| 1277 |
|
|---|
| 1278 | if (saddend > 0xf || saddend < 0)
|
|---|
| 1279 | return bfd_reloc_overflow;
|
|---|
| 1280 |
|
|---|
| 1281 | insn &= 0xfff0;
|
|---|
| 1282 | insn |= addend;
|
|---|
| 1283 | break;
|
|---|
| 1284 |
|
|---|
| 1285 | case R_V850_ZDA_16_16_SPLIT_OFFSET:
|
|---|
| 1286 | case R_V850_SDA_16_16_SPLIT_OFFSET:
|
|---|
| 1287 | insn = bfd_get_32 (abfd, address);
|
|---|
| 1288 | addend += ((insn & 0xfffe0000) >> 16) + ((insn & 0x20) >> 5);
|
|---|
| 1289 |
|
|---|
| 1290 | saddend = (bfd_signed_vma) addend;
|
|---|
| 1291 |
|
|---|
| 1292 | if (saddend > 0x7fff || saddend < -0x8000)
|
|---|
| 1293 | return bfd_reloc_overflow;
|
|---|
| 1294 |
|
|---|
| 1295 | insn &= 0x0001ffdf;
|
|---|
| 1296 | insn |= (addend & 1) << 5;
|
|---|
| 1297 | insn |= (addend &~ (bfd_vma) 1) << 16;
|
|---|
| 1298 |
|
|---|
| 1299 | bfd_put_32 (abfd, (bfd_vma) insn, address);
|
|---|
| 1300 | return bfd_reloc_ok;
|
|---|
| 1301 |
|
|---|
| 1302 | case R_V850_CALLT_6_7_OFFSET:
|
|---|
| 1303 | insn = bfd_get_16 (abfd, address);
|
|---|
| 1304 | addend += ((insn & 0x3f) << 1);
|
|---|
| 1305 |
|
|---|
| 1306 | saddend = (bfd_signed_vma) addend;
|
|---|
| 1307 |
|
|---|
| 1308 | if (saddend > 0x7e || saddend < 0)
|
|---|
| 1309 | return bfd_reloc_overflow;
|
|---|
| 1310 |
|
|---|
| 1311 | if (addend & 1)
|
|---|
| 1312 | return bfd_reloc_dangerous;
|
|---|
| 1313 |
|
|---|
| 1314 | insn &= 0xff80;
|
|---|
| 1315 | insn |= (addend >> 1);
|
|---|
| 1316 | break;
|
|---|
| 1317 |
|
|---|
| 1318 | case R_V850_GNU_VTINHERIT:
|
|---|
| 1319 | case R_V850_GNU_VTENTRY:
|
|---|
| 1320 | return bfd_reloc_ok;
|
|---|
| 1321 |
|
|---|
| 1322 | }
|
|---|
| 1323 |
|
|---|
| 1324 | bfd_put_16 (abfd, (bfd_vma) insn, address);
|
|---|
| 1325 | return bfd_reloc_ok;
|
|---|
| 1326 | }
|
|---|
| 1327 | |
|---|
| 1328 |
|
|---|
| 1329 | /* Insert the addend into the instruction. */
|
|---|
| 1330 |
|
|---|
| 1331 | static bfd_reloc_status_type
|
|---|
| 1332 | v850_elf_reloc (abfd, reloc, symbol, data, isection, obfd, err)
|
|---|
| 1333 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1334 | arelent *reloc;
|
|---|
| 1335 | asymbol *symbol;
|
|---|
| 1336 | PTR data ATTRIBUTE_UNUSED;
|
|---|
| 1337 | asection *isection;
|
|---|
| 1338 | bfd *obfd;
|
|---|
| 1339 | char **err ATTRIBUTE_UNUSED;
|
|---|
| 1340 | {
|
|---|
| 1341 | long relocation;
|
|---|
| 1342 |
|
|---|
| 1343 | /* If there is an output BFD,
|
|---|
| 1344 | and the symbol is not a section name (which is only defined at final link time),
|
|---|
| 1345 | and either we are not putting the addend into the instruction
|
|---|
| 1346 | or the addend is zero, so there is nothing to add into the instruction
|
|---|
| 1347 | then just fixup the address and return. */
|
|---|
| 1348 | if (obfd != (bfd *) NULL
|
|---|
| 1349 | && (symbol->flags & BSF_SECTION_SYM) == 0
|
|---|
| 1350 | && (! reloc->howto->partial_inplace
|
|---|
| 1351 | || reloc->addend == 0))
|
|---|
| 1352 | {
|
|---|
| 1353 | reloc->address += isection->output_offset;
|
|---|
| 1354 | return bfd_reloc_ok;
|
|---|
| 1355 | }
|
|---|
| 1356 |
|
|---|
| 1357 | /* Catch relocs involving undefined symbols. */
|
|---|
| 1358 | if (bfd_is_und_section (symbol->section)
|
|---|
| 1359 | && (symbol->flags & BSF_WEAK) == 0
|
|---|
| 1360 | && obfd == NULL)
|
|---|
| 1361 | return bfd_reloc_undefined;
|
|---|
| 1362 |
|
|---|
| 1363 | /* We handle final linking of some relocs ourselves. */
|
|---|
| 1364 |
|
|---|
| 1365 | /* Is the address of the relocation really within the section? */
|
|---|
| 1366 | if (reloc->address > isection->_cooked_size)
|
|---|
| 1367 | return bfd_reloc_outofrange;
|
|---|
| 1368 |
|
|---|
| 1369 | /* Work out which section the relocation is targetted at and the
|
|---|
| 1370 | initial relocation command value. */
|
|---|
| 1371 |
|
|---|
| 1372 | if (reloc->howto->pc_relative)
|
|---|
| 1373 | return bfd_reloc_ok;
|
|---|
| 1374 |
|
|---|
| 1375 | /* Get symbol value. (Common symbols are special.) */
|
|---|
| 1376 | if (bfd_is_com_section (symbol->section))
|
|---|
| 1377 | relocation = 0;
|
|---|
| 1378 | else
|
|---|
| 1379 | relocation = symbol->value;
|
|---|
| 1380 |
|
|---|
| 1381 | /* Convert input-section-relative symbol value to absolute + addend. */
|
|---|
| 1382 | relocation += symbol->section->output_section->vma;
|
|---|
| 1383 | relocation += symbol->section->output_offset;
|
|---|
| 1384 | relocation += reloc->addend;
|
|---|
| 1385 |
|
|---|
| 1386 | #if 0 /* Since this reloc is going to be processed later on, we should
|
|---|
| 1387 | not make it pc-relative here. To test this, try assembling and
|
|---|
| 1388 | linking this program:
|
|---|
| 1389 |
|
|---|
| 1390 | .text
|
|---|
| 1391 | .globl _start
|
|---|
| 1392 | nop
|
|---|
| 1393 | _start:
|
|---|
| 1394 | jr foo
|
|---|
| 1395 |
|
|---|
| 1396 | .section ".foo","ax"
|
|---|
| 1397 | nop
|
|---|
| 1398 | foo:
|
|---|
| 1399 | nop */
|
|---|
| 1400 | if (reloc->howto->pc_relative)
|
|---|
| 1401 | {
|
|---|
| 1402 | /* Here the variable relocation holds the final address of the
|
|---|
| 1403 | symbol we are relocating against, plus any addend. */
|
|---|
| 1404 | relocation -= isection->output_section->vma + isection->output_offset;
|
|---|
| 1405 |
|
|---|
| 1406 | /* Deal with pcrel_offset. */
|
|---|
| 1407 | relocation -= reloc->address;
|
|---|
| 1408 | }
|
|---|
| 1409 | #endif
|
|---|
| 1410 | reloc->addend = relocation;
|
|---|
| 1411 | return bfd_reloc_ok;
|
|---|
| 1412 | }
|
|---|
| 1413 |
|
|---|
| 1414 | /* This function is used for relocs which are only used
|
|---|
| 1415 | for relaxing, which the linker should otherwise ignore. */
|
|---|
| 1416 |
|
|---|
| 1417 | static bfd_reloc_status_type
|
|---|
| 1418 | v850_elf_ignore_reloc (abfd, reloc_entry, symbol, data, input_section,
|
|---|
| 1419 | output_bfd, error_message)
|
|---|
| 1420 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1421 | arelent *reloc_entry;
|
|---|
| 1422 | asymbol *symbol ATTRIBUTE_UNUSED;
|
|---|
| 1423 | PTR data ATTRIBUTE_UNUSED;
|
|---|
| 1424 | asection *input_section;
|
|---|
| 1425 | bfd *output_bfd;
|
|---|
| 1426 | char **error_message ATTRIBUTE_UNUSED;
|
|---|
| 1427 | {
|
|---|
| 1428 | if (output_bfd != NULL)
|
|---|
| 1429 | reloc_entry->address += input_section->output_offset;
|
|---|
| 1430 |
|
|---|
| 1431 | return bfd_reloc_ok;
|
|---|
| 1432 | }
|
|---|
| 1433 | |
|---|
| 1434 |
|
|---|
| 1435 | static bfd_boolean
|
|---|
| 1436 | v850_elf_is_local_label_name (abfd, name)
|
|---|
| 1437 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1438 | const char *name;
|
|---|
| 1439 | {
|
|---|
| 1440 | return ( (name[0] == '.' && (name[1] == 'L' || name[1] == '.'))
|
|---|
| 1441 | || (name[0] == '_' && name[1] == '.' && name[2] == 'L' && name[3] == '_'));
|
|---|
| 1442 | }
|
|---|
| 1443 | |
|---|
| 1444 |
|
|---|
| 1445 | /* We overload some of the bfd_reloc error codes for own purposes. */
|
|---|
| 1446 | #define bfd_reloc_gp_not_found bfd_reloc_other
|
|---|
| 1447 | #define bfd_reloc_ep_not_found bfd_reloc_continue
|
|---|
| 1448 | #define bfd_reloc_ctbp_not_found (bfd_reloc_dangerous + 1)
|
|---|
| 1449 |
|
|---|
| 1450 | /* Perform a relocation as part of a final link. */
|
|---|
| 1451 |
|
|---|
| 1452 | static bfd_reloc_status_type
|
|---|
| 1453 | v850_elf_final_link_relocate (howto, input_bfd, output_bfd,
|
|---|
| 1454 | input_section, contents, offset, value,
|
|---|
| 1455 | addend, info, sym_sec, is_local)
|
|---|
| 1456 | reloc_howto_type *howto;
|
|---|
| 1457 | bfd *input_bfd;
|
|---|
| 1458 | bfd *output_bfd ATTRIBUTE_UNUSED;
|
|---|
| 1459 | asection *input_section;
|
|---|
| 1460 | bfd_byte *contents;
|
|---|
| 1461 | bfd_vma offset;
|
|---|
| 1462 | bfd_vma value;
|
|---|
| 1463 | bfd_vma addend;
|
|---|
| 1464 | struct bfd_link_info *info;
|
|---|
| 1465 | asection *sym_sec;
|
|---|
| 1466 | int is_local ATTRIBUTE_UNUSED;
|
|---|
| 1467 | {
|
|---|
| 1468 | unsigned int r_type = howto->type;
|
|---|
| 1469 | bfd_byte *hit_data = contents + offset;
|
|---|
| 1470 |
|
|---|
| 1471 | /* Adjust the value according to the relocation. */
|
|---|
| 1472 | switch (r_type)
|
|---|
| 1473 | {
|
|---|
| 1474 | case R_V850_9_PCREL:
|
|---|
| 1475 | value -= (input_section->output_section->vma
|
|---|
| 1476 | + input_section->output_offset);
|
|---|
| 1477 | value -= offset;
|
|---|
| 1478 | break;
|
|---|
| 1479 |
|
|---|
| 1480 | case R_V850_22_PCREL:
|
|---|
| 1481 | value -= (input_section->output_section->vma
|
|---|
| 1482 | + input_section->output_offset
|
|---|
| 1483 | + offset);
|
|---|
| 1484 |
|
|---|
| 1485 | /* If the sign extension will corrupt the value then we have overflowed. */
|
|---|
| 1486 | if (((value & 0xff000000) != 0x0) && ((value & 0xff000000) != 0xff000000))
|
|---|
| 1487 | return bfd_reloc_overflow;
|
|---|
| 1488 |
|
|---|
| 1489 | /* Only the bottom 24 bits of the PC are valid */
|
|---|
| 1490 | value = SEXT24 (value);
|
|---|
| 1491 | break;
|
|---|
| 1492 |
|
|---|
| 1493 | case R_V850_REL32:
|
|---|
| 1494 | value -= (input_section->output_section->vma
|
|---|
| 1495 | + input_section->output_offset
|
|---|
| 1496 | + offset);
|
|---|
| 1497 | break;
|
|---|
| 1498 |
|
|---|
| 1499 | case R_V850_HI16_S:
|
|---|
| 1500 | case R_V850_HI16:
|
|---|
| 1501 | case R_V850_LO16:
|
|---|
| 1502 | case R_V850_16:
|
|---|
| 1503 | case R_V850_ABS32:
|
|---|
| 1504 | case R_V850_8:
|
|---|
| 1505 | break;
|
|---|
| 1506 |
|
|---|
| 1507 | case R_V850_ZDA_15_16_OFFSET:
|
|---|
| 1508 | case R_V850_ZDA_16_16_OFFSET:
|
|---|
| 1509 | case R_V850_ZDA_16_16_SPLIT_OFFSET:
|
|---|
| 1510 | if (sym_sec == NULL)
|
|---|
| 1511 | return bfd_reloc_undefined;
|
|---|
| 1512 |
|
|---|
| 1513 | value -= sym_sec->output_section->vma;
|
|---|
| 1514 | break;
|
|---|
| 1515 |
|
|---|
| 1516 | case R_V850_SDA_15_16_OFFSET:
|
|---|
| 1517 | case R_V850_SDA_16_16_OFFSET:
|
|---|
| 1518 | case R_V850_SDA_16_16_SPLIT_OFFSET:
|
|---|
| 1519 | {
|
|---|
| 1520 | unsigned long gp;
|
|---|
| 1521 | struct bfd_link_hash_entry * h;
|
|---|
| 1522 |
|
|---|
| 1523 | if (sym_sec == NULL)
|
|---|
| 1524 | return bfd_reloc_undefined;
|
|---|
| 1525 |
|
|---|
| 1526 | /* Get the value of __gp. */
|
|---|
| 1527 | h = bfd_link_hash_lookup (info->hash, "__gp", FALSE, FALSE, TRUE);
|
|---|
| 1528 | if (h == (struct bfd_link_hash_entry *) NULL
|
|---|
| 1529 | || h->type != bfd_link_hash_defined)
|
|---|
| 1530 | return bfd_reloc_gp_not_found;
|
|---|
| 1531 |
|
|---|
| 1532 | gp = (h->u.def.value
|
|---|
| 1533 | + h->u.def.section->output_section->vma
|
|---|
| 1534 | + h->u.def.section->output_offset);
|
|---|
| 1535 |
|
|---|
| 1536 | value -= sym_sec->output_section->vma;
|
|---|
| 1537 | value -= (gp - sym_sec->output_section->vma);
|
|---|
| 1538 | }
|
|---|
| 1539 | break;
|
|---|
| 1540 |
|
|---|
| 1541 | case R_V850_TDA_4_4_OFFSET:
|
|---|
| 1542 | case R_V850_TDA_4_5_OFFSET:
|
|---|
| 1543 | case R_V850_TDA_16_16_OFFSET:
|
|---|
| 1544 | case R_V850_TDA_7_7_OFFSET:
|
|---|
| 1545 | case R_V850_TDA_7_8_OFFSET:
|
|---|
| 1546 | case R_V850_TDA_6_8_OFFSET:
|
|---|
| 1547 | {
|
|---|
| 1548 | unsigned long ep;
|
|---|
| 1549 | struct bfd_link_hash_entry * h;
|
|---|
| 1550 |
|
|---|
| 1551 | /* Get the value of __ep. */
|
|---|
| 1552 | h = bfd_link_hash_lookup (info->hash, "__ep", FALSE, FALSE, TRUE);
|
|---|
| 1553 | if (h == (struct bfd_link_hash_entry *) NULL
|
|---|
| 1554 | || h->type != bfd_link_hash_defined)
|
|---|
| 1555 | return bfd_reloc_ep_not_found;
|
|---|
| 1556 |
|
|---|
| 1557 | ep = (h->u.def.value
|
|---|
| 1558 | + h->u.def.section->output_section->vma
|
|---|
| 1559 | + h->u.def.section->output_offset);
|
|---|
| 1560 |
|
|---|
| 1561 | value -= ep;
|
|---|
| 1562 | }
|
|---|
| 1563 | break;
|
|---|
| 1564 |
|
|---|
| 1565 | case R_V850_CALLT_6_7_OFFSET:
|
|---|
| 1566 | {
|
|---|
| 1567 | unsigned long ctbp;
|
|---|
| 1568 | struct bfd_link_hash_entry * h;
|
|---|
| 1569 |
|
|---|
| 1570 | /* Get the value of __ctbp. */
|
|---|
| 1571 | h = bfd_link_hash_lookup (info->hash, "__ctbp", FALSE, FALSE, TRUE);
|
|---|
| 1572 | if (h == (struct bfd_link_hash_entry *) NULL
|
|---|
| 1573 | || h->type != bfd_link_hash_defined)
|
|---|
| 1574 | return bfd_reloc_ctbp_not_found;
|
|---|
| 1575 |
|
|---|
| 1576 | ctbp = (h->u.def.value
|
|---|
| 1577 | + h->u.def.section->output_section->vma
|
|---|
| 1578 | + h->u.def.section->output_offset);
|
|---|
| 1579 | value -= ctbp;
|
|---|
| 1580 | }
|
|---|
| 1581 | break;
|
|---|
| 1582 |
|
|---|
| 1583 | case R_V850_CALLT_16_16_OFFSET:
|
|---|
| 1584 | {
|
|---|
| 1585 | unsigned long ctbp;
|
|---|
| 1586 | struct bfd_link_hash_entry * h;
|
|---|
| 1587 |
|
|---|
| 1588 | if (sym_sec == NULL)
|
|---|
| 1589 | return bfd_reloc_undefined;
|
|---|
| 1590 |
|
|---|
| 1591 | /* Get the value of __ctbp. */
|
|---|
| 1592 | h = bfd_link_hash_lookup (info->hash, "__ctbp", FALSE, FALSE, TRUE);
|
|---|
| 1593 | if (h == (struct bfd_link_hash_entry *) NULL
|
|---|
| 1594 | || h->type != bfd_link_hash_defined)
|
|---|
| 1595 | return bfd_reloc_ctbp_not_found;
|
|---|
| 1596 |
|
|---|
| 1597 | ctbp = (h->u.def.value
|
|---|
| 1598 | + h->u.def.section->output_section->vma
|
|---|
| 1599 | + h->u.def.section->output_offset);
|
|---|
| 1600 |
|
|---|
| 1601 | value -= sym_sec->output_section->vma;
|
|---|
| 1602 | value -= (ctbp - sym_sec->output_section->vma);
|
|---|
| 1603 | }
|
|---|
| 1604 | break;
|
|---|
| 1605 |
|
|---|
| 1606 | case R_V850_NONE:
|
|---|
| 1607 | case R_V850_GNU_VTINHERIT:
|
|---|
| 1608 | case R_V850_GNU_VTENTRY:
|
|---|
| 1609 | case R_V850_LONGCALL:
|
|---|
| 1610 | case R_V850_LONGJUMP:
|
|---|
| 1611 | case R_V850_ALIGN:
|
|---|
| 1612 | return bfd_reloc_ok;
|
|---|
| 1613 |
|
|---|
| 1614 | default:
|
|---|
| 1615 | return bfd_reloc_notsupported;
|
|---|
| 1616 | }
|
|---|
| 1617 |
|
|---|
| 1618 | /* Perform the relocation. */
|
|---|
| 1619 | return v850_elf_perform_relocation (input_bfd, r_type, value + addend, hit_data);
|
|---|
| 1620 | }
|
|---|
| 1621 | |
|---|
| 1622 |
|
|---|
| 1623 | /* Relocate an V850 ELF section. */
|
|---|
| 1624 |
|
|---|
| 1625 | static bfd_boolean
|
|---|
| 1626 | v850_elf_relocate_section (output_bfd, info, input_bfd, input_section,
|
|---|
| 1627 | contents, relocs, local_syms, local_sections)
|
|---|
| 1628 | bfd *output_bfd;
|
|---|
| 1629 | struct bfd_link_info *info;
|
|---|
| 1630 | bfd *input_bfd;
|
|---|
| 1631 | asection *input_section;
|
|---|
| 1632 | bfd_byte *contents;
|
|---|
| 1633 | Elf_Internal_Rela *relocs;
|
|---|
| 1634 | Elf_Internal_Sym *local_syms;
|
|---|
| 1635 | asection **local_sections;
|
|---|
| 1636 | {
|
|---|
| 1637 | Elf_Internal_Shdr *symtab_hdr;
|
|---|
| 1638 | struct elf_link_hash_entry **sym_hashes;
|
|---|
| 1639 | Elf_Internal_Rela *rel;
|
|---|
| 1640 | Elf_Internal_Rela *relend;
|
|---|
| 1641 |
|
|---|
| 1642 | if (info->relocateable)
|
|---|
| 1643 | return TRUE;
|
|---|
| 1644 |
|
|---|
| 1645 | symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
|
|---|
| 1646 | sym_hashes = elf_sym_hashes (input_bfd);
|
|---|
| 1647 |
|
|---|
| 1648 | if (sym_hashes == NULL)
|
|---|
| 1649 | {
|
|---|
| 1650 | info->callbacks->warning
|
|---|
| 1651 | (info, "no hash table available",
|
|---|
| 1652 | NULL, input_bfd, input_section, (bfd_vma) 0);
|
|---|
| 1653 |
|
|---|
| 1654 | return FALSE;
|
|---|
| 1655 | }
|
|---|
| 1656 |
|
|---|
| 1657 | /* Reset the list of remembered HI16S relocs to empty. */
|
|---|
| 1658 | free_hi16s = previous_hi16s;
|
|---|
| 1659 | previous_hi16s = NULL;
|
|---|
| 1660 | hi16s_counter = 0;
|
|---|
| 1661 |
|
|---|
| 1662 | rel = relocs;
|
|---|
| 1663 | relend = relocs + input_section->reloc_count;
|
|---|
| 1664 | for (; rel < relend; rel++)
|
|---|
| 1665 | {
|
|---|
| 1666 | int r_type;
|
|---|
| 1667 | reloc_howto_type *howto;
|
|---|
| 1668 | unsigned long r_symndx;
|
|---|
| 1669 | Elf_Internal_Sym *sym;
|
|---|
| 1670 | asection *sec;
|
|---|
| 1671 | struct elf_link_hash_entry *h;
|
|---|
| 1672 | bfd_vma relocation;
|
|---|
| 1673 | bfd_reloc_status_type r;
|
|---|
| 1674 |
|
|---|
| 1675 | r_symndx = ELF32_R_SYM (rel->r_info);
|
|---|
| 1676 | r_type = ELF32_R_TYPE (rel->r_info);
|
|---|
| 1677 |
|
|---|
| 1678 | if (r_type == R_V850_GNU_VTENTRY
|
|---|
| 1679 | || r_type == R_V850_GNU_VTINHERIT)
|
|---|
| 1680 | continue;
|
|---|
| 1681 |
|
|---|
| 1682 | /* This is a final link. */
|
|---|
| 1683 | howto = v850_elf_howto_table + r_type;
|
|---|
| 1684 | h = NULL;
|
|---|
| 1685 | sym = NULL;
|
|---|
| 1686 | sec = NULL;
|
|---|
| 1687 | if (r_symndx < symtab_hdr->sh_info)
|
|---|
| 1688 | {
|
|---|
| 1689 | sym = local_syms + r_symndx;
|
|---|
| 1690 | sec = local_sections[r_symndx];
|
|---|
| 1691 | relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
|
|---|
| 1692 | #if 0
|
|---|
| 1693 | {
|
|---|
| 1694 | char * name;
|
|---|
| 1695 |
|
|---|
| 1696 | name = bfd_elf_string_from_elf_section (input_bfd, symtab_hdr->sh_link, sym->st_name);
|
|---|
| 1697 | name = (name == NULL) ? "<none>" : name;
|
|---|
| 1698 | fprintf (stderr, "local: sec: %s, sym: %s (%d), value: %x + %x + %x addend %x\n",
|
|---|
| 1699 | sec->name, name, sym->st_name,
|
|---|
| 1700 | sec->output_section->vma, sec->output_offset, sym->st_value, rel->r_addend);
|
|---|
| 1701 | }
|
|---|
| 1702 | #endif
|
|---|
| 1703 | }
|
|---|
| 1704 | else
|
|---|
| 1705 | {
|
|---|
| 1706 | h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
|---|
| 1707 |
|
|---|
| 1708 | while (h->root.type == bfd_link_hash_indirect
|
|---|
| 1709 | || h->root.type == bfd_link_hash_warning)
|
|---|
| 1710 | h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|---|
| 1711 |
|
|---|
| 1712 | if (h->root.type == bfd_link_hash_defined
|
|---|
| 1713 | || h->root.type == bfd_link_hash_defweak)
|
|---|
| 1714 | {
|
|---|
| 1715 | sec = h->root.u.def.section;
|
|---|
| 1716 | relocation = (h->root.u.def.value
|
|---|
| 1717 | + sec->output_section->vma
|
|---|
| 1718 | + sec->output_offset);
|
|---|
| 1719 | #if 0
|
|---|
| 1720 | fprintf (stderr, "defined: sec: %s, name: %s, value: %x + %x + %x gives: %x\n",
|
|---|
| 1721 | sec->name, h->root.root.string, h->root.u.def.value, sec->output_section->vma, sec->output_offset, relocation);
|
|---|
| 1722 | #endif
|
|---|
| 1723 | }
|
|---|
| 1724 | else if (h->root.type == bfd_link_hash_undefweak)
|
|---|
| 1725 | {
|
|---|
| 1726 | #if 0
|
|---|
| 1727 | fprintf (stderr, "undefined: sec: %s, name: %s\n",
|
|---|
| 1728 | sec->name, h->root.root.string);
|
|---|
| 1729 | #endif
|
|---|
| 1730 | relocation = 0;
|
|---|
| 1731 | }
|
|---|
| 1732 | else
|
|---|
| 1733 | {
|
|---|
| 1734 | if (! ((*info->callbacks->undefined_symbol)
|
|---|
| 1735 | (info, h->root.root.string, input_bfd,
|
|---|
| 1736 | input_section, rel->r_offset, TRUE)))
|
|---|
| 1737 | return FALSE;
|
|---|
| 1738 | #if 0
|
|---|
| 1739 | fprintf (stderr, "unknown: name: %s\n", h->root.root.string);
|
|---|
| 1740 | #endif
|
|---|
| 1741 | relocation = 0;
|
|---|
| 1742 | }
|
|---|
| 1743 | }
|
|---|
| 1744 |
|
|---|
| 1745 | /* FIXME: We should use the addend, but the COFF relocations don't. */
|
|---|
| 1746 | r = v850_elf_final_link_relocate (howto, input_bfd, output_bfd,
|
|---|
| 1747 | input_section,
|
|---|
| 1748 | contents, rel->r_offset,
|
|---|
| 1749 | relocation, rel->r_addend,
|
|---|
| 1750 | info, sec, h == NULL);
|
|---|
| 1751 |
|
|---|
| 1752 | if (r != bfd_reloc_ok)
|
|---|
| 1753 | {
|
|---|
| 1754 | const char * name;
|
|---|
| 1755 | const char * msg = (const char *)0;
|
|---|
| 1756 |
|
|---|
| 1757 | if (h != NULL)
|
|---|
| 1758 | name = h->root.root.string;
|
|---|
| 1759 | else
|
|---|
| 1760 | {
|
|---|
| 1761 | name = (bfd_elf_string_from_elf_section
|
|---|
| 1762 | (input_bfd, symtab_hdr->sh_link, sym->st_name));
|
|---|
| 1763 | if (name == NULL || *name == '\0')
|
|---|
| 1764 | name = bfd_section_name (input_bfd, sec);
|
|---|
| 1765 | }
|
|---|
| 1766 |
|
|---|
| 1767 | switch (r)
|
|---|
| 1768 | {
|
|---|
| 1769 | case bfd_reloc_overflow:
|
|---|
| 1770 | if (! ((*info->callbacks->reloc_overflow)
|
|---|
| 1771 | (info, name, howto->name, (bfd_vma) 0,
|
|---|
| 1772 | input_bfd, input_section, rel->r_offset)))
|
|---|
| 1773 | return FALSE;
|
|---|
| 1774 | break;
|
|---|
| 1775 |
|
|---|
| 1776 | case bfd_reloc_undefined:
|
|---|
| 1777 | if (! ((*info->callbacks->undefined_symbol)
|
|---|
| 1778 | (info, name, input_bfd, input_section,
|
|---|
| 1779 | rel->r_offset, TRUE)))
|
|---|
| 1780 | return FALSE;
|
|---|
| 1781 | break;
|
|---|
| 1782 |
|
|---|
| 1783 | case bfd_reloc_outofrange:
|
|---|
| 1784 | msg = _("internal error: out of range error");
|
|---|
| 1785 | goto common_error;
|
|---|
| 1786 |
|
|---|
| 1787 | case bfd_reloc_notsupported:
|
|---|
| 1788 | msg = _("internal error: unsupported relocation error");
|
|---|
| 1789 | goto common_error;
|
|---|
| 1790 |
|
|---|
| 1791 | case bfd_reloc_dangerous:
|
|---|
| 1792 | msg = _("internal error: dangerous relocation");
|
|---|
| 1793 | goto common_error;
|
|---|
| 1794 |
|
|---|
| 1795 | case bfd_reloc_gp_not_found:
|
|---|
| 1796 | msg = _("could not locate special linker symbol __gp");
|
|---|
| 1797 | goto common_error;
|
|---|
| 1798 |
|
|---|
| 1799 | case bfd_reloc_ep_not_found:
|
|---|
| 1800 | msg = _("could not locate special linker symbol __ep");
|
|---|
| 1801 | goto common_error;
|
|---|
| 1802 |
|
|---|
| 1803 | case bfd_reloc_ctbp_not_found:
|
|---|
| 1804 | msg = _("could not locate special linker symbol __ctbp");
|
|---|
| 1805 | goto common_error;
|
|---|
| 1806 |
|
|---|
| 1807 | default:
|
|---|
| 1808 | msg = _("internal error: unknown error");
|
|---|
| 1809 | /* fall through */
|
|---|
| 1810 |
|
|---|
| 1811 | common_error:
|
|---|
| 1812 | if (!((*info->callbacks->warning)
|
|---|
| 1813 | (info, msg, name, input_bfd, input_section,
|
|---|
| 1814 | rel->r_offset)))
|
|---|
| 1815 | return FALSE;
|
|---|
| 1816 | break;
|
|---|
| 1817 | }
|
|---|
| 1818 | }
|
|---|
| 1819 | }
|
|---|
| 1820 |
|
|---|
| 1821 | return TRUE;
|
|---|
| 1822 | }
|
|---|
| 1823 |
|
|---|
| 1824 | static bfd_boolean
|
|---|
| 1825 | v850_elf_gc_sweep_hook (abfd, info, sec, relocs)
|
|---|
| 1826 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1827 | struct bfd_link_info *info ATTRIBUTE_UNUSED;
|
|---|
| 1828 | asection *sec ATTRIBUTE_UNUSED;
|
|---|
| 1829 | const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;
|
|---|
| 1830 | {
|
|---|
| 1831 | /* No got and plt entries for v850-elf. */
|
|---|
| 1832 | return TRUE;
|
|---|
| 1833 | }
|
|---|
| 1834 |
|
|---|
| 1835 | static asection *
|
|---|
| 1836 | v850_elf_gc_mark_hook (sec, info, rel, h, sym)
|
|---|
| 1837 | asection *sec;
|
|---|
| 1838 | struct bfd_link_info *info ATTRIBUTE_UNUSED;
|
|---|
| 1839 | Elf_Internal_Rela *rel;
|
|---|
| 1840 | struct elf_link_hash_entry *h;
|
|---|
| 1841 | Elf_Internal_Sym *sym;
|
|---|
| 1842 | {
|
|---|
| 1843 | if (h != NULL)
|
|---|
| 1844 | {
|
|---|
| 1845 | switch (ELF32_R_TYPE (rel->r_info))
|
|---|
| 1846 | {
|
|---|
| 1847 | case R_V850_GNU_VTINHERIT:
|
|---|
| 1848 | case R_V850_GNU_VTENTRY:
|
|---|
| 1849 | break;
|
|---|
| 1850 |
|
|---|
| 1851 | default:
|
|---|
| 1852 | switch (h->root.type)
|
|---|
| 1853 | {
|
|---|
| 1854 | case bfd_link_hash_defined:
|
|---|
| 1855 | case bfd_link_hash_defweak:
|
|---|
| 1856 | return h->root.u.def.section;
|
|---|
| 1857 |
|
|---|
| 1858 | case bfd_link_hash_common:
|
|---|
| 1859 | return h->root.u.c.p->section;
|
|---|
| 1860 |
|
|---|
| 1861 | default:
|
|---|
| 1862 | break;
|
|---|
| 1863 | }
|
|---|
| 1864 | }
|
|---|
| 1865 | }
|
|---|
| 1866 | else
|
|---|
| 1867 | return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
|
|---|
| 1868 |
|
|---|
| 1869 | return NULL;
|
|---|
| 1870 | }
|
|---|
| 1871 |
|
|---|
| 1872 | /* Set the right machine number. */
|
|---|
| 1873 |
|
|---|
| 1874 | static bfd_boolean
|
|---|
| 1875 | v850_elf_object_p (abfd)
|
|---|
| 1876 | bfd *abfd;
|
|---|
| 1877 | {
|
|---|
| 1878 | switch (elf_elfheader (abfd)->e_flags & EF_V850_ARCH)
|
|---|
| 1879 | {
|
|---|
| 1880 | default:
|
|---|
| 1881 | case E_V850_ARCH:
|
|---|
| 1882 | bfd_default_set_arch_mach (abfd, bfd_arch_v850, bfd_mach_v850);
|
|---|
| 1883 | break;
|
|---|
| 1884 | case E_V850E_ARCH:
|
|---|
| 1885 | bfd_default_set_arch_mach (abfd, bfd_arch_v850, bfd_mach_v850e);
|
|---|
| 1886 | break;
|
|---|
| 1887 | }
|
|---|
| 1888 | return TRUE;
|
|---|
| 1889 | }
|
|---|
| 1890 |
|
|---|
| 1891 | /* Store the machine number in the flags field. */
|
|---|
| 1892 |
|
|---|
| 1893 | static void
|
|---|
| 1894 | v850_elf_final_write_processing (abfd, linker)
|
|---|
| 1895 | bfd *abfd;
|
|---|
| 1896 | bfd_boolean linker ATTRIBUTE_UNUSED;
|
|---|
| 1897 | {
|
|---|
| 1898 | unsigned long val;
|
|---|
| 1899 |
|
|---|
| 1900 | switch (bfd_get_mach (abfd))
|
|---|
| 1901 | {
|
|---|
| 1902 | default:
|
|---|
| 1903 | case bfd_mach_v850: val = E_V850_ARCH; break;
|
|---|
| 1904 | case bfd_mach_v850e: val = E_V850E_ARCH; break;
|
|---|
| 1905 | }
|
|---|
| 1906 |
|
|---|
| 1907 | elf_elfheader (abfd)->e_flags &=~ EF_V850_ARCH;
|
|---|
| 1908 | elf_elfheader (abfd)->e_flags |= val;
|
|---|
| 1909 | }
|
|---|
| 1910 |
|
|---|
| 1911 | /* Function to keep V850 specific file flags. */
|
|---|
| 1912 |
|
|---|
| 1913 | static bfd_boolean
|
|---|
| 1914 | v850_elf_set_private_flags (abfd, flags)
|
|---|
| 1915 | bfd *abfd;
|
|---|
| 1916 | flagword flags;
|
|---|
| 1917 | {
|
|---|
| 1918 | BFD_ASSERT (!elf_flags_init (abfd)
|
|---|
| 1919 | || elf_elfheader (abfd)->e_flags == flags);
|
|---|
| 1920 |
|
|---|
| 1921 | elf_elfheader (abfd)->e_flags = flags;
|
|---|
| 1922 | elf_flags_init (abfd) = TRUE;
|
|---|
| 1923 | return TRUE;
|
|---|
| 1924 | }
|
|---|
| 1925 |
|
|---|
| 1926 | /* Merge backend specific data from an object file
|
|---|
| 1927 | to the output object file when linking. */
|
|---|
| 1928 | static bfd_boolean
|
|---|
| 1929 | v850_elf_merge_private_bfd_data (ibfd, obfd)
|
|---|
| 1930 | bfd *ibfd;
|
|---|
| 1931 | bfd *obfd;
|
|---|
| 1932 | {
|
|---|
| 1933 | flagword out_flags;
|
|---|
| 1934 | flagword in_flags;
|
|---|
| 1935 |
|
|---|
| 1936 | if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
|
|---|
| 1937 | || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
|
|---|
| 1938 | return TRUE;
|
|---|
| 1939 |
|
|---|
| 1940 | in_flags = elf_elfheader (ibfd)->e_flags;
|
|---|
| 1941 | out_flags = elf_elfheader (obfd)->e_flags;
|
|---|
| 1942 |
|
|---|
| 1943 | if (! elf_flags_init (obfd))
|
|---|
| 1944 | {
|
|---|
| 1945 | /* If the input is the default architecture then do not
|
|---|
| 1946 | bother setting the flags for the output architecture,
|
|---|
| 1947 | instead allow future merges to do this. If no future
|
|---|
| 1948 | merges ever set these flags then they will retain their
|
|---|
| 1949 | unitialised values, which surprise surprise, correspond
|
|---|
| 1950 | to the default values. */
|
|---|
| 1951 | if (bfd_get_arch_info (ibfd)->the_default)
|
|---|
| 1952 | return TRUE;
|
|---|
| 1953 |
|
|---|
| 1954 | elf_flags_init (obfd) = TRUE;
|
|---|
| 1955 | elf_elfheader (obfd)->e_flags = in_flags;
|
|---|
| 1956 |
|
|---|
| 1957 | if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
|
|---|
| 1958 | && bfd_get_arch_info (obfd)->the_default)
|
|---|
| 1959 | return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd));
|
|---|
| 1960 |
|
|---|
| 1961 | return TRUE;
|
|---|
| 1962 | }
|
|---|
| 1963 |
|
|---|
| 1964 | /* Check flag compatibility. */
|
|---|
| 1965 | if (in_flags == out_flags)
|
|---|
| 1966 | return TRUE;
|
|---|
| 1967 |
|
|---|
| 1968 | if ((in_flags & EF_V850_ARCH) != (out_flags & EF_V850_ARCH)
|
|---|
| 1969 | && (in_flags & EF_V850_ARCH) != E_V850_ARCH)
|
|---|
| 1970 | _bfd_error_handler (_("%s: Architecture mismatch with previous modules"),
|
|---|
| 1971 | bfd_archive_filename (ibfd));
|
|---|
| 1972 |
|
|---|
| 1973 | return TRUE;
|
|---|
| 1974 | }
|
|---|
| 1975 |
|
|---|
| 1976 | /* Display the flags field. */
|
|---|
| 1977 |
|
|---|
| 1978 | static bfd_boolean
|
|---|
| 1979 | v850_elf_print_private_bfd_data (abfd, ptr)
|
|---|
| 1980 | bfd *abfd;
|
|---|
| 1981 | PTR ptr;
|
|---|
| 1982 | {
|
|---|
| 1983 | FILE * file = (FILE *) ptr;
|
|---|
| 1984 |
|
|---|
| 1985 | BFD_ASSERT (abfd != NULL && ptr != NULL);
|
|---|
| 1986 |
|
|---|
| 1987 | _bfd_elf_print_private_bfd_data (abfd, ptr);
|
|---|
| 1988 |
|
|---|
| 1989 | /* xgettext:c-format */
|
|---|
| 1990 | fprintf (file, _("private flags = %lx: "), elf_elfheader (abfd)->e_flags);
|
|---|
| 1991 |
|
|---|
| 1992 | switch (elf_elfheader (abfd)->e_flags & EF_V850_ARCH)
|
|---|
| 1993 | {
|
|---|
| 1994 | default:
|
|---|
| 1995 | case E_V850_ARCH: fprintf (file, _("v850 architecture")); break;
|
|---|
| 1996 | case E_V850E_ARCH: fprintf (file, _("v850e architecture")); break;
|
|---|
| 1997 | }
|
|---|
| 1998 |
|
|---|
| 1999 | fputc ('\n', file);
|
|---|
| 2000 |
|
|---|
| 2001 | return TRUE;
|
|---|
| 2002 | }
|
|---|
| 2003 |
|
|---|
| 2004 | /* V850 ELF uses four common sections. One is the usual one, and the
|
|---|
| 2005 | others are for (small) objects in one of the special data areas:
|
|---|
| 2006 | small, tiny and zero. All the objects are kept together, and then
|
|---|
| 2007 | referenced via the gp register, the ep register or the r0 register
|
|---|
| 2008 | respectively, which yields smaller, faster assembler code. This
|
|---|
| 2009 | approach is copied from elf32-mips.c. */
|
|---|
| 2010 |
|
|---|
| 2011 | static asection v850_elf_scom_section;
|
|---|
| 2012 | static asymbol v850_elf_scom_symbol;
|
|---|
| 2013 | static asymbol * v850_elf_scom_symbol_ptr;
|
|---|
| 2014 | static asection v850_elf_tcom_section;
|
|---|
| 2015 | static asymbol v850_elf_tcom_symbol;
|
|---|
| 2016 | static asymbol * v850_elf_tcom_symbol_ptr;
|
|---|
| 2017 | static asection v850_elf_zcom_section;
|
|---|
| 2018 | static asymbol v850_elf_zcom_symbol;
|
|---|
| 2019 | static asymbol * v850_elf_zcom_symbol_ptr;
|
|---|
| 2020 |
|
|---|
| 2021 | /* Given a BFD section, try to locate the
|
|---|
| 2022 | corresponding ELF section index. */
|
|---|
| 2023 |
|
|---|
| 2024 | static bfd_boolean
|
|---|
| 2025 | v850_elf_section_from_bfd_section (abfd, sec, retval)
|
|---|
| 2026 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 2027 | asection *sec;
|
|---|
| 2028 | int *retval;
|
|---|
| 2029 | {
|
|---|
| 2030 | if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0)
|
|---|
| 2031 | *retval = SHN_V850_SCOMMON;
|
|---|
| 2032 | else if (strcmp (bfd_get_section_name (abfd, sec), ".tcommon") == 0)
|
|---|
| 2033 | *retval = SHN_V850_TCOMMON;
|
|---|
| 2034 | else if (strcmp (bfd_get_section_name (abfd, sec), ".zcommon") == 0)
|
|---|
| 2035 | *retval = SHN_V850_ZCOMMON;
|
|---|
| 2036 | else
|
|---|
| 2037 | return FALSE;
|
|---|
| 2038 |
|
|---|
| 2039 | return TRUE;
|
|---|
| 2040 | }
|
|---|
| 2041 |
|
|---|
| 2042 | /* Handle the special V850 section numbers that a symbol may use. */
|
|---|
| 2043 |
|
|---|
| 2044 | static void
|
|---|
| 2045 | v850_elf_symbol_processing (abfd, asym)
|
|---|
| 2046 | bfd *abfd;
|
|---|
| 2047 | asymbol *asym;
|
|---|
| 2048 | {
|
|---|
| 2049 | elf_symbol_type * elfsym = (elf_symbol_type *) asym;
|
|---|
| 2050 | unsigned int indx;
|
|---|
| 2051 |
|
|---|
| 2052 | indx = elfsym->internal_elf_sym.st_shndx;
|
|---|
| 2053 |
|
|---|
| 2054 | /* If the section index is an "ordinary" index, then it may
|
|---|
| 2055 | refer to a v850 specific section created by the assembler.
|
|---|
| 2056 | Check the section's type and change the index it matches.
|
|---|
| 2057 |
|
|---|
| 2058 | FIXME: Should we alter the st_shndx field as well ? */
|
|---|
| 2059 |
|
|---|
| 2060 | if (indx < elf_numsections (abfd))
|
|---|
| 2061 | switch (elf_elfsections(abfd)[indx]->sh_type)
|
|---|
| 2062 | {
|
|---|
| 2063 | case SHT_V850_SCOMMON:
|
|---|
| 2064 | indx = SHN_V850_SCOMMON;
|
|---|
| 2065 | break;
|
|---|
| 2066 |
|
|---|
| 2067 | case SHT_V850_TCOMMON:
|
|---|
| 2068 | indx = SHN_V850_TCOMMON;
|
|---|
| 2069 | break;
|
|---|
| 2070 |
|
|---|
| 2071 | case SHT_V850_ZCOMMON:
|
|---|
| 2072 | indx = SHN_V850_ZCOMMON;
|
|---|
| 2073 | break;
|
|---|
| 2074 |
|
|---|
| 2075 | default:
|
|---|
| 2076 | break;
|
|---|
| 2077 | }
|
|---|
| 2078 |
|
|---|
| 2079 | switch (indx)
|
|---|
| 2080 | {
|
|---|
| 2081 | case SHN_V850_SCOMMON:
|
|---|
| 2082 | if (v850_elf_scom_section.name == NULL)
|
|---|
| 2083 | {
|
|---|
| 2084 | /* Initialize the small common section. */
|
|---|
| 2085 | v850_elf_scom_section.name = ".scommon";
|
|---|
| 2086 | v850_elf_scom_section.flags = SEC_IS_COMMON | SEC_ALLOC | SEC_DATA;
|
|---|
| 2087 | v850_elf_scom_section.output_section = & v850_elf_scom_section;
|
|---|
| 2088 | v850_elf_scom_section.symbol = & v850_elf_scom_symbol;
|
|---|
| 2089 | v850_elf_scom_section.symbol_ptr_ptr = & v850_elf_scom_symbol_ptr;
|
|---|
| 2090 | v850_elf_scom_symbol.name = ".scommon";
|
|---|
| 2091 | v850_elf_scom_symbol.flags = BSF_SECTION_SYM;
|
|---|
| 2092 | v850_elf_scom_symbol.section = & v850_elf_scom_section;
|
|---|
| 2093 | v850_elf_scom_symbol_ptr = & v850_elf_scom_symbol;
|
|---|
| 2094 | }
|
|---|
| 2095 | asym->section = & v850_elf_scom_section;
|
|---|
| 2096 | asym->value = elfsym->internal_elf_sym.st_size;
|
|---|
| 2097 | break;
|
|---|
| 2098 |
|
|---|
| 2099 | case SHN_V850_TCOMMON:
|
|---|
| 2100 | if (v850_elf_tcom_section.name == NULL)
|
|---|
| 2101 | {
|
|---|
| 2102 | /* Initialize the tcommon section. */
|
|---|
| 2103 | v850_elf_tcom_section.name = ".tcommon";
|
|---|
| 2104 | v850_elf_tcom_section.flags = SEC_IS_COMMON;
|
|---|
| 2105 | v850_elf_tcom_section.output_section = & v850_elf_tcom_section;
|
|---|
| 2106 | v850_elf_tcom_section.symbol = & v850_elf_tcom_symbol;
|
|---|
| 2107 | v850_elf_tcom_section.symbol_ptr_ptr = & v850_elf_tcom_symbol_ptr;
|
|---|
| 2108 | v850_elf_tcom_symbol.name = ".tcommon";
|
|---|
| 2109 | v850_elf_tcom_symbol.flags = BSF_SECTION_SYM;
|
|---|
| 2110 | v850_elf_tcom_symbol.section = & v850_elf_tcom_section;
|
|---|
| 2111 | v850_elf_tcom_symbol_ptr = & v850_elf_tcom_symbol;
|
|---|
| 2112 | }
|
|---|
| 2113 | asym->section = & v850_elf_tcom_section;
|
|---|
| 2114 | asym->value = elfsym->internal_elf_sym.st_size;
|
|---|
| 2115 | break;
|
|---|
| 2116 |
|
|---|
| 2117 | case SHN_V850_ZCOMMON:
|
|---|
| 2118 | if (v850_elf_zcom_section.name == NULL)
|
|---|
| 2119 | {
|
|---|
| 2120 | /* Initialize the zcommon section. */
|
|---|
| 2121 | v850_elf_zcom_section.name = ".zcommon";
|
|---|
| 2122 | v850_elf_zcom_section.flags = SEC_IS_COMMON;
|
|---|
| 2123 | v850_elf_zcom_section.output_section = & v850_elf_zcom_section;
|
|---|
| 2124 | v850_elf_zcom_section.symbol = & v850_elf_zcom_symbol;
|
|---|
| 2125 | v850_elf_zcom_section.symbol_ptr_ptr = & v850_elf_zcom_symbol_ptr;
|
|---|
| 2126 | v850_elf_zcom_symbol.name = ".zcommon";
|
|---|
| 2127 | v850_elf_zcom_symbol.flags = BSF_SECTION_SYM;
|
|---|
| 2128 | v850_elf_zcom_symbol.section = & v850_elf_zcom_section;
|
|---|
| 2129 | v850_elf_zcom_symbol_ptr = & v850_elf_zcom_symbol;
|
|---|
| 2130 | }
|
|---|
| 2131 | asym->section = & v850_elf_zcom_section;
|
|---|
| 2132 | asym->value = elfsym->internal_elf_sym.st_size;
|
|---|
| 2133 | break;
|
|---|
| 2134 | }
|
|---|
| 2135 | }
|
|---|
| 2136 |
|
|---|
| 2137 | /* Hook called by the linker routine which adds symbols from an object
|
|---|
| 2138 | file. We must handle the special v850 section numbers here. */
|
|---|
| 2139 |
|
|---|
| 2140 | static bfd_boolean
|
|---|
| 2141 | v850_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
|
|---|
| 2142 | bfd *abfd;
|
|---|
| 2143 | struct bfd_link_info *info ATTRIBUTE_UNUSED;
|
|---|
| 2144 | const Elf_Internal_Sym *sym;
|
|---|
| 2145 | const char **namep ATTRIBUTE_UNUSED;
|
|---|
| 2146 | flagword *flagsp ATTRIBUTE_UNUSED;
|
|---|
| 2147 | asection **secp;
|
|---|
| 2148 | bfd_vma *valp;
|
|---|
| 2149 | {
|
|---|
| 2150 | unsigned int indx = sym->st_shndx;
|
|---|
| 2151 |
|
|---|
| 2152 | /* If the section index is an "ordinary" index, then it may
|
|---|
| 2153 | refer to a v850 specific section created by the assembler.
|
|---|
| 2154 | Check the section's type and change the index it matches.
|
|---|
| 2155 |
|
|---|
| 2156 | FIXME: Should we alter the st_shndx field as well ? */
|
|---|
| 2157 |
|
|---|
| 2158 | if (indx < elf_numsections (abfd))
|
|---|
| 2159 | switch (elf_elfsections(abfd)[indx]->sh_type)
|
|---|
| 2160 | {
|
|---|
| 2161 | case SHT_V850_SCOMMON:
|
|---|
| 2162 | indx = SHN_V850_SCOMMON;
|
|---|
| 2163 | break;
|
|---|
| 2164 |
|
|---|
| 2165 | case SHT_V850_TCOMMON:
|
|---|
| 2166 | indx = SHN_V850_TCOMMON;
|
|---|
| 2167 | break;
|
|---|
| 2168 |
|
|---|
| 2169 | case SHT_V850_ZCOMMON:
|
|---|
| 2170 | indx = SHN_V850_ZCOMMON;
|
|---|
| 2171 | break;
|
|---|
| 2172 |
|
|---|
| 2173 | default:
|
|---|
| 2174 | break;
|
|---|
| 2175 | }
|
|---|
| 2176 |
|
|---|
| 2177 | switch (indx)
|
|---|
| 2178 | {
|
|---|
| 2179 | case SHN_V850_SCOMMON:
|
|---|
| 2180 | *secp = bfd_make_section_old_way (abfd, ".scommon");
|
|---|
| 2181 | (*secp)->flags |= SEC_IS_COMMON;
|
|---|
| 2182 | *valp = sym->st_size;
|
|---|
| 2183 | break;
|
|---|
| 2184 |
|
|---|
| 2185 | case SHN_V850_TCOMMON:
|
|---|
| 2186 | *secp = bfd_make_section_old_way (abfd, ".tcommon");
|
|---|
| 2187 | (*secp)->flags |= SEC_IS_COMMON;
|
|---|
| 2188 | *valp = sym->st_size;
|
|---|
| 2189 | break;
|
|---|
| 2190 |
|
|---|
| 2191 | case SHN_V850_ZCOMMON:
|
|---|
| 2192 | *secp = bfd_make_section_old_way (abfd, ".zcommon");
|
|---|
| 2193 | (*secp)->flags |= SEC_IS_COMMON;
|
|---|
| 2194 | *valp = sym->st_size;
|
|---|
| 2195 | break;
|
|---|
| 2196 | }
|
|---|
| 2197 |
|
|---|
| 2198 | return TRUE;
|
|---|
| 2199 | }
|
|---|
| 2200 |
|
|---|
| 2201 | static bfd_boolean
|
|---|
| 2202 | v850_elf_link_output_symbol_hook (abfd, info, name, sym, input_sec)
|
|---|
| 2203 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 2204 | struct bfd_link_info *info ATTRIBUTE_UNUSED;
|
|---|
| 2205 | const char *name ATTRIBUTE_UNUSED;
|
|---|
| 2206 | Elf_Internal_Sym *sym;
|
|---|
| 2207 | asection *input_sec;
|
|---|
| 2208 | {
|
|---|
| 2209 | /* If we see a common symbol, which implies a relocatable link, then
|
|---|
| 2210 | if a symbol was in a special common section in an input file, mark
|
|---|
| 2211 | it as a special common in the output file. */
|
|---|
| 2212 |
|
|---|
| 2213 | if (sym->st_shndx == SHN_COMMON)
|
|---|
| 2214 | {
|
|---|
| 2215 | if (strcmp (input_sec->name, ".scommon") == 0)
|
|---|
| 2216 | sym->st_shndx = SHN_V850_SCOMMON;
|
|---|
| 2217 | else if (strcmp (input_sec->name, ".tcommon") == 0)
|
|---|
| 2218 | sym->st_shndx = SHN_V850_TCOMMON;
|
|---|
| 2219 | else if (strcmp (input_sec->name, ".zcommon") == 0)
|
|---|
| 2220 | sym->st_shndx = SHN_V850_ZCOMMON;
|
|---|
| 2221 | }
|
|---|
| 2222 |
|
|---|
| 2223 | return TRUE;
|
|---|
| 2224 | }
|
|---|
| 2225 |
|
|---|
| 2226 | static bfd_boolean
|
|---|
| 2227 | v850_elf_section_from_shdr (abfd, hdr, name)
|
|---|
| 2228 | bfd *abfd;
|
|---|
| 2229 | Elf_Internal_Shdr *hdr;
|
|---|
| 2230 | const char *name;
|
|---|
| 2231 | {
|
|---|
| 2232 | /* There ought to be a place to keep ELF backend specific flags, but
|
|---|
| 2233 | at the moment there isn't one. We just keep track of the
|
|---|
| 2234 | sections by their name, instead. */
|
|---|
| 2235 |
|
|---|
| 2236 | if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
|
|---|
| 2237 | return FALSE;
|
|---|
| 2238 |
|
|---|
| 2239 | switch (hdr->sh_type)
|
|---|
| 2240 | {
|
|---|
| 2241 | case SHT_V850_SCOMMON:
|
|---|
| 2242 | case SHT_V850_TCOMMON:
|
|---|
| 2243 | case SHT_V850_ZCOMMON:
|
|---|
| 2244 | if (! bfd_set_section_flags (abfd, hdr->bfd_section,
|
|---|
| 2245 | (bfd_get_section_flags (abfd,
|
|---|
| 2246 | hdr->bfd_section)
|
|---|
| 2247 | | SEC_IS_COMMON)))
|
|---|
| 2248 | return FALSE;
|
|---|
| 2249 | }
|
|---|
| 2250 |
|
|---|
| 2251 | return TRUE;
|
|---|
| 2252 | }
|
|---|
| 2253 |
|
|---|
| 2254 | /* Set the correct type for a V850 ELF section. We do this
|
|---|
| 2255 | by the section name, which is a hack, but ought to work. */
|
|---|
| 2256 |
|
|---|
| 2257 | static bfd_boolean
|
|---|
| 2258 | v850_elf_fake_sections (abfd, hdr, sec)
|
|---|
| 2259 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 2260 | Elf_Internal_Shdr *hdr;
|
|---|
| 2261 | asection *sec;
|
|---|
| 2262 | {
|
|---|
| 2263 | register const char * name;
|
|---|
| 2264 |
|
|---|
| 2265 | name = bfd_get_section_name (abfd, sec);
|
|---|
| 2266 |
|
|---|
| 2267 | if (strcmp (name, ".scommon") == 0)
|
|---|
| 2268 | {
|
|---|
| 2269 | hdr->sh_type = SHT_V850_SCOMMON;
|
|---|
| 2270 | }
|
|---|
| 2271 | else if (strcmp (name, ".tcommon") == 0)
|
|---|
| 2272 | {
|
|---|
| 2273 | hdr->sh_type = SHT_V850_TCOMMON;
|
|---|
| 2274 | }
|
|---|
| 2275 | else if (strcmp (name, ".zcommon") == 0)
|
|---|
| 2276 | hdr->sh_type = SHT_V850_ZCOMMON;
|
|---|
| 2277 |
|
|---|
| 2278 | return TRUE;
|
|---|
| 2279 | }
|
|---|
| 2280 |
|
|---|
| 2281 | /* Delete some bytes from a section while relaxing. */
|
|---|
| 2282 |
|
|---|
| 2283 | static bfd_boolean
|
|---|
| 2284 | v850_elf_relax_delete_bytes (abfd, sec, addr, toaddr, count)
|
|---|
| 2285 | bfd *abfd;
|
|---|
| 2286 | asection *sec;
|
|---|
| 2287 | bfd_vma addr;
|
|---|
| 2288 | bfd_vma toaddr;
|
|---|
| 2289 | int count;
|
|---|
| 2290 | {
|
|---|
| 2291 | Elf_Internal_Shdr *symtab_hdr;
|
|---|
| 2292 | Elf32_External_Sym *extsyms;
|
|---|
| 2293 | Elf32_External_Sym *esym;
|
|---|
| 2294 | Elf32_External_Sym *esymend;
|
|---|
| 2295 | int index;
|
|---|
| 2296 | unsigned int sec_shndx;
|
|---|
| 2297 | bfd_byte *contents;
|
|---|
| 2298 | Elf_Internal_Rela *irel;
|
|---|
| 2299 | Elf_Internal_Rela *irelend;
|
|---|
| 2300 | struct elf_link_hash_entry *sym_hash;
|
|---|
| 2301 | Elf_Internal_Shdr *shndx_hdr;
|
|---|
| 2302 | Elf_External_Sym_Shndx *shndx;
|
|---|
| 2303 |
|
|---|
| 2304 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
|
|---|
| 2305 | extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
|
|---|
| 2306 |
|
|---|
| 2307 | sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
|
|---|
| 2308 |
|
|---|
| 2309 | contents = elf_section_data (sec)->this_hdr.contents;
|
|---|
| 2310 |
|
|---|
| 2311 | /* The deletion must stop at the next ALIGN reloc for an alignment
|
|---|
| 2312 | power larger than the number of bytes we are deleting. */
|
|---|
| 2313 |
|
|---|
| 2314 | /* Actually delete the bytes. */
|
|---|
| 2315 | #if (DEBUG_RELAX & 2)
|
|---|
| 2316 | fprintf (stderr, "relax_delete: contents: sec: %s %p .. %p %x\n",
|
|---|
| 2317 | sec->name, addr, toaddr, count );
|
|---|
| 2318 | #endif
|
|---|
| 2319 | memmove (contents + addr, contents + addr + count,
|
|---|
| 2320 | toaddr - addr - count);
|
|---|
| 2321 | memset (contents + toaddr-count, 0, count);
|
|---|
| 2322 |
|
|---|
| 2323 | /* Adjust all the relocs. */
|
|---|
| 2324 | irel = elf_section_data (sec)->relocs;
|
|---|
| 2325 | irelend = irel + sec->reloc_count;
|
|---|
| 2326 | shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
|
|---|
| 2327 | shndx = (Elf_External_Sym_Shndx *) shndx_hdr->contents;
|
|---|
| 2328 |
|
|---|
| 2329 | for (; irel < irelend; irel++)
|
|---|
| 2330 | {
|
|---|
| 2331 | bfd_vma raddr, paddr, symval;
|
|---|
| 2332 | Elf_Internal_Sym isym;
|
|---|
| 2333 |
|
|---|
| 2334 | /* Get the new reloc address. */
|
|---|
| 2335 | raddr = irel->r_offset;
|
|---|
| 2336 | if ((raddr >= (addr + count) && raddr < toaddr))
|
|---|
| 2337 | irel->r_offset -= count;
|
|---|
| 2338 |
|
|---|
| 2339 | if (raddr >= addr && raddr < addr + count)
|
|---|
| 2340 | {
|
|---|
| 2341 | irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
|
|---|
| 2342 | (int) R_V850_NONE);
|
|---|
| 2343 | continue;
|
|---|
| 2344 | }
|
|---|
| 2345 |
|
|---|
| 2346 | if (ELF32_R_TYPE (irel->r_info) == (int) R_V850_ALIGN)
|
|---|
| 2347 | continue;
|
|---|
| 2348 |
|
|---|
| 2349 | bfd_elf32_swap_symbol_in (abfd,
|
|---|
| 2350 | extsyms + ELF32_R_SYM (irel->r_info),
|
|---|
| 2351 | shndx ? shndx + ELF32_R_SYM (irel->r_info) : NULL,
|
|---|
| 2352 | & isym);
|
|---|
| 2353 |
|
|---|
| 2354 | if (isym.st_shndx != sec_shndx)
|
|---|
| 2355 | continue;
|
|---|
| 2356 |
|
|---|
| 2357 | /* Get the value of the symbol referred to by the reloc. */
|
|---|
| 2358 | if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
|
|---|
| 2359 | {
|
|---|
| 2360 | symval = isym.st_value;
|
|---|
| 2361 | #if (DEBUG_RELAX & 2)
|
|---|
| 2362 | {
|
|---|
| 2363 | char * name = bfd_elf_string_from_elf_section
|
|---|
| 2364 | (abfd, symtab_hdr->sh_link, isym.st_name);
|
|---|
| 2365 | fprintf (stderr,
|
|---|
| 2366 | "relax_delete: local: sec: %s, sym: %s (%d), value: %x + %x + %x addend %x\n",
|
|---|
| 2367 | sec->name, name, isym.st_name,
|
|---|
| 2368 | sec->output_section->vma, sec->output_offset,
|
|---|
| 2369 | isym.st_value, irel->r_addend);
|
|---|
| 2370 | }
|
|---|
| 2371 | #endif
|
|---|
| 2372 | }
|
|---|
| 2373 | else
|
|---|
| 2374 | {
|
|---|
| 2375 | unsigned long indx;
|
|---|
| 2376 | struct elf_link_hash_entry * h;
|
|---|
| 2377 |
|
|---|
| 2378 | /* An external symbol. */
|
|---|
| 2379 | indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info;
|
|---|
| 2380 |
|
|---|
| 2381 | h = elf_sym_hashes (abfd) [indx];
|
|---|
| 2382 | BFD_ASSERT (h != NULL);
|
|---|
| 2383 |
|
|---|
| 2384 | symval = h->root.u.def.value;
|
|---|
| 2385 | #if (DEBUG_RELAX & 2)
|
|---|
| 2386 | fprintf (stderr,
|
|---|
| 2387 | "relax_delete: defined: sec: %s, name: %s, value: %x + %x + %x addend %x\n",
|
|---|
| 2388 | sec->name, h->root.root.string, h->root.u.def.value,
|
|---|
| 2389 | sec->output_section->vma, sec->output_offset, irel->r_addend);
|
|---|
| 2390 | #endif
|
|---|
| 2391 | }
|
|---|
| 2392 |
|
|---|
| 2393 | paddr = symval + irel->r_addend;
|
|---|
| 2394 |
|
|---|
| 2395 | if ( (symval >= addr + count && symval < toaddr)
|
|---|
| 2396 | && (paddr < addr + count || paddr >= toaddr))
|
|---|
| 2397 | irel->r_addend += count;
|
|---|
| 2398 | else if ( (symval < addr + count || symval >= toaddr)
|
|---|
| 2399 | && (paddr >= addr + count && paddr < toaddr))
|
|---|
| 2400 | irel->r_addend -= count;
|
|---|
| 2401 | }
|
|---|
| 2402 |
|
|---|
| 2403 | /* Adjust the local symbols defined in this section. */
|
|---|
| 2404 | esym = extsyms;
|
|---|
| 2405 | esymend = esym + symtab_hdr->sh_info;
|
|---|
| 2406 |
|
|---|
| 2407 | for (; esym < esymend; esym++, shndx = (shndx ? shndx + 1 : NULL))
|
|---|
| 2408 | {
|
|---|
| 2409 | Elf_Internal_Sym isym;
|
|---|
| 2410 |
|
|---|
| 2411 | bfd_elf32_swap_symbol_in (abfd, esym, shndx, & isym);
|
|---|
| 2412 |
|
|---|
| 2413 | if (isym.st_shndx == sec_shndx
|
|---|
| 2414 | && isym.st_value >= addr + count
|
|---|
| 2415 | && isym.st_value < toaddr)
|
|---|
| 2416 | {
|
|---|
| 2417 | isym.st_value -= count;
|
|---|
| 2418 |
|
|---|
| 2419 | if (isym.st_value + isym.st_size >= toaddr)
|
|---|
| 2420 | isym.st_size += count;
|
|---|
| 2421 |
|
|---|
| 2422 | bfd_elf32_swap_symbol_out (abfd, & isym, esym, shndx);
|
|---|
| 2423 | }
|
|---|
| 2424 | else if (isym.st_shndx == sec_shndx
|
|---|
| 2425 | && isym.st_value < addr + count)
|
|---|
| 2426 | {
|
|---|
| 2427 | if (isym.st_value+isym.st_size >= addr + count
|
|---|
| 2428 | && isym.st_value+isym.st_size < toaddr)
|
|---|
| 2429 | isym.st_size -= count;
|
|---|
| 2430 |
|
|---|
| 2431 | if (isym.st_value >= addr
|
|---|
| 2432 | && isym.st_value < addr + count)
|
|---|
| 2433 | isym.st_value = addr;
|
|---|
| 2434 |
|
|---|
| 2435 | bfd_elf32_swap_symbol_out (abfd, & isym, esym, shndx);
|
|---|
| 2436 | }
|
|---|
| 2437 | }
|
|---|
| 2438 |
|
|---|
| 2439 | /* Now adjust the global symbols defined in this section. */
|
|---|
| 2440 | esym = extsyms + symtab_hdr->sh_info;
|
|---|
| 2441 | esymend = extsyms + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym));
|
|---|
| 2442 |
|
|---|
| 2443 | for (index = 0; esym < esymend; esym ++, index ++)
|
|---|
| 2444 | {
|
|---|
| 2445 | Elf_Internal_Sym isym;
|
|---|
| 2446 |
|
|---|
| 2447 | bfd_elf32_swap_symbol_in (abfd, esym, shndx, & isym);
|
|---|
| 2448 | sym_hash = elf_sym_hashes (abfd) [index];
|
|---|
| 2449 |
|
|---|
| 2450 | if (isym.st_shndx == sec_shndx
|
|---|
| 2451 | && ((sym_hash)->root.type == bfd_link_hash_defined
|
|---|
| 2452 | || (sym_hash)->root.type == bfd_link_hash_defweak)
|
|---|
| 2453 | && (sym_hash)->root.u.def.section == sec
|
|---|
| 2454 | && (sym_hash)->root.u.def.value >= addr + count
|
|---|
| 2455 | && (sym_hash)->root.u.def.value < toaddr)
|
|---|
| 2456 | {
|
|---|
| 2457 | if ((sym_hash)->root.u.def.value + isym.st_size >= toaddr)
|
|---|
| 2458 | {
|
|---|
| 2459 | isym.st_size += count;
|
|---|
| 2460 | bfd_elf32_swap_symbol_out (abfd, & isym, esym, shndx);
|
|---|
| 2461 | }
|
|---|
| 2462 |
|
|---|
| 2463 | (sym_hash)->root.u.def.value -= count;
|
|---|
| 2464 | }
|
|---|
| 2465 | else if (isym.st_shndx == sec_shndx
|
|---|
| 2466 | && ((sym_hash)->root.type == bfd_link_hash_defined
|
|---|
| 2467 | || (sym_hash)->root.type == bfd_link_hash_defweak)
|
|---|
| 2468 | && (sym_hash)->root.u.def.section == sec
|
|---|
| 2469 | && (sym_hash)->root.u.def.value < addr + count)
|
|---|
| 2470 | {
|
|---|
| 2471 | if ((sym_hash)->root.u.def.value+isym.st_size >= addr + count
|
|---|
| 2472 | && (sym_hash)->root.u.def.value+isym.st_size < toaddr)
|
|---|
| 2473 | isym.st_size -= count;
|
|---|
| 2474 |
|
|---|
| 2475 | if ((sym_hash)->root.u.def.value >= addr
|
|---|
| 2476 | && (sym_hash)->root.u.def.value < addr + count)
|
|---|
| 2477 | (sym_hash)->root.u.def.value = addr;
|
|---|
| 2478 |
|
|---|
| 2479 | bfd_elf32_swap_symbol_out (abfd, & isym, esym, shndx);
|
|---|
| 2480 | }
|
|---|
| 2481 |
|
|---|
| 2482 | if (shndx)
|
|---|
| 2483 | ++ shndx;
|
|---|
| 2484 | }
|
|---|
| 2485 |
|
|---|
| 2486 | return TRUE;
|
|---|
| 2487 | }
|
|---|
| 2488 |
|
|---|
| 2489 | #define NOP_OPCODE (0x0000)
|
|---|
| 2490 | #define MOVHI 0x0640 /* 4byte */
|
|---|
| 2491 | #define MOVHI_MASK 0x07e0
|
|---|
| 2492 | #define MOVHI_R1(insn) ((insn) & 0x1f) /* 4byte */
|
|---|
| 2493 | #define MOVHI_R2(insn) ((insn) >> 11)
|
|---|
| 2494 | #define MOVEA 0x0620 /* 2byte */
|
|---|
| 2495 | #define MOVEA_MASK 0x07e0
|
|---|
| 2496 | #define MOVEA_R1(insn) ((insn) & 0x1f)
|
|---|
| 2497 | #define MOVEA_R2(insn) ((insn) >> 11)
|
|---|
| 2498 | #define JARL_4 0x00040780 /* 4byte */
|
|---|
| 2499 | #define JARL_4_MASK 0xFFFF07FF
|
|---|
| 2500 | #define JARL_R2(insn) (int)(((insn) & (~JARL_4_MASK)) >> 11)
|
|---|
| 2501 | #define ADD_I 0x0240 /* 2byte */
|
|---|
| 2502 | #define ADD_I_MASK 0x07e0
|
|---|
| 2503 | #define ADD_I5(insn) ((((insn) & 0x001f) << 11) >> 11) /* 2byte */
|
|---|
| 2504 | #define ADD_R2(insn) ((insn) >> 11)
|
|---|
| 2505 | #define JMP_R 0x0060 /* 2byte */
|
|---|
| 2506 | #define JMP_R_MASK 0xFFE0
|
|---|
| 2507 | #define JMP_R1(insn) ((insn) & 0x1f)
|
|---|
| 2508 |
|
|---|
| 2509 | static bfd_boolean
|
|---|
| 2510 | v850_elf_relax_section (abfd, sec, link_info, again)
|
|---|
| 2511 | bfd *abfd;
|
|---|
| 2512 | asection *sec;
|
|---|
| 2513 | struct bfd_link_info *link_info;
|
|---|
| 2514 | bfd_boolean *again;
|
|---|
| 2515 | {
|
|---|
| 2516 | Elf_Internal_Shdr *symtab_hdr;
|
|---|
| 2517 | Elf_Internal_Rela *internal_relocs;
|
|---|
| 2518 | Elf_Internal_Rela *irel;
|
|---|
| 2519 | Elf_Internal_Rela *irelend;
|
|---|
| 2520 | Elf_Internal_Rela *irelalign = NULL;
|
|---|
| 2521 | Elf_Internal_Sym *isymbuf = NULL;
|
|---|
| 2522 | bfd_byte *contents = NULL;
|
|---|
| 2523 | bfd_vma addr = 0;
|
|---|
| 2524 | bfd_vma toaddr;
|
|---|
| 2525 | int align_pad_size = 0;
|
|---|
| 2526 | bfd_boolean result = TRUE;
|
|---|
| 2527 |
|
|---|
| 2528 | *again = FALSE;
|
|---|
| 2529 |
|
|---|
| 2530 | if (link_info->relocateable
|
|---|
| 2531 | || (sec->flags & SEC_RELOC) == 0
|
|---|
| 2532 | || sec->reloc_count == 0)
|
|---|
| 2533 | return TRUE;
|
|---|
| 2534 |
|
|---|
| 2535 | /* If this is the first time we have been called
|
|---|
| 2536 | for this section, initialize the cooked size. */
|
|---|
| 2537 | if (sec->_cooked_size == 0)
|
|---|
| 2538 | sec->_cooked_size = sec->_raw_size;
|
|---|
| 2539 |
|
|---|
| 2540 | symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
|
|---|
| 2541 |
|
|---|
| 2542 | internal_relocs = (_bfd_elf32_link_read_relocs
|
|---|
| 2543 | (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
|
|---|
| 2544 | link_info->keep_memory));
|
|---|
| 2545 | if (internal_relocs == NULL)
|
|---|
| 2546 | goto error_return;
|
|---|
| 2547 |
|
|---|
| 2548 | irelend = internal_relocs + sec->reloc_count;
|
|---|
| 2549 |
|
|---|
| 2550 | while (addr < sec->_cooked_size)
|
|---|
| 2551 | {
|
|---|
| 2552 | toaddr = sec->_cooked_size;
|
|---|
| 2553 |
|
|---|
| 2554 | for (irel = internal_relocs; irel < irelend; irel ++)
|
|---|
| 2555 | if (ELF32_R_TYPE (irel->r_info) == (int) R_V850_ALIGN
|
|---|
| 2556 | && irel->r_offset > addr
|
|---|
| 2557 | && irel->r_offset < toaddr)
|
|---|
| 2558 | toaddr = irel->r_offset;
|
|---|
| 2559 |
|
|---|
| 2560 | #ifdef DEBUG_RELAX
|
|---|
| 2561 | fprintf (stderr, "relax region 0x%x to 0x%x align pad %d\n",
|
|---|
| 2562 | addr, toaddr, align_pad_size);
|
|---|
| 2563 | #endif
|
|---|
| 2564 | if (irelalign)
|
|---|
| 2565 | {
|
|---|
| 2566 | bfd_vma alignto;
|
|---|
| 2567 | bfd_vma alignmoveto;
|
|---|
| 2568 |
|
|---|
| 2569 | alignmoveto = BFD_ALIGN (addr - align_pad_size, 1 << irelalign->r_addend);
|
|---|
| 2570 | alignto = BFD_ALIGN (addr, 1 << irelalign->r_addend);
|
|---|
| 2571 |
|
|---|
| 2572 | if (alignmoveto < alignto)
|
|---|
| 2573 | {
|
|---|
| 2574 | unsigned int i;
|
|---|
| 2575 |
|
|---|
| 2576 | align_pad_size = alignto - alignmoveto;
|
|---|
| 2577 | #ifdef DEBUG_RELAX
|
|---|
| 2578 | fprintf (stderr, "relax move region 0x%x to 0x%x delete size 0x%x\n",
|
|---|
| 2579 | alignmoveto, toaddr, align_pad_size);
|
|---|
| 2580 | #endif
|
|---|
| 2581 | if (!v850_elf_relax_delete_bytes (abfd, sec, alignmoveto,
|
|---|
| 2582 | toaddr, align_pad_size))
|
|---|
| 2583 | goto error_return;
|
|---|
| 2584 |
|
|---|
| 2585 | for (i = BFD_ALIGN (toaddr - align_pad_size, 1);
|
|---|
| 2586 | (i + 1) < toaddr; i += 2)
|
|---|
| 2587 | bfd_put_16 (abfd, NOP_OPCODE, contents + i);
|
|---|
| 2588 |
|
|---|
| 2589 | addr = alignmoveto;
|
|---|
| 2590 | }
|
|---|
| 2591 | else
|
|---|
| 2592 | align_pad_size = 0;
|
|---|
| 2593 | }
|
|---|
| 2594 |
|
|---|
| 2595 | for (irel = internal_relocs; irel < irelend; irel++)
|
|---|
| 2596 | {
|
|---|
| 2597 | bfd_vma laddr;
|
|---|
| 2598 | bfd_vma addend;
|
|---|
| 2599 | bfd_vma symval;
|
|---|
| 2600 | int insn[5];
|
|---|
| 2601 | int no_match = -1;
|
|---|
| 2602 | Elf_Internal_Rela *hi_irelfn;
|
|---|
| 2603 | Elf_Internal_Rela *lo_irelfn;
|
|---|
| 2604 | Elf_Internal_Rela *irelcall;
|
|---|
| 2605 | bfd_signed_vma foff;
|
|---|
| 2606 |
|
|---|
| 2607 | if (! (irel->r_offset >= addr && irel->r_offset < toaddr
|
|---|
| 2608 | && (ELF32_R_TYPE (irel->r_info) == (int) R_V850_LONGCALL
|
|---|
| 2609 | || ELF32_R_TYPE (irel->r_info) == (int) R_V850_LONGJUMP)))
|
|---|
| 2610 | continue;
|
|---|
| 2611 |
|
|---|
| 2612 | #ifdef DEBUG_RELAX
|
|---|
| 2613 | fprintf (stderr, "relax check r_info 0x%x r_offset 0x%x r_addend 0x%x\n",
|
|---|
| 2614 | irel->r_info,
|
|---|
| 2615 | irel->r_offset,
|
|---|
| 2616 | irel->r_addend );
|
|---|
| 2617 | #endif
|
|---|
| 2618 |
|
|---|
| 2619 | /* Get the section contents. */
|
|---|
| 2620 | if (contents == NULL)
|
|---|
| 2621 | {
|
|---|
| 2622 | if (elf_section_data (sec)->this_hdr.contents != NULL)
|
|---|
| 2623 | contents = elf_section_data (sec)->this_hdr.contents;
|
|---|
| 2624 | else
|
|---|
| 2625 | {
|
|---|
| 2626 | contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
|
|---|
| 2627 | if (contents == NULL)
|
|---|
| 2628 | goto error_return;
|
|---|
| 2629 |
|
|---|
| 2630 | if (! bfd_get_section_contents (abfd, sec, contents,
|
|---|
| 2631 | (file_ptr) 0, sec->_raw_size))
|
|---|
| 2632 | goto error_return;
|
|---|
| 2633 | }
|
|---|
| 2634 | }
|
|---|
| 2635 |
|
|---|
| 2636 | /* Read this BFD's local symbols if we haven't done so already. */
|
|---|
| 2637 | if (isymbuf == NULL && symtab_hdr->sh_info != 0)
|
|---|
| 2638 | {
|
|---|
| 2639 | isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
|
|---|
| 2640 | if (isymbuf == NULL)
|
|---|
| 2641 | isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
|
|---|
| 2642 | symtab_hdr->sh_info, 0,
|
|---|
| 2643 | NULL, NULL, NULL);
|
|---|
| 2644 | if (isymbuf == NULL)
|
|---|
| 2645 | goto error_return;
|
|---|
| 2646 | }
|
|---|
| 2647 |
|
|---|
| 2648 | laddr = irel->r_offset;
|
|---|
| 2649 |
|
|---|
| 2650 | if (ELF32_R_TYPE (irel->r_info) == (int) R_V850_LONGCALL)
|
|---|
| 2651 | {
|
|---|
| 2652 | /* Check code for -mlong-calls output. */
|
|---|
| 2653 | if (laddr + 16 <= (bfd_vma) sec->_raw_size)
|
|---|
| 2654 | {
|
|---|
| 2655 | insn[0] = bfd_get_16 (abfd, contents + laddr);
|
|---|
| 2656 | insn[1] = bfd_get_16 (abfd, contents + laddr + 4);
|
|---|
| 2657 | insn[2] = bfd_get_32 (abfd, contents + laddr + 8);
|
|---|
| 2658 | insn[3] = bfd_get_16 (abfd, contents + laddr + 12);
|
|---|
| 2659 | insn[4] = bfd_get_16 (abfd, contents + laddr + 14);
|
|---|
| 2660 |
|
|---|
| 2661 | if ((insn[0] & MOVHI_MASK) != MOVHI
|
|---|
| 2662 | || MOVHI_R1 (insn[0]) != 0)
|
|---|
| 2663 | no_match = 0;
|
|---|
| 2664 |
|
|---|
| 2665 | if (no_match < 0
|
|---|
| 2666 | && ((insn[1] & MOVEA_MASK) != MOVEA
|
|---|
| 2667 | || MOVHI_R2 (insn[0]) != MOVEA_R1 (insn[1])))
|
|---|
| 2668 | no_match = 1;
|
|---|
| 2669 |
|
|---|
| 2670 | if (no_match < 0
|
|---|
| 2671 | && (insn[2] & JARL_4_MASK) != JARL_4)
|
|---|
| 2672 | no_match = 2;
|
|---|
| 2673 |
|
|---|
| 2674 | if (no_match < 0
|
|---|
| 2675 | && ((insn[3] & ADD_I_MASK) != ADD_I
|
|---|
| 2676 | || ADD_I5 (insn[3]) != 4
|
|---|
| 2677 | || JARL_R2 (insn[2]) != ADD_R2 (insn[3])))
|
|---|
| 2678 | no_match = 3;
|
|---|
| 2679 |
|
|---|
| 2680 | if (no_match < 0
|
|---|
| 2681 | && ((insn[4] & JMP_R_MASK) != JMP_R
|
|---|
| 2682 | || MOVEA_R2 (insn[1]) != JMP_R1 (insn[4])))
|
|---|
| 2683 | no_match = 4;
|
|---|
| 2684 | }
|
|---|
| 2685 | else
|
|---|
| 2686 | {
|
|---|
| 2687 | ((*_bfd_error_handler)
|
|---|
| 2688 | ("%s: 0x%lx: warning: R_V850_LONGCALL points to unrecognized insns",
|
|---|
| 2689 | bfd_get_filename (abfd), (unsigned long) irel->r_offset));
|
|---|
| 2690 |
|
|---|
| 2691 | continue;
|
|---|
| 2692 | }
|
|---|
| 2693 |
|
|---|
| 2694 | if (no_match >= 0)
|
|---|
| 2695 | {
|
|---|
| 2696 | ((*_bfd_error_handler)
|
|---|
| 2697 | ("%s: 0x%lx: warning: R_V850_LONGCALL points to unrecognized insn 0x%x",
|
|---|
| 2698 | bfd_get_filename (abfd), (unsigned long) irel->r_offset+no_match, insn[no_match]));
|
|---|
| 2699 |
|
|---|
| 2700 | continue;
|
|---|
| 2701 | }
|
|---|
| 2702 |
|
|---|
| 2703 | /* Get the reloc for the address from which the register is
|
|---|
| 2704 | being loaded. This reloc will tell us which function is
|
|---|
| 2705 | actually being called. */
|
|---|
| 2706 | for (hi_irelfn = internal_relocs; hi_irelfn < irelend; hi_irelfn ++)
|
|---|
| 2707 | if (hi_irelfn->r_offset == laddr + 2
|
|---|
| 2708 | && ELF32_R_TYPE (hi_irelfn->r_info)
|
|---|
| 2709 | == (int) R_V850_HI16_S)
|
|---|
| 2710 | break;
|
|---|
| 2711 |
|
|---|
| 2712 | for (lo_irelfn = internal_relocs; lo_irelfn < irelend; lo_irelfn ++)
|
|---|
| 2713 | if (lo_irelfn->r_offset == laddr + 6
|
|---|
| 2714 | && ELF32_R_TYPE (lo_irelfn->r_info)
|
|---|
| 2715 | == (int) R_V850_LO16)
|
|---|
| 2716 | break;
|
|---|
| 2717 |
|
|---|
| 2718 | for (irelcall = internal_relocs; irelcall < irelend; irelcall ++)
|
|---|
| 2719 | if (irelcall->r_offset == laddr + 8
|
|---|
| 2720 | && ELF32_R_TYPE (irelcall->r_info)
|
|---|
| 2721 | == (int) R_V850_22_PCREL)
|
|---|
| 2722 | break;
|
|---|
| 2723 |
|
|---|
| 2724 | if ( hi_irelfn == irelend
|
|---|
| 2725 | || lo_irelfn == irelend
|
|---|
| 2726 | || irelcall == irelend)
|
|---|
| 2727 | {
|
|---|
| 2728 | ((*_bfd_error_handler)
|
|---|
| 2729 | ("%s: 0x%lx: warning: R_V850_LONGCALL points to unrecognized reloc",
|
|---|
| 2730 | bfd_get_filename (abfd), (unsigned long) irel->r_offset ));
|
|---|
| 2731 |
|
|---|
| 2732 | continue;
|
|---|
| 2733 | }
|
|---|
| 2734 |
|
|---|
| 2735 | if (ELF32_R_SYM (irelcall->r_info) < symtab_hdr->sh_info)
|
|---|
| 2736 | {
|
|---|
| 2737 | Elf_Internal_Sym * isym;
|
|---|
| 2738 |
|
|---|
| 2739 | /* A local symbol. */
|
|---|
| 2740 | isym = isymbuf + ELF32_R_SYM (irelcall->r_info);
|
|---|
| 2741 |
|
|---|
| 2742 | symval = isym->st_value;
|
|---|
| 2743 | }
|
|---|
| 2744 | else
|
|---|
| 2745 | {
|
|---|
| 2746 | unsigned long indx;
|
|---|
| 2747 | struct elf_link_hash_entry * h;
|
|---|
| 2748 |
|
|---|
| 2749 | /* An external symbol. */
|
|---|
| 2750 | indx = ELF32_R_SYM (irelcall->r_info) - symtab_hdr->sh_info;
|
|---|
| 2751 | h = elf_sym_hashes (abfd)[indx];
|
|---|
| 2752 | BFD_ASSERT (h != NULL);
|
|---|
| 2753 |
|
|---|
| 2754 | if ( h->root.type != bfd_link_hash_defined
|
|---|
| 2755 | && h->root.type != bfd_link_hash_defweak)
|
|---|
| 2756 | /* This appears to be a reference to an undefined
|
|---|
| 2757 | symbol. Just ignore it--it will be caught by the
|
|---|
| 2758 | regular reloc processing. */
|
|---|
| 2759 | continue;
|
|---|
| 2760 |
|
|---|
| 2761 | symval = h->root.u.def.value;
|
|---|
| 2762 | }
|
|---|
| 2763 |
|
|---|
| 2764 | if (symval + irelcall->r_addend != irelcall->r_offset + 4)
|
|---|
| 2765 | {
|
|---|
| 2766 | ((*_bfd_error_handler)
|
|---|
| 2767 | ("%s: 0x%lx: warning: R_V850_LONGCALL points to unrecognized reloc 0x%lx",
|
|---|
| 2768 | bfd_get_filename (abfd), (unsigned long) irel->r_offset, irelcall->r_offset ));
|
|---|
| 2769 |
|
|---|
| 2770 | continue;
|
|---|
| 2771 | }
|
|---|
| 2772 |
|
|---|
| 2773 | /* Get the value of the symbol referred to by the reloc. */
|
|---|
| 2774 | if (ELF32_R_SYM (hi_irelfn->r_info) < symtab_hdr->sh_info)
|
|---|
| 2775 | {
|
|---|
| 2776 | Elf_Internal_Sym *isym;
|
|---|
| 2777 | asection *sym_sec;
|
|---|
| 2778 |
|
|---|
| 2779 | /* A local symbol. */
|
|---|
| 2780 | isym = isymbuf + ELF32_R_SYM (hi_irelfn->r_info);
|
|---|
| 2781 |
|
|---|
| 2782 | if (isym->st_shndx == SHN_UNDEF)
|
|---|
| 2783 | sym_sec = bfd_und_section_ptr;
|
|---|
| 2784 | else if (isym->st_shndx == SHN_ABS)
|
|---|
| 2785 | sym_sec = bfd_abs_section_ptr;
|
|---|
| 2786 | else if (isym->st_shndx == SHN_COMMON)
|
|---|
| 2787 | sym_sec = bfd_com_section_ptr;
|
|---|
| 2788 | else
|
|---|
| 2789 | sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
|
|---|
| 2790 | symval = (isym->st_value
|
|---|
| 2791 | + sym_sec->output_section->vma
|
|---|
| 2792 | + sym_sec->output_offset);
|
|---|
| 2793 | }
|
|---|
| 2794 | else
|
|---|
| 2795 | {
|
|---|
| 2796 | unsigned long indx;
|
|---|
| 2797 | struct elf_link_hash_entry *h;
|
|---|
| 2798 |
|
|---|
| 2799 | /* An external symbol. */
|
|---|
| 2800 | indx = ELF32_R_SYM (hi_irelfn->r_info) - symtab_hdr->sh_info;
|
|---|
| 2801 | h = elf_sym_hashes (abfd)[indx];
|
|---|
| 2802 | BFD_ASSERT (h != NULL);
|
|---|
| 2803 |
|
|---|
| 2804 | if ( h->root.type != bfd_link_hash_defined
|
|---|
| 2805 | && h->root.type != bfd_link_hash_defweak)
|
|---|
| 2806 | /* This appears to be a reference to an undefined
|
|---|
| 2807 | symbol. Just ignore it--it will be caught by the
|
|---|
| 2808 | regular reloc processing. */
|
|---|
| 2809 | continue;
|
|---|
| 2810 |
|
|---|
| 2811 | symval = (h->root.u.def.value
|
|---|
| 2812 | + h->root.u.def.section->output_section->vma
|
|---|
| 2813 | + h->root.u.def.section->output_offset);
|
|---|
| 2814 | }
|
|---|
| 2815 |
|
|---|
| 2816 | addend = irel->r_addend;
|
|---|
| 2817 |
|
|---|
| 2818 | foff = (symval + addend
|
|---|
| 2819 | - (irel->r_offset
|
|---|
| 2820 | + sec->output_section->vma
|
|---|
| 2821 | + sec->output_offset
|
|---|
| 2822 | + 4));
|
|---|
| 2823 | #ifdef DEBUG_RELAX
|
|---|
| 2824 | fprintf (stderr, "relax longcall r_offset 0x%x ptr 0x%x symbol 0x%x addend 0x%x distance 0x%x\n",
|
|---|
| 2825 | irel->r_offset,
|
|---|
| 2826 | (irel->r_offset
|
|---|
| 2827 | + sec->output_section->vma
|
|---|
| 2828 | + sec->output_offset),
|
|---|
| 2829 | symval, addend, foff);
|
|---|
| 2830 | #endif
|
|---|
| 2831 |
|
|---|
| 2832 | if (foff < -0x100000 || foff >= 0x100000)
|
|---|
| 2833 | /* After all that work, we can't shorten this function call. */
|
|---|
| 2834 | continue;
|
|---|
| 2835 |
|
|---|
| 2836 | /* For simplicity of coding, we are going to modify the section
|
|---|
| 2837 | contents, the section relocs, and the BFD symbol table. We
|
|---|
| 2838 | must tell the rest of the code not to free up this
|
|---|
| 2839 | information. It would be possible to instead create a table
|
|---|
| 2840 | of changes which have to be made, as is done in coff-mips.c;
|
|---|
| 2841 | that would be more work, but would require less memory when
|
|---|
| 2842 | the linker is run. */
|
|---|
| 2843 | elf_section_data (sec)->relocs = internal_relocs;
|
|---|
| 2844 | elf_section_data (sec)->this_hdr.contents = contents;
|
|---|
| 2845 | symtab_hdr->contents = (bfd_byte *) isymbuf;
|
|---|
| 2846 |
|
|---|
| 2847 | /* Replace the long call with a jarl. */
|
|---|
| 2848 | irel->r_info = ELF32_R_INFO (ELF32_R_SYM (hi_irelfn->r_info), R_V850_22_PCREL);
|
|---|
| 2849 |
|
|---|
| 2850 | addend = 0;
|
|---|
| 2851 |
|
|---|
| 2852 | if (ELF32_R_SYM (hi_irelfn->r_info) < symtab_hdr->sh_info)
|
|---|
| 2853 | /* If this needs to be changed because of future relaxing,
|
|---|
| 2854 | it will be handled here like other internal IND12W
|
|---|
| 2855 | relocs. */
|
|---|
| 2856 | bfd_put_32 (abfd,
|
|---|
| 2857 | 0x00000780 | (JARL_R2 (insn[2])<<11) | ((addend << 16) & 0xffff) | ((addend >> 16) & 0xf),
|
|---|
| 2858 | contents + irel->r_offset);
|
|---|
| 2859 | else
|
|---|
| 2860 | /* We can't fully resolve this yet, because the external
|
|---|
| 2861 | symbol value may be changed by future relaxing.
|
|---|
| 2862 | We let the final link phase handle it. */
|
|---|
| 2863 | bfd_put_32 (abfd, 0x00000780 | (JARL_R2 (insn[2])<<11),
|
|---|
| 2864 | contents + irel->r_offset);
|
|---|
| 2865 |
|
|---|
| 2866 | hi_irelfn->r_info =
|
|---|
| 2867 | ELF32_R_INFO (ELF32_R_SYM (hi_irelfn->r_info), R_V850_NONE);
|
|---|
| 2868 | lo_irelfn->r_info =
|
|---|
| 2869 | ELF32_R_INFO (ELF32_R_SYM (lo_irelfn->r_info), R_V850_NONE);
|
|---|
| 2870 | irelcall->r_info =
|
|---|
| 2871 | ELF32_R_INFO (ELF32_R_SYM (irelcall->r_info), R_V850_NONE);
|
|---|
| 2872 |
|
|---|
| 2873 | if (! v850_elf_relax_delete_bytes (abfd, sec,
|
|---|
| 2874 | irel->r_offset + 4, toaddr, 12))
|
|---|
| 2875 | goto error_return;
|
|---|
| 2876 |
|
|---|
| 2877 | align_pad_size += 12;
|
|---|
| 2878 | }
|
|---|
| 2879 | else if (ELF32_R_TYPE (irel->r_info) == (int) R_V850_LONGJUMP)
|
|---|
| 2880 | {
|
|---|
| 2881 | /* Check code for -mlong-jumps output. */
|
|---|
| 2882 | if (laddr + 10 <= (bfd_vma) sec->_raw_size)
|
|---|
| 2883 | {
|
|---|
| 2884 | insn[0] = bfd_get_16 (abfd, contents + laddr);
|
|---|
| 2885 | insn[1] = bfd_get_16 (abfd, contents + laddr + 4);
|
|---|
| 2886 | insn[2] = bfd_get_16 (abfd, contents + laddr + 8);
|
|---|
| 2887 |
|
|---|
| 2888 | if ((insn[0] & MOVHI_MASK) != MOVHI
|
|---|
| 2889 | || MOVHI_R1 (insn[0]) != 0)
|
|---|
| 2890 | no_match = 0;
|
|---|
| 2891 |
|
|---|
| 2892 | if (no_match < 0
|
|---|
| 2893 | && ((insn[1] & MOVEA_MASK) != MOVEA
|
|---|
| 2894 | || MOVHI_R2 (insn[0]) != MOVEA_R1 (insn[1])))
|
|---|
| 2895 | no_match = 1;
|
|---|
| 2896 |
|
|---|
| 2897 | if (no_match < 0
|
|---|
| 2898 | && ((insn[2] & JMP_R_MASK) != JMP_R
|
|---|
| 2899 | || MOVEA_R2 (insn[1]) != JMP_R1 (insn[2])))
|
|---|
| 2900 | no_match = 4;
|
|---|
| 2901 | }
|
|---|
| 2902 | else
|
|---|
| 2903 | {
|
|---|
| 2904 | ((*_bfd_error_handler)
|
|---|
| 2905 | ("%s: 0x%lx: warning: R_V850_LONGJUMP points to unrecognized insns",
|
|---|
| 2906 | bfd_get_filename (abfd), (unsigned long) irel->r_offset));
|
|---|
| 2907 |
|
|---|
| 2908 | continue;
|
|---|
| 2909 | }
|
|---|
| 2910 |
|
|---|
| 2911 | if (no_match >= 0)
|
|---|
| 2912 | {
|
|---|
| 2913 | ((*_bfd_error_handler)
|
|---|
| 2914 | ("%s: 0x%lx: warning: R_V850_LONGJUMP points to unrecognized insn 0x%x",
|
|---|
| 2915 | bfd_get_filename (abfd), (unsigned long) irel->r_offset+no_match, insn[no_match]));
|
|---|
| 2916 |
|
|---|
| 2917 | continue;
|
|---|
| 2918 | }
|
|---|
| 2919 |
|
|---|
| 2920 | /* Get the reloc for the address from which the register is
|
|---|
| 2921 | being loaded. This reloc will tell us which function is
|
|---|
| 2922 | actually being called. */
|
|---|
| 2923 | for (hi_irelfn = internal_relocs; hi_irelfn < irelend; hi_irelfn ++)
|
|---|
| 2924 | if (hi_irelfn->r_offset == laddr + 2
|
|---|
| 2925 | && ELF32_R_TYPE (hi_irelfn->r_info) == (int) R_V850_HI16_S)
|
|---|
| 2926 | break;
|
|---|
| 2927 |
|
|---|
| 2928 | for (lo_irelfn = internal_relocs; lo_irelfn < irelend; lo_irelfn ++)
|
|---|
| 2929 | if (lo_irelfn->r_offset == laddr + 6
|
|---|
| 2930 | && ELF32_R_TYPE (lo_irelfn->r_info) == (int) R_V850_LO16)
|
|---|
| 2931 | break;
|
|---|
| 2932 |
|
|---|
| 2933 | if ( hi_irelfn == irelend
|
|---|
| 2934 | || lo_irelfn == irelend)
|
|---|
| 2935 | {
|
|---|
| 2936 | ((*_bfd_error_handler)
|
|---|
| 2937 | ("%s: 0x%lx: warning: R_V850_LONGJUMP points to unrecognized reloc",
|
|---|
| 2938 | bfd_get_filename (abfd), (unsigned long) irel->r_offset ));
|
|---|
| 2939 |
|
|---|
| 2940 | continue;
|
|---|
| 2941 | }
|
|---|
| 2942 |
|
|---|
| 2943 | /* Get the value of the symbol referred to by the reloc. */
|
|---|
| 2944 | if (ELF32_R_SYM (hi_irelfn->r_info) < symtab_hdr->sh_info)
|
|---|
| 2945 | {
|
|---|
| 2946 | Elf_Internal_Sym * isym;
|
|---|
| 2947 | asection * sym_sec;
|
|---|
| 2948 |
|
|---|
| 2949 | /* A local symbol. */
|
|---|
| 2950 | isym = isymbuf + ELF32_R_SYM (hi_irelfn->r_info);
|
|---|
| 2951 |
|
|---|
| 2952 | if (isym->st_shndx == SHN_UNDEF)
|
|---|
| 2953 | sym_sec = bfd_und_section_ptr;
|
|---|
| 2954 | else if (isym->st_shndx == SHN_ABS)
|
|---|
| 2955 | sym_sec = bfd_abs_section_ptr;
|
|---|
| 2956 | else if (isym->st_shndx == SHN_COMMON)
|
|---|
| 2957 | sym_sec = bfd_com_section_ptr;
|
|---|
| 2958 | else
|
|---|
| 2959 | sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
|
|---|
| 2960 | symval = (isym->st_value
|
|---|
| 2961 | + sym_sec->output_section->vma
|
|---|
| 2962 | + sym_sec->output_offset);
|
|---|
| 2963 | #ifdef DEBUG_RELAX
|
|---|
| 2964 | {
|
|---|
| 2965 | char * name = bfd_elf_string_from_elf_section
|
|---|
| 2966 | (abfd, symtab_hdr->sh_link, isym->st_name);
|
|---|
| 2967 |
|
|---|
| 2968 | fprintf (stderr, "relax long jump local: sec: %s, sym: %s (%d), value: %x + %x + %x addend %x\n",
|
|---|
| 2969 | sym_sec->name, name, isym->st_name,
|
|---|
| 2970 | sym_sec->output_section->vma,
|
|---|
| 2971 | sym_sec->output_offset,
|
|---|
| 2972 | isym->st_value, irel->r_addend);
|
|---|
| 2973 | }
|
|---|
| 2974 | #endif
|
|---|
| 2975 | }
|
|---|
| 2976 | else
|
|---|
| 2977 | {
|
|---|
| 2978 | unsigned long indx;
|
|---|
| 2979 | struct elf_link_hash_entry * h;
|
|---|
| 2980 |
|
|---|
| 2981 | /* An external symbol. */
|
|---|
| 2982 | indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info;
|
|---|
| 2983 | h = elf_sym_hashes (abfd)[indx];
|
|---|
| 2984 | BFD_ASSERT (h != NULL);
|
|---|
| 2985 |
|
|---|
| 2986 | if ( h->root.type != bfd_link_hash_defined
|
|---|
| 2987 | && h->root.type != bfd_link_hash_defweak)
|
|---|
| 2988 | /* This appears to be a reference to an undefined
|
|---|
| 2989 | symbol. Just ignore it--it will be caught by the
|
|---|
| 2990 | regular reloc processing. */
|
|---|
| 2991 | continue;
|
|---|
| 2992 |
|
|---|
| 2993 | symval = (h->root.u.def.value
|
|---|
| 2994 | + h->root.u.def.section->output_section->vma
|
|---|
| 2995 | + h->root.u.def.section->output_offset);
|
|---|
| 2996 | #ifdef DEBUG_RELAX
|
|---|
| 2997 | fprintf (stderr,
|
|---|
| 2998 | "relax longjump defined: sec: %s, name: %s, value: %x + %x + %x addend %x\n",
|
|---|
| 2999 | sec->name, h->root.root.string, h->root.u.def.value,
|
|---|
| 3000 | sec->output_section->vma, sec->output_offset, irel->r_addend);
|
|---|
| 3001 | #endif
|
|---|
| 3002 | }
|
|---|
| 3003 |
|
|---|
| 3004 | addend = irel->r_addend;
|
|---|
| 3005 |
|
|---|
| 3006 | foff = (symval + addend
|
|---|
| 3007 | - (irel->r_offset
|
|---|
| 3008 | + sec->output_section->vma
|
|---|
| 3009 | + sec->output_offset
|
|---|
| 3010 | + 4));
|
|---|
| 3011 | #ifdef DEBUG_RELAX
|
|---|
| 3012 | fprintf (stderr, "relax longjump r_offset 0x%x ptr 0x%x symbol 0x%x addend 0x%x distance 0x%x\n",
|
|---|
| 3013 | irel->r_offset,
|
|---|
| 3014 | (irel->r_offset
|
|---|
| 3015 | + sec->output_section->vma
|
|---|
| 3016 | + sec->output_offset),
|
|---|
| 3017 | symval, addend, foff);
|
|---|
| 3018 | #endif
|
|---|
| 3019 | if (foff < -0x100000 || foff >= 0x100000)
|
|---|
| 3020 | /* After all that work, we can't shorten this function call. */
|
|---|
| 3021 | continue;
|
|---|
| 3022 |
|
|---|
| 3023 | /* For simplicity of coding, we are going to modify the section
|
|---|
| 3024 | contents, the section relocs, and the BFD symbol table. We
|
|---|
| 3025 | must tell the rest of the code not to free up this
|
|---|
| 3026 | information. It would be possible to instead create a table
|
|---|
| 3027 | of changes which have to be made, as is done in coff-mips.c;
|
|---|
| 3028 | that would be more work, but would require less memory when
|
|---|
| 3029 | the linker is run. */
|
|---|
| 3030 | elf_section_data (sec)->relocs = internal_relocs;
|
|---|
| 3031 | elf_section_data (sec)->this_hdr.contents = contents;
|
|---|
| 3032 | symtab_hdr->contents = (bfd_byte *) isymbuf;
|
|---|
| 3033 |
|
|---|
| 3034 | if (foff < -0x100 || foff >= 0x100)
|
|---|
| 3035 | {
|
|---|
| 3036 | /* Replace the long jump with a jr. */
|
|---|
| 3037 |
|
|---|
| 3038 | irel->r_info =
|
|---|
| 3039 | ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_V850_22_PCREL);
|
|---|
| 3040 |
|
|---|
| 3041 | irel->r_addend = addend;
|
|---|
| 3042 | addend = 0;
|
|---|
| 3043 |
|
|---|
| 3044 | if (ELF32_R_SYM (hi_irelfn->r_info) < symtab_hdr->sh_info)
|
|---|
| 3045 | /* If this needs to be changed because of future relaxing,
|
|---|
| 3046 | it will be handled here like other internal IND12W
|
|---|
| 3047 | relocs. */
|
|---|
| 3048 | bfd_put_32 (abfd,
|
|---|
| 3049 | 0x00000780 | ((addend << 15) & 0xffff0000) | ((addend >> 17) & 0xf),
|
|---|
| 3050 | contents + irel->r_offset);
|
|---|
| 3051 | else
|
|---|
| 3052 | /* We can't fully resolve this yet, because the external
|
|---|
| 3053 | symbol value may be changed by future relaxing.
|
|---|
| 3054 | We let the final link phase handle it. */
|
|---|
| 3055 | bfd_put_32 (abfd, 0x00000780, contents + irel->r_offset);
|
|---|
| 3056 |
|
|---|
| 3057 | hi_irelfn->r_info =
|
|---|
| 3058 | ELF32_R_INFO (ELF32_R_SYM (hi_irelfn->r_info), R_V850_NONE);
|
|---|
| 3059 | lo_irelfn->r_info =
|
|---|
| 3060 | ELF32_R_INFO (ELF32_R_SYM (lo_irelfn->r_info), R_V850_NONE);
|
|---|
| 3061 | if (!v850_elf_relax_delete_bytes (abfd, sec,
|
|---|
| 3062 | irel->r_offset + 4, toaddr, 6))
|
|---|
| 3063 | goto error_return;
|
|---|
| 3064 |
|
|---|
| 3065 | align_pad_size += 6;
|
|---|
| 3066 | }
|
|---|
| 3067 | else
|
|---|
| 3068 | {
|
|---|
| 3069 | /* Replace the long jump with a br. */
|
|---|
| 3070 |
|
|---|
| 3071 | irel->r_info =
|
|---|
| 3072 | ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_V850_9_PCREL);
|
|---|
| 3073 |
|
|---|
| 3074 | irel->r_addend = addend;
|
|---|
| 3075 | addend = 0;
|
|---|
| 3076 |
|
|---|
| 3077 | if (ELF32_R_SYM (hi_irelfn->r_info) < symtab_hdr->sh_info)
|
|---|
| 3078 | /* If this needs to be changed because of future relaxing,
|
|---|
| 3079 | it will be handled here like other internal IND12W
|
|---|
| 3080 | relocs. */
|
|---|
| 3081 | bfd_put_16 (abfd,
|
|---|
| 3082 | 0x0585 | ((addend << 10) & 0xf800) | ((addend << 3) & 0x0070),
|
|---|
| 3083 | contents + irel->r_offset);
|
|---|
| 3084 | else
|
|---|
| 3085 | /* We can't fully resolve this yet, because the external
|
|---|
| 3086 | symbol value may be changed by future relaxing.
|
|---|
| 3087 | We let the final link phase handle it. */
|
|---|
| 3088 | bfd_put_16 (abfd, 0x0585, contents + irel->r_offset);
|
|---|
| 3089 |
|
|---|
| 3090 | hi_irelfn->r_info =
|
|---|
| 3091 | ELF32_R_INFO (ELF32_R_SYM (hi_irelfn->r_info), R_V850_NONE);
|
|---|
| 3092 | lo_irelfn->r_info =
|
|---|
| 3093 | ELF32_R_INFO (ELF32_R_SYM (lo_irelfn->r_info), R_V850_NONE);
|
|---|
| 3094 | if (!v850_elf_relax_delete_bytes (abfd, sec,
|
|---|
| 3095 | irel->r_offset + 2, toaddr, 8))
|
|---|
| 3096 | goto error_return;
|
|---|
| 3097 |
|
|---|
| 3098 | align_pad_size += 8;
|
|---|
| 3099 | }
|
|---|
| 3100 | }
|
|---|
| 3101 | }
|
|---|
| 3102 |
|
|---|
| 3103 | irelalign = NULL;
|
|---|
| 3104 | for (irel = internal_relocs; irel < irelend; irel++)
|
|---|
| 3105 | {
|
|---|
| 3106 | if (ELF32_R_TYPE (irel->r_info) == (int) R_V850_ALIGN
|
|---|
| 3107 | && irel->r_offset == toaddr)
|
|---|
| 3108 | {
|
|---|
| 3109 | irel->r_offset -= align_pad_size;
|
|---|
| 3110 |
|
|---|
| 3111 | if (irelalign == NULL || irelalign->r_addend > irel->r_addend)
|
|---|
| 3112 | irelalign = irel;
|
|---|
| 3113 | }
|
|---|
| 3114 | }
|
|---|
| 3115 |
|
|---|
| 3116 | addr = toaddr;
|
|---|
| 3117 | }
|
|---|
| 3118 |
|
|---|
| 3119 | if (!irelalign)
|
|---|
| 3120 | {
|
|---|
| 3121 | #ifdef DEBUG_RELAX
|
|---|
| 3122 | fprintf (stderr, "relax pad %d shorten %d -> %d\n",
|
|---|
| 3123 | align_pad_size,
|
|---|
| 3124 | sec->_cooked_size,
|
|---|
| 3125 | sec->_cooked_size - align_pad_size);
|
|---|
| 3126 | #endif
|
|---|
| 3127 | sec->_cooked_size -= align_pad_size;
|
|---|
| 3128 | }
|
|---|
| 3129 |
|
|---|
| 3130 | finish:
|
|---|
| 3131 | if (internal_relocs != NULL
|
|---|
| 3132 | && elf_section_data (sec)->relocs != internal_relocs)
|
|---|
| 3133 | free (internal_relocs);
|
|---|
| 3134 |
|
|---|
| 3135 | if (contents != NULL
|
|---|
| 3136 | && elf_section_data (sec)->this_hdr.contents != (unsigned char *) contents)
|
|---|
| 3137 | free (contents);
|
|---|
| 3138 |
|
|---|
| 3139 | if (isymbuf != NULL
|
|---|
| 3140 | && symtab_hdr->contents != (bfd_byte *) isymbuf)
|
|---|
| 3141 | free (isymbuf);
|
|---|
| 3142 |
|
|---|
| 3143 | return result;
|
|---|
| 3144 |
|
|---|
| 3145 | error_return:
|
|---|
| 3146 | result = FALSE;
|
|---|
| 3147 | goto finish;
|
|---|
| 3148 | }
|
|---|
| 3149 | |
|---|
| 3150 |
|
|---|
| 3151 | #define TARGET_LITTLE_SYM bfd_elf32_v850_vec
|
|---|
| 3152 | #define TARGET_LITTLE_NAME "elf32-v850"
|
|---|
| 3153 | #define ELF_ARCH bfd_arch_v850
|
|---|
| 3154 | #define ELF_MACHINE_CODE EM_V850
|
|---|
| 3155 | #define ELF_MACHINE_ALT1 EM_CYGNUS_V850
|
|---|
| 3156 | #define ELF_MAXPAGESIZE 0x1000
|
|---|
| 3157 |
|
|---|
| 3158 | #define elf_info_to_howto v850_elf_info_to_howto_rela
|
|---|
| 3159 | #define elf_info_to_howto_rel v850_elf_info_to_howto_rel
|
|---|
| 3160 |
|
|---|
| 3161 | #define elf_backend_check_relocs v850_elf_check_relocs
|
|---|
| 3162 | #define elf_backend_relocate_section v850_elf_relocate_section
|
|---|
| 3163 | #define elf_backend_object_p v850_elf_object_p
|
|---|
| 3164 | #define elf_backend_final_write_processing v850_elf_final_write_processing
|
|---|
| 3165 | #define elf_backend_section_from_bfd_section v850_elf_section_from_bfd_section
|
|---|
| 3166 | #define elf_backend_symbol_processing v850_elf_symbol_processing
|
|---|
| 3167 | #define elf_backend_add_symbol_hook v850_elf_add_symbol_hook
|
|---|
| 3168 | #define elf_backend_link_output_symbol_hook v850_elf_link_output_symbol_hook
|
|---|
| 3169 | #define elf_backend_section_from_shdr v850_elf_section_from_shdr
|
|---|
| 3170 | #define elf_backend_fake_sections v850_elf_fake_sections
|
|---|
| 3171 | #define elf_backend_gc_mark_hook v850_elf_gc_mark_hook
|
|---|
| 3172 | #define elf_backend_gc_sweep_hook v850_elf_gc_sweep_hook
|
|---|
| 3173 |
|
|---|
| 3174 | #define elf_backend_can_gc_sections 1
|
|---|
| 3175 | #define elf_backend_rela_normal 1
|
|---|
| 3176 |
|
|---|
| 3177 | #define bfd_elf32_bfd_is_local_label_name v850_elf_is_local_label_name
|
|---|
| 3178 | #define bfd_elf32_bfd_reloc_type_lookup v850_elf_reloc_type_lookup
|
|---|
| 3179 | #define bfd_elf32_bfd_merge_private_bfd_data v850_elf_merge_private_bfd_data
|
|---|
| 3180 | #define bfd_elf32_bfd_set_private_flags v850_elf_set_private_flags
|
|---|
| 3181 | #define bfd_elf32_bfd_print_private_bfd_data v850_elf_print_private_bfd_data
|
|---|
| 3182 | #define bfd_elf32_bfd_relax_section v850_elf_relax_section
|
|---|
| 3183 |
|
|---|
| 3184 | #define elf_symbol_leading_char '_'
|
|---|
| 3185 |
|
|---|
| 3186 | #include "elf32-target.h"
|
|---|