1 /* V850-specific support for 32-bit ELF
2 Copyright 1996, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
5 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
21 /* XXX FIXME: This code is littered with 32bit int, 16bit short, 8bit char
22 dependencies. As is the gas & simulator code or the v850. */
30 #include "libiberty.h"
32 /* Sign-extend a 24-bit number. */
33 #define SEXT24(x) ((((x) & 0xffffff) ^ 0x800000) - 0x800000)
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
*, Elf32_Internal_Rel
*));
39 static void v850_elf_info_to_howto_rela
40 PARAMS ((bfd
*, arelent
*, Elf32_Internal_Rela
*));
41 static bfd_reloc_status_type v850_elf_reloc
42 PARAMS ((bfd
*, arelent
*, asymbol
*, PTR
, asection
*, bfd
*, char **));
43 static boolean v850_elf_is_local_label_name
44 PARAMS ((bfd
*, const char *));
45 static 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 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
, 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 boolean v850_elf_object_p
61 static boolean v850_elf_fake_sections
62 PARAMS ((bfd
*, Elf32_Internal_Shdr
*, asection
*));
63 static void v850_elf_final_write_processing
64 PARAMS ((bfd
*, boolean
));
65 static boolean v850_elf_set_private_flags
66 PARAMS ((bfd
*, flagword
));
67 static boolean v850_elf_copy_private_bfd_data
68 PARAMS ((bfd
*, bfd
*));
69 static boolean v850_elf_merge_private_bfd_data
70 PARAMS ((bfd
*, bfd
*));
71 static boolean v850_elf_print_private_bfd_data
72 PARAMS ((bfd
*, PTR
));
73 static boolean v850_elf_section_from_bfd_section
74 PARAMS ((bfd
*, Elf32_Internal_Shdr
*, asection
*, int *));
75 static void v850_elf_symbol_processing
76 PARAMS ((bfd
*, asymbol
*));
77 static boolean v850_elf_add_symbol_hook
78 PARAMS ((bfd
*, struct bfd_link_info
*, const Elf_Internal_Sym
*,
79 const char **, flagword
*, asection
**, bfd_vma
*));
80 static boolean v850_elf_link_output_symbol_hook
81 PARAMS ((bfd
*, struct bfd_link_info
*, const char *,
82 Elf_Internal_Sym
*, asection
*));
83 static boolean v850_elf_section_from_shdr
84 PARAMS ((bfd
*, Elf_Internal_Shdr
*, char *));
85 static boolean v850_elf_gc_sweep_hook
86 PARAMS ((bfd
*, struct bfd_link_info
*, asection
*,
87 const Elf_Internal_Rela
*));
88 static asection
* v850_elf_gc_mark_hook
89 PARAMS ((bfd
*, struct bfd_link_info
*,
90 Elf_Internal_Rela
*, struct elf_link_hash_entry
*,
93 /* Note: It is REQUIRED that the 'type' value of each entry
94 in this array match the index of the entry in the array. */
95 static reloc_howto_type v850_elf_howto_table
[] =
97 /* This reloc does nothing. */
98 HOWTO (R_V850_NONE
, /* type */
100 2, /* size (0 = byte, 1 = short, 2 = long) */
102 false, /* pc_relative */
104 complain_overflow_bitfield
, /* complain_on_overflow */
105 bfd_elf_generic_reloc
, /* special_function */
106 "R_V850_NONE", /* name */
107 false, /* partial_inplace */
110 false), /* pcrel_offset */
112 /* A PC relative 9 bit branch. */
113 HOWTO (R_V850_9_PCREL
, /* type */
115 2, /* size (0 = byte, 1 = short, 2 = long) */
117 true, /* pc_relative */
119 complain_overflow_bitfield
, /* complain_on_overflow */
120 v850_elf_reloc
, /* special_function */
121 "R_V850_9_PCREL", /* name */
122 false, /* partial_inplace */
123 0x00ffffff, /* src_mask */
124 0x00ffffff, /* dst_mask */
125 true), /* pcrel_offset */
127 /* A PC relative 22 bit branch. */
128 HOWTO (R_V850_22_PCREL
, /* type */
130 2, /* size (0 = byte, 1 = short, 2 = long) */
132 true, /* pc_relative */
134 complain_overflow_signed
, /* complain_on_overflow */
135 v850_elf_reloc
, /* special_function */
136 "R_V850_22_PCREL", /* name */
137 false, /* partial_inplace */
138 0x07ffff80, /* src_mask */
139 0x07ffff80, /* dst_mask */
140 true), /* pcrel_offset */
142 /* High 16 bits of symbol value. */
143 HOWTO (R_V850_HI16_S
, /* type */
145 1, /* size (0 = byte, 1 = short, 2 = long) */
147 false, /* pc_relative */
149 complain_overflow_dont
, /* complain_on_overflow */
150 v850_elf_reloc
, /* special_function */
151 "R_V850_HI16_S", /* name */
152 false, /* partial_inplace */
153 0xffff, /* src_mask */
154 0xffff, /* dst_mask */
155 false), /* pcrel_offset */
157 /* High 16 bits of symbol value. */
158 HOWTO (R_V850_HI16
, /* type */
160 1, /* size (0 = byte, 1 = short, 2 = long) */
162 false, /* pc_relative */
164 complain_overflow_dont
, /* complain_on_overflow */
165 v850_elf_reloc
, /* special_function */
166 "R_V850_HI16", /* name */
167 false, /* partial_inplace */
168 0xffff, /* src_mask */
169 0xffff, /* dst_mask */
170 false), /* pcrel_offset */
172 /* Low 16 bits of symbol value. */
173 HOWTO (R_V850_LO16
, /* type */
175 1, /* size (0 = byte, 1 = short, 2 = long) */
177 false, /* pc_relative */
179 complain_overflow_dont
, /* complain_on_overflow */
180 v850_elf_reloc
, /* special_function */
181 "R_V850_LO16", /* name */
182 false, /* partial_inplace */
183 0xffff, /* src_mask */
184 0xffff, /* dst_mask */
185 false), /* pcrel_offset */
187 /* Simple 32bit reloc. */
188 HOWTO (R_V850_32
, /* type */
190 2, /* size (0 = byte, 1 = short, 2 = long) */
192 false, /* pc_relative */
194 complain_overflow_dont
, /* complain_on_overflow */
195 v850_elf_reloc
, /* special_function */
196 "R_V850_32", /* name */
197 false, /* partial_inplace */
198 0xffffffff, /* src_mask */
199 0xffffffff, /* dst_mask */
200 false), /* pcrel_offset */
202 /* Simple 16bit reloc. */
203 HOWTO (R_V850_16
, /* type */
205 1, /* size (0 = byte, 1 = short, 2 = long) */
207 false, /* pc_relative */
209 complain_overflow_dont
, /* complain_on_overflow */
210 bfd_elf_generic_reloc
, /* special_function */
211 "R_V850_16", /* name */
212 false, /* partial_inplace */
213 0xffff, /* src_mask */
214 0xffff, /* dst_mask */
215 false), /* pcrel_offset */
217 /* Simple 8bit reloc. */
218 HOWTO (R_V850_8
, /* type */
220 0, /* size (0 = byte, 1 = short, 2 = long) */
222 false, /* pc_relative */
224 complain_overflow_dont
, /* complain_on_overflow */
225 bfd_elf_generic_reloc
, /* special_function */
226 "R_V850_8", /* name */
227 false, /* partial_inplace */
230 false), /* pcrel_offset */
232 /* 16 bit offset from the short data area pointer. */
233 HOWTO (R_V850_SDA_16_16_OFFSET
, /* type */
235 1, /* size (0 = byte, 1 = short, 2 = long) */
237 false, /* pc_relative */
239 complain_overflow_dont
, /* complain_on_overflow */
240 v850_elf_reloc
, /* special_function */
241 "R_V850_SDA_16_16_OFFSET", /* name */
242 false, /* partial_inplace */
243 0xffff, /* src_mask */
244 0xffff, /* dst_mask */
245 false), /* pcrel_offset */
247 /* 15 bit offset from the short data area pointer. */
248 HOWTO (R_V850_SDA_15_16_OFFSET
, /* type */
250 1, /* size (0 = byte, 1 = short, 2 = long) */
252 false, /* pc_relative */
254 complain_overflow_dont
, /* complain_on_overflow */
255 v850_elf_reloc
, /* special_function */
256 "R_V850_SDA_15_16_OFFSET", /* name */
257 false, /* partial_inplace */
258 0xfffe, /* src_mask */
259 0xfffe, /* dst_mask */
260 false), /* pcrel_offset */
262 /* 16 bit offset from the zero data area pointer. */
263 HOWTO (R_V850_ZDA_16_16_OFFSET
, /* type */
265 1, /* size (0 = byte, 1 = short, 2 = long) */
267 false, /* pc_relative */
269 complain_overflow_dont
, /* complain_on_overflow */
270 v850_elf_reloc
, /* special_function */
271 "R_V850_ZDA_16_16_OFFSET", /* name */
272 false, /* partial_inplace */
273 0xffff, /* src_mask */
274 0xffff, /* dst_mask */
275 false), /* pcrel_offset */
277 /* 15 bit offset from the zero data area pointer. */
278 HOWTO (R_V850_ZDA_15_16_OFFSET
, /* type */
280 1, /* size (0 = byte, 1 = short, 2 = long) */
282 false, /* pc_relative */
284 complain_overflow_dont
, /* complain_on_overflow */
285 v850_elf_reloc
, /* special_function */
286 "R_V850_ZDA_15_16_OFFSET", /* name */
287 false, /* partial_inplace */
288 0xfffe, /* src_mask */
289 0xfffe, /* dst_mask */
290 false), /* pcrel_offset */
292 /* 6 bit offset from the tiny data area pointer. */
293 HOWTO (R_V850_TDA_6_8_OFFSET
, /* type */
295 1, /* size (0 = byte, 1 = short, 2 = long) */
297 false, /* pc_relative */
299 complain_overflow_dont
, /* complain_on_overflow */
300 v850_elf_reloc
, /* special_function */
301 "R_V850_TDA_6_8_OFFSET", /* name */
302 false, /* partial_inplace */
305 false), /* pcrel_offset */
307 /* 8 bit offset from the tiny data area pointer. */
308 HOWTO (R_V850_TDA_7_8_OFFSET
, /* type */
310 1, /* size (0 = byte, 1 = short, 2 = long) */
312 false, /* pc_relative */
314 complain_overflow_dont
, /* complain_on_overflow */
315 v850_elf_reloc
, /* special_function */
316 "R_V850_TDA_7_8_OFFSET", /* name */
317 false, /* partial_inplace */
320 false), /* pcrel_offset */
322 /* 7 bit offset from the tiny data area pointer. */
323 HOWTO (R_V850_TDA_7_7_OFFSET
, /* type */
325 1, /* size (0 = byte, 1 = short, 2 = long) */
327 false, /* pc_relative */
329 complain_overflow_dont
, /* complain_on_overflow */
330 v850_elf_reloc
, /* special_function */
331 "R_V850_TDA_7_7_OFFSET", /* name */
332 false, /* partial_inplace */
335 false), /* pcrel_offset */
337 /* 16 bit offset from the tiny data area pointer! */
338 HOWTO (R_V850_TDA_16_16_OFFSET
, /* type */
340 1, /* size (0 = byte, 1 = short, 2 = long) */
342 false, /* pc_relative */
344 complain_overflow_dont
, /* complain_on_overflow */
345 v850_elf_reloc
, /* special_function */
346 "R_V850_TDA_16_16_OFFSET", /* name */
347 false, /* partial_inplace */
348 0xffff, /* src_mask */
349 0xfff, /* dst_mask */
350 false), /* pcrel_offset */
352 /* 5 bit offset from the tiny data area pointer. */
353 HOWTO (R_V850_TDA_4_5_OFFSET
, /* type */
355 1, /* size (0 = byte, 1 = short, 2 = long) */
357 false, /* pc_relative */
359 complain_overflow_dont
, /* complain_on_overflow */
360 v850_elf_reloc
, /* special_function */
361 "R_V850_TDA_4_5_OFFSET", /* name */
362 false, /* partial_inplace */
365 false), /* pcrel_offset */
367 /* 4 bit offset from the tiny data area pointer. */
368 HOWTO (R_V850_TDA_4_4_OFFSET
, /* type */
370 1, /* size (0 = byte, 1 = short, 2 = long) */
372 false, /* pc_relative */
374 complain_overflow_dont
, /* complain_on_overflow */
375 v850_elf_reloc
, /* special_function */
376 "R_V850_TDA_4_4_OFFSET", /* name */
377 false, /* partial_inplace */
380 false), /* pcrel_offset */
382 /* 16 bit offset from the short data area pointer. */
383 HOWTO (R_V850_SDA_16_16_SPLIT_OFFSET
, /* type */
385 2, /* size (0 = byte, 1 = short, 2 = long) */
387 false, /* pc_relative */
389 complain_overflow_dont
, /* complain_on_overflow */
390 v850_elf_reloc
, /* special_function */
391 "R_V850_SDA_16_16_SPLIT_OFFSET",/* name */
392 false, /* partial_inplace */
393 0xfffe0020, /* src_mask */
394 0xfffe0020, /* dst_mask */
395 false), /* pcrel_offset */
397 /* 16 bit offset from the zero data area pointer. */
398 HOWTO (R_V850_ZDA_16_16_SPLIT_OFFSET
, /* type */
400 2, /* size (0 = byte, 1 = short, 2 = long) */
402 false, /* pc_relative */
404 complain_overflow_dont
, /* complain_on_overflow */
405 v850_elf_reloc
, /* special_function */
406 "R_V850_ZDA_16_16_SPLIT_OFFSET",/* name */
407 false, /* partial_inplace */
408 0xfffe0020, /* src_mask */
409 0xfffe0020, /* dst_mask */
410 false), /* pcrel_offset */
412 /* 6 bit offset from the call table base pointer. */
413 HOWTO (R_V850_CALLT_6_7_OFFSET
, /* type */
415 1, /* size (0 = byte, 1 = short, 2 = long) */
417 false, /* pc_relative */
419 complain_overflow_dont
, /* complain_on_overflow */
420 v850_elf_reloc
, /* special_function */
421 "R_V850_CALLT_6_7_OFFSET", /* name */
422 false, /* partial_inplace */
425 false), /* pcrel_offset */
427 /* 16 bit offset from the call table base pointer. */
428 HOWTO (R_V850_CALLT_16_16_OFFSET
, /* type */
430 1, /* size (0 = byte, 1 = short, 2 = long) */
432 false, /* pc_relative */
434 complain_overflow_dont
, /* complain_on_overflow */
435 v850_elf_reloc
, /* special_function */
436 "R_V850_CALLT_16_16_OFFSET", /* name */
437 false, /* partial_inplace */
438 0xffff, /* src_mask */
439 0xffff, /* dst_mask */
440 false), /* pcrel_offset */
442 /* GNU extension to record C++ vtable hierarchy */
443 HOWTO (R_V850_GNU_VTINHERIT
, /* type */
445 2, /* size (0 = byte, 1 = short, 2 = long) */
447 false, /* pc_relative */
449 complain_overflow_dont
, /* complain_on_overflow */
450 NULL
, /* special_function */
451 "R_V850_GNU_VTINHERIT", /* name */
452 false, /* partial_inplace */
455 false), /* pcrel_offset */
457 /* GNU extension to record C++ vtable member usage */
458 HOWTO (R_V850_GNU_VTENTRY
, /* type */
460 2, /* size (0 = byte, 1 = short, 2 = long) */
462 false, /* pc_relative */
464 complain_overflow_dont
, /* complain_on_overflow */
465 _bfd_elf_rel_vtable_reloc_fn
, /* special_function */
466 "R_V850_GNU_VTENTRY", /* name */
467 false, /* partial_inplace */
470 false), /* pcrel_offset */
474 /* Map BFD reloc types to V850 ELF reloc types. */
476 struct v850_elf_reloc_map
478 /* BFD_RELOC_V850_CALLT_16_16_OFFSET is 258, which will not fix in an
480 bfd_reloc_code_real_type bfd_reloc_val
;
481 unsigned int elf_reloc_val
;
484 static const struct v850_elf_reloc_map v850_elf_reloc_map
[] =
486 { BFD_RELOC_NONE
, R_V850_NONE
},
487 { BFD_RELOC_V850_9_PCREL
, R_V850_9_PCREL
},
488 { BFD_RELOC_V850_22_PCREL
, R_V850_22_PCREL
},
489 { BFD_RELOC_HI16_S
, R_V850_HI16_S
},
490 { BFD_RELOC_HI16
, R_V850_HI16
},
491 { BFD_RELOC_LO16
, R_V850_LO16
},
492 { BFD_RELOC_32
, R_V850_32
},
493 { BFD_RELOC_16
, R_V850_16
},
494 { BFD_RELOC_8
, R_V850_8
},
495 { BFD_RELOC_V850_SDA_16_16_OFFSET
, R_V850_SDA_16_16_OFFSET
},
496 { BFD_RELOC_V850_SDA_15_16_OFFSET
, R_V850_SDA_15_16_OFFSET
},
497 { BFD_RELOC_V850_ZDA_16_16_OFFSET
, R_V850_ZDA_16_16_OFFSET
},
498 { BFD_RELOC_V850_ZDA_15_16_OFFSET
, R_V850_ZDA_15_16_OFFSET
},
499 { BFD_RELOC_V850_TDA_6_8_OFFSET
, R_V850_TDA_6_8_OFFSET
},
500 { BFD_RELOC_V850_TDA_7_8_OFFSET
, R_V850_TDA_7_8_OFFSET
},
501 { BFD_RELOC_V850_TDA_7_7_OFFSET
, R_V850_TDA_7_7_OFFSET
},
502 { BFD_RELOC_V850_TDA_16_16_OFFSET
, R_V850_TDA_16_16_OFFSET
},
503 { BFD_RELOC_V850_TDA_4_5_OFFSET
, R_V850_TDA_4_5_OFFSET
},
504 { BFD_RELOC_V850_TDA_4_4_OFFSET
, R_V850_TDA_4_4_OFFSET
},
505 { BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET
, R_V850_SDA_16_16_SPLIT_OFFSET
},
506 { BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET
, R_V850_ZDA_16_16_SPLIT_OFFSET
},
507 { BFD_RELOC_V850_CALLT_6_7_OFFSET
, R_V850_CALLT_6_7_OFFSET
},
508 { BFD_RELOC_V850_CALLT_16_16_OFFSET
, R_V850_CALLT_16_16_OFFSET
},
509 { BFD_RELOC_VTABLE_INHERIT
, R_V850_GNU_VTINHERIT
},
510 { BFD_RELOC_VTABLE_ENTRY
, R_V850_GNU_VTENTRY
},
514 /* Map a bfd relocation into the appropriate howto structure. */
516 static reloc_howto_type
*
517 v850_elf_reloc_type_lookup (abfd
, code
)
518 bfd
* abfd ATTRIBUTE_UNUSED
;
519 bfd_reloc_code_real_type code
;
523 for (i
= ARRAY_SIZE (v850_elf_reloc_map
); i
--;)
524 if (v850_elf_reloc_map
[i
].bfd_reloc_val
== code
)
526 unsigned int elf_reloc_val
= v850_elf_reloc_map
[i
].elf_reloc_val
;
528 BFD_ASSERT (v850_elf_howto_table
[elf_reloc_val
].type
== elf_reloc_val
);
530 return v850_elf_howto_table
+ elf_reloc_val
;
536 /* Set the howto pointer for an V850 ELF reloc. */
539 v850_elf_info_to_howto_rel (abfd
, cache_ptr
, dst
)
540 bfd
* abfd ATTRIBUTE_UNUSED
;
542 Elf32_Internal_Rel
* dst
;
546 r_type
= ELF32_R_TYPE (dst
->r_info
);
547 BFD_ASSERT (r_type
< (unsigned int) R_V850_max
);
548 cache_ptr
->howto
= &v850_elf_howto_table
[r_type
];
551 /* Set the howto pointer for a V850 ELF reloc (type RELA). */
553 v850_elf_info_to_howto_rela (abfd
, cache_ptr
, dst
)
554 bfd
* abfd ATTRIBUTE_UNUSED
;
556 Elf32_Internal_Rela
*dst
;
560 r_type
= ELF32_R_TYPE (dst
->r_info
);
561 BFD_ASSERT (r_type
< (unsigned int) R_V850_max
);
562 cache_ptr
->howto
= &v850_elf_howto_table
[r_type
];
565 /* Look through the relocs for a section during the first phase, and
566 allocate space in the global offset table or procedure linkage
570 v850_elf_check_relocs (abfd
, info
, sec
, relocs
)
572 struct bfd_link_info
* info
;
574 const Elf_Internal_Rela
* relocs
;
578 Elf_Internal_Shdr
*symtab_hdr
;
579 struct elf_link_hash_entry
**sym_hashes
;
580 const Elf_Internal_Rela
*rel
;
581 const Elf_Internal_Rela
*rel_end
;
583 enum v850_reloc_type r_type
;
585 const char *common
= (const char *)0;
587 if (info
->relocateable
)
591 fprintf (stderr
, "v850_elf_check_relocs called for section %s in %s\n",
592 bfd_get_section_name (abfd
, sec
),
593 bfd_archive_filename (abfd
));
596 dynobj
= elf_hash_table (info
)->dynobj
;
597 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
598 sym_hashes
= elf_sym_hashes (abfd
);
601 rel_end
= relocs
+ sec
->reloc_count
;
602 for (rel
= relocs
; rel
< rel_end
; rel
++)
604 unsigned long r_symndx
;
605 struct elf_link_hash_entry
*h
;
607 r_symndx
= ELF32_R_SYM (rel
->r_info
);
608 if (r_symndx
< symtab_hdr
->sh_info
)
611 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
613 r_type
= (enum v850_reloc_type
) ELF32_R_TYPE (rel
->r_info
);
619 case R_V850_22_PCREL
:
626 case R_V850_CALLT_6_7_OFFSET
:
627 case R_V850_CALLT_16_16_OFFSET
:
630 /* This relocation describes the C++ object vtable hierarchy.
631 Reconstruct it for later use during GC. */
632 case R_V850_GNU_VTINHERIT
:
633 if (!_bfd_elf32_gc_record_vtinherit (abfd
, sec
, h
, rel
->r_offset
))
637 /* This relocation describes which C++ vtable entries
638 are actually used. Record for later use during GC. */
639 case R_V850_GNU_VTENTRY
:
640 if (!_bfd_elf32_gc_record_vtentry (abfd
, sec
, h
, rel
->r_addend
))
644 case R_V850_SDA_16_16_SPLIT_OFFSET
:
645 case R_V850_SDA_16_16_OFFSET
:
646 case R_V850_SDA_15_16_OFFSET
:
647 other
= V850_OTHER_SDA
;
649 goto small_data_common
;
651 case R_V850_ZDA_16_16_SPLIT_OFFSET
:
652 case R_V850_ZDA_16_16_OFFSET
:
653 case R_V850_ZDA_15_16_OFFSET
:
654 other
= V850_OTHER_ZDA
;
656 goto small_data_common
;
658 case R_V850_TDA_4_5_OFFSET
:
659 case R_V850_TDA_4_4_OFFSET
:
660 case R_V850_TDA_6_8_OFFSET
:
661 case R_V850_TDA_7_8_OFFSET
:
662 case R_V850_TDA_7_7_OFFSET
:
663 case R_V850_TDA_16_16_OFFSET
:
664 other
= V850_OTHER_TDA
;
668 #define V850_OTHER_MASK (V850_OTHER_TDA | V850_OTHER_SDA | V850_OTHER_ZDA)
673 /* Flag which type of relocation was used. */
675 if ((h
->other
& V850_OTHER_MASK
) != (other
& V850_OTHER_MASK
)
676 && (h
->other
& V850_OTHER_ERROR
) == 0)
679 static char buff
[200]; /* XXX */
681 switch (h
->other
& V850_OTHER_MASK
)
684 msg
= _("Variable `%s' cannot occupy in multiple small data regions");
686 case V850_OTHER_SDA
| V850_OTHER_ZDA
| V850_OTHER_TDA
:
687 msg
= _("Variable `%s' can only be in one of the small, zero, and tiny data regions");
689 case V850_OTHER_SDA
| V850_OTHER_ZDA
:
690 msg
= _("Variable `%s' cannot be in both small and zero data regions simultaneously");
692 case V850_OTHER_SDA
| V850_OTHER_TDA
:
693 msg
= _("Variable `%s' cannot be in both small and tiny data regions simultaneously");
695 case V850_OTHER_ZDA
| V850_OTHER_TDA
:
696 msg
= _("Variable `%s' cannot be in both zero and tiny data regions simultaneously");
700 sprintf (buff
, msg
, h
->root
.root
.string
);
701 info
->callbacks
->warning (info
, buff
, h
->root
.root
.string
,
702 abfd
, h
->root
.u
.def
.section
,
705 bfd_set_error (bfd_error_bad_value
);
706 h
->other
|= V850_OTHER_ERROR
;
711 if (h
&& h
->root
.type
== bfd_link_hash_common
713 && !strcmp (bfd_get_section_name (abfd
, h
->root
.u
.c
.p
->section
), "COMMON"))
717 section
= h
->root
.u
.c
.p
->section
= bfd_make_section_old_way (abfd
, common
);
718 section
->flags
|= SEC_IS_COMMON
;
722 fprintf (stderr
, "v850_elf_check_relocs, found %s relocation for %s%s\n",
723 v850_elf_howto_table
[ (int)r_type
].name
,
724 (h
&& h
->root
.root
.string
) ? h
->root
.root
.string
: "<unknown>",
725 (h
->root
.type
== bfd_link_hash_common
) ? ", symbol is common" : "");
734 /* In the old version, when an entry was checked out from the table,
735 it was deleted. This produced an error if the entry was needed
736 more than once, as the second attempted retry failed.
738 In the current version, the entry is not deleted, instead we set
739 the field 'found' to true. If a second lookup matches the same
740 entry, then we know that the hi16s reloc has already been updated
741 and does not need to be updated a second time.
743 TODO - TOFIX: If it is possible that we need to restore 2 different
744 addresses from the same table entry, where the first generates an
745 overflow, whilst the second do not, then this code will fail. */
747 typedef struct hi16s_location
751 unsigned long counter
;
753 struct hi16s_location
* next
;
757 static hi16s_location
* previous_hi16s
;
758 static hi16s_location
* free_hi16s
;
759 static unsigned long hi16s_counter
;
762 remember_hi16s_reloc (abfd
, addend
, address
)
767 hi16s_location
* entry
= NULL
;
768 bfd_size_type amt
= sizeof (* free_hi16s
);
770 /* Find a free structure. */
771 if (free_hi16s
== NULL
)
772 free_hi16s
= (hi16s_location
*) bfd_zalloc (abfd
, amt
);
775 free_hi16s
= free_hi16s
->next
;
777 entry
->addend
= addend
;
778 entry
->address
= address
;
779 entry
->counter
= hi16s_counter
++;
780 entry
->found
= false;
781 entry
->next
= previous_hi16s
;
782 previous_hi16s
= entry
;
784 /* Cope with wrap around of our counter. */
785 if (hi16s_counter
== 0)
787 /* XXX - Assume that all counter entries differ only in their low 16 bits. */
788 for (entry
= previous_hi16s
; entry
!= NULL
; entry
= entry
->next
)
789 entry
->counter
&= 0xffff;
791 hi16s_counter
= 0x10000;
798 find_remembered_hi16s_reloc (addend
, already_found
)
800 boolean
* already_found
;
802 hi16s_location
* match
= NULL
;
803 hi16s_location
* entry
;
804 hi16s_location
* previous
= NULL
;
805 hi16s_location
* prev
;
808 /* Search the table. Record the most recent entry that matches. */
809 for (entry
= previous_hi16s
; entry
; entry
= entry
->next
)
811 if (entry
->addend
== addend
812 && (match
== NULL
|| match
->counter
< entry
->counter
))
824 /* Extract the address. */
825 addr
= match
->address
;
827 /* Remeber if this entry has already been used before. */
829 * already_found
= match
->found
;
831 /* Note that this entry has now been used. */
837 /* FIXME: The code here probably ought to be removed and the code in reloc.c
838 allowed to do its stuff instead. At least for most of the relocs, anwyay. */
840 static bfd_reloc_status_type
841 v850_elf_perform_relocation (abfd
, r_type
, addend
, address
)
848 bfd_signed_vma saddend
= (bfd_signed_vma
) addend
;
853 /* fprintf (stderr, "reloc type %d not SUPPORTED\n", r_type ); */
854 return bfd_reloc_notsupported
;
857 bfd_put_32 (abfd
, addend
, address
);
860 case R_V850_22_PCREL
:
861 if (saddend
> 0x1fffff || saddend
< -0x200000)
862 return bfd_reloc_overflow
;
864 if ((addend
% 2) != 0)
865 return bfd_reloc_dangerous
;
867 insn
= bfd_get_32 (abfd
, address
);
869 insn
|= (((addend
& 0xfffe) << 16) | ((addend
& 0x3f0000) >> 16));
870 bfd_put_32 (abfd
, (bfd_vma
) insn
, address
);
874 if (saddend
> 0xff || saddend
< -0x100)
875 return bfd_reloc_overflow
;
877 if ((addend
% 2) != 0)
878 return bfd_reloc_dangerous
;
880 insn
= bfd_get_16 (abfd
, address
);
882 insn
|= ((addend
& 0x1f0) << 7) | ((addend
& 0x0e) << 3);
886 addend
+= (bfd_get_16 (abfd
, address
) << 16);
887 addend
= (addend
>> 16);
892 /* Remember where this relocation took place. */
893 remember_hi16s_reloc (abfd
, addend
, address
);
895 addend
+= (bfd_get_16 (abfd
, address
) << 16);
896 addend
= (addend
>> 16) + ((addend
& 0x8000) != 0);
898 /* This relocation cannot overflow. */
906 /* Calculate the sum of the value stored in the instruction and the
907 addend and check for overflow from the low 16 bits into the high
908 16 bits. The assembler has already done some of this: If the
909 value stored in the instruction has its 15th bit set, (counting
910 from zero) then the assembler will have added 1 to the value
911 stored in the associated HI16S reloc. So for example, these
914 movhi hi( fred ), r0, r1
915 movea lo( fred ), r1, r1
917 will store 0 in the value fields for the MOVHI and MOVEA instructions
918 and addend will be the address of fred, but for these instructions:
920 movhi hi( fred + 0x123456), r0, r1
921 movea lo( fred + 0x123456), r1, r1
923 the value stored in the MOVHI instruction will be 0x12 and the value
924 stored in the MOVEA instruction will be 0x3456. If however the
927 movhi hi( fred + 0x10ffff), r0, r1
928 movea lo( fred + 0x10ffff), r1, r1
930 then the value stored in the MOVHI instruction would be 0x11 (not
931 0x10) and the value stored in the MOVEA instruction would be 0xffff.
932 Thus (assuming for the moment that the addend is 0), at run time the
933 MOVHI instruction loads 0x110000 into r1, then the MOVEA instruction
934 adds 0xffffffff (sign extension!) producing 0x10ffff. Similarly if
935 the instructions were:
937 movhi hi( fred - 1), r0, r1
938 movea lo( fred - 1), r1, r1
940 then 0 is stored in the MOVHI instruction and -1 is stored in the
943 Overflow can occur if the addition of the value stored in the
944 instruction plus the addend sets the 15th bit when before it was clear.
945 This is because the 15th bit will be sign extended into the high part,
946 thus reducing its value by one, but since the 15th bit was originally
947 clear, the assembler will not have added 1 to the previous HI16S reloc
948 to compensate for this effect. For example:
950 movhi hi( fred + 0x123456), r0, r1
951 movea lo( fred + 0x123456), r1, r1
953 The value stored in HI16S reloc is 0x12, the value stored in the LO16
954 reloc is 0x3456. If we assume that the address of fred is 0x00007000
955 then the relocations become:
957 HI16S: 0x0012 + (0x00007000 >> 16) = 0x12
958 LO16: 0x3456 + (0x00007000 & 0xffff) = 0xa456
960 but when the instructions are executed, the MOVEA instruction's value
961 is signed extended, so the sum becomes:
966 0x0011a456 but 'fred + 0x123456' = 0x0012a456
968 Note that if the 15th bit was set in the value stored in the LO16
969 reloc, then we do not have to do anything:
971 movhi hi( fred + 0x10ffff), r0, r1
972 movea lo( fred + 0x10ffff), r1, r1
974 HI16S: 0x0011 + (0x00007000 >> 16) = 0x11
975 LO16: 0xffff + (0x00007000 & 0xffff) = 0x6fff
980 0x00116fff = fred + 0x10ffff = 0x7000 + 0x10ffff
982 Overflow can also occur if the computation carries into the 16th bit
983 and it also results in the 15th bit having the same value as the 15th
984 bit of the original value. What happens is that the HI16S reloc
985 will have already examined the 15th bit of the original value and
986 added 1 to the high part if the bit is set. This compensates for the
987 sign extension of 15th bit of the result of the computation. But now
988 there is a carry into the 16th bit, and this has not been allowed for.
990 So, for example if fred is at address 0xf000:
992 movhi hi( fred + 0xffff), r0, r1 [bit 15 of the offset is set]
993 movea lo( fred + 0xffff), r1, r1
995 HI16S: 0x0001 + (0x0000f000 >> 16) = 0x0001
996 LO16: 0xffff + (0x0000f000 & 0xffff) = 0xefff (carry into bit 16 is lost)
1001 0x0000efff but 'fred + 0xffff' = 0x0001efff
1003 Similarly, if the 15th bit remains clear, but overflow occurs into
1004 the 16th bit then (assuming the address of fred is 0xf000):
1006 movhi hi( fred + 0x7000), r0, r1 [bit 15 of the offset is clear]
1007 movea lo( fred + 0x7000), r1, r1
1009 HI16S: 0x0000 + (0x0000f000 >> 16) = 0x0000
1010 LO16: 0x7000 + (0x0000f000 & 0xffff) = 0x6fff (carry into bit 16 is lost)
1015 0x00006fff but 'fred + 0x7000' = 0x00016fff
1017 Note - there is no need to change anything if a carry occurs, and the
1018 15th bit changes its value from being set to being clear, as the HI16S
1019 reloc will have already added in 1 to the high part for us:
1021 movhi hi( fred + 0xffff), r0, r1 [bit 15 of the offset is set]
1022 movea lo( fred + 0xffff), r1, r1
1024 HI16S: 0x0001 + (0x00007000 >> 16)
1025 LO16: 0xffff + (0x00007000 & 0xffff) = 0x6fff (carry into bit 16 is lost)
1028 + 0x00006fff (bit 15 not set, so the top half is zero)
1030 0x00016fff which is right (assuming that fred is at 0x7000)
1032 but if the 15th bit goes from being clear to being set, then we must
1033 once again handle overflow:
1035 movhi hi( fred + 0x7000), r0, r1 [bit 15 of the offset is clear]
1036 movea lo( fred + 0x7000), r1, r1
1038 HI16S: 0x0000 + (0x0000ffff >> 16)
1039 LO16: 0x7000 + (0x0000ffff & 0xffff) = 0x6fff (carry into bit 16)
1042 + 0x00006fff (bit 15 not set, so the top half is zero)
1044 0x00006fff which is wrong (assuming that fred is at 0xffff). */
1048 insn
= bfd_get_16 (abfd
, address
);
1049 result
= insn
+ addend
;
1051 #define BIT15_SET(x) ((x) & 0x8000)
1052 #define OVERFLOWS(a,i) ((((a) & 0xffff) + (i)) > 0xffff)
1054 if ((BIT15_SET (result
) && ! BIT15_SET (addend
))
1055 || (OVERFLOWS (addend
, insn
)
1056 && ((! BIT15_SET (insn
)) || (BIT15_SET (addend
)))))
1058 boolean already_updated
;
1059 bfd_byte
* hi16s_address
= find_remembered_hi16s_reloc
1060 (addend
, & already_updated
);
1062 /* Amend the matching HI16_S relocation. */
1063 if (hi16s_address
!= NULL
)
1065 if (! already_updated
)
1067 insn
= bfd_get_16 (abfd
, hi16s_address
);
1069 bfd_put_16 (abfd
, (bfd_vma
) insn
, hi16s_address
);
1074 fprintf (stderr
, _("FAILED to find previous HI16 reloc\n"));
1075 return bfd_reloc_overflow
;
1079 /* Do not complain if value has top bit set, as this has been anticipated. */
1080 insn
= result
& 0xffff;
1085 addend
+= (char) bfd_get_8 (abfd
, address
);
1087 saddend
= (bfd_signed_vma
) addend
;
1089 if (saddend
> 0x7f || saddend
< -0x80)
1090 return bfd_reloc_overflow
;
1092 bfd_put_8 (abfd
, addend
, address
);
1093 return bfd_reloc_ok
;
1095 case R_V850_CALLT_16_16_OFFSET
:
1096 addend
+= bfd_get_16 (abfd
, address
);
1098 saddend
= (bfd_signed_vma
) addend
;
1100 if (saddend
> 0xffff || saddend
< 0)
1101 return bfd_reloc_overflow
;
1109 case R_V850_SDA_16_16_OFFSET
:
1110 case R_V850_ZDA_16_16_OFFSET
:
1111 case R_V850_TDA_16_16_OFFSET
:
1112 addend
+= bfd_get_16 (abfd
, address
);
1114 saddend
= (bfd_signed_vma
) addend
;
1116 if (saddend
> 0x7fff || saddend
< -0x8000)
1117 return bfd_reloc_overflow
;
1122 case R_V850_SDA_15_16_OFFSET
:
1123 case R_V850_ZDA_15_16_OFFSET
:
1124 insn
= bfd_get_16 (abfd
, address
);
1125 addend
+= (insn
& 0xfffe);
1127 saddend
= (bfd_signed_vma
) addend
;
1129 if (saddend
> 0x7ffe || saddend
< -0x8000)
1130 return bfd_reloc_overflow
;
1133 return bfd_reloc_dangerous
;
1135 insn
= (addend
&~ (bfd_vma
) 1) | (insn
& 1);
1138 case R_V850_TDA_6_8_OFFSET
:
1139 insn
= bfd_get_16 (abfd
, address
);
1140 addend
+= ((insn
& 0x7e) << 1);
1142 saddend
= (bfd_signed_vma
) addend
;
1144 if (saddend
> 0xfc || saddend
< 0)
1145 return bfd_reloc_overflow
;
1148 return bfd_reloc_dangerous
;
1151 insn
|= (addend
>> 1);
1154 case R_V850_TDA_7_8_OFFSET
:
1155 insn
= bfd_get_16 (abfd
, address
);
1156 addend
+= ((insn
& 0x7f) << 1);
1158 saddend
= (bfd_signed_vma
) addend
;
1160 if (saddend
> 0xfe || saddend
< 0)
1161 return bfd_reloc_overflow
;
1164 return bfd_reloc_dangerous
;
1167 insn
|= (addend
>> 1);
1170 case R_V850_TDA_7_7_OFFSET
:
1171 insn
= bfd_get_16 (abfd
, address
);
1172 addend
+= insn
& 0x7f;
1174 saddend
= (bfd_signed_vma
) addend
;
1176 if (saddend
> 0x7f || saddend
< 0)
1177 return bfd_reloc_overflow
;
1183 case R_V850_TDA_4_5_OFFSET
:
1184 insn
= bfd_get_16 (abfd
, address
);
1185 addend
+= ((insn
& 0xf) << 1);
1187 saddend
= (bfd_signed_vma
) addend
;
1189 if (saddend
> 0x1e || saddend
< 0)
1190 return bfd_reloc_overflow
;
1193 return bfd_reloc_dangerous
;
1196 insn
|= (addend
>> 1);
1199 case R_V850_TDA_4_4_OFFSET
:
1200 insn
= bfd_get_16 (abfd
, address
);
1201 addend
+= insn
& 0xf;
1203 saddend
= (bfd_signed_vma
) addend
;
1205 if (saddend
> 0xf || saddend
< 0)
1206 return bfd_reloc_overflow
;
1212 case R_V850_ZDA_16_16_SPLIT_OFFSET
:
1213 case R_V850_SDA_16_16_SPLIT_OFFSET
:
1214 insn
= bfd_get_32 (abfd
, address
);
1215 addend
+= ((insn
& 0xfffe0000) >> 16) + ((insn
& 0x20) >> 5);
1217 saddend
= (bfd_signed_vma
) addend
;
1219 if (saddend
> 0x7fff || saddend
< -0x8000)
1220 return bfd_reloc_overflow
;
1223 insn
|= (addend
& 1) << 5;
1224 insn
|= (addend
&~ (bfd_vma
) 1) << 16;
1226 bfd_put_32 (abfd
, (bfd_vma
) insn
, address
);
1227 return bfd_reloc_ok
;
1229 case R_V850_CALLT_6_7_OFFSET
:
1230 insn
= bfd_get_16 (abfd
, address
);
1231 addend
+= ((insn
& 0x3f) << 1);
1233 saddend
= (bfd_signed_vma
) addend
;
1235 if (saddend
> 0x7e || saddend
< 0)
1236 return bfd_reloc_overflow
;
1239 return bfd_reloc_dangerous
;
1242 insn
|= (addend
>> 1);
1245 case R_V850_GNU_VTINHERIT
:
1246 case R_V850_GNU_VTENTRY
:
1247 return bfd_reloc_ok
;
1251 bfd_put_16 (abfd
, (bfd_vma
) insn
, address
);
1252 return bfd_reloc_ok
;
1255 /* Insert the addend into the instruction. */
1257 static bfd_reloc_status_type
1258 v850_elf_reloc (abfd
, reloc
, symbol
, data
, isection
, obfd
, err
)
1259 bfd
* abfd ATTRIBUTE_UNUSED
;
1262 PTR data ATTRIBUTE_UNUSED
;
1263 asection
* isection
;
1265 char ** err ATTRIBUTE_UNUSED
;
1269 /* If there is an output BFD,
1270 and the symbol is not a section name (which is only defined at final link time),
1271 and either we are not putting the addend into the instruction
1272 or the addend is zero, so there is nothing to add into the instruction
1273 then just fixup the address and return. */
1274 if (obfd
!= (bfd
*) NULL
1275 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
1276 && (! reloc
->howto
->partial_inplace
1277 || reloc
->addend
== 0))
1279 reloc
->address
+= isection
->output_offset
;
1280 return bfd_reloc_ok
;
1283 else if (obfd
!= NULL
)
1284 return bfd_reloc_continue
;
1287 /* Catch relocs involving undefined symbols. */
1288 if (bfd_is_und_section (symbol
->section
)
1289 && (symbol
->flags
& BSF_WEAK
) == 0
1291 return bfd_reloc_undefined
;
1293 /* We handle final linking of some relocs ourselves. */
1295 /* Is the address of the relocation really within the section? */
1296 if (reloc
->address
> isection
->_cooked_size
)
1297 return bfd_reloc_outofrange
;
1299 /* Work out which section the relocation is targetted at and the
1300 initial relocation command value. */
1302 /* Get symbol value. (Common symbols are special.) */
1303 if (bfd_is_com_section (symbol
->section
))
1306 relocation
= symbol
->value
;
1308 /* Convert input-section-relative symbol value to absolute + addend. */
1309 relocation
+= symbol
->section
->output_section
->vma
;
1310 relocation
+= symbol
->section
->output_offset
;
1311 relocation
+= reloc
->addend
;
1313 #if 0 /* Since this reloc is going to be processed later on, we should
1314 not make it pc-relative here. To test this, try assembling and
1315 linking this program:
1323 .section ".foo","ax"
1327 if (reloc
->howto
->pc_relative
== true)
1329 /* Here the variable relocation holds the final address of the
1330 symbol we are relocating against, plus any addend. */
1331 relocation
-= isection
->output_section
->vma
+ isection
->output_offset
;
1333 /* Deal with pcrel_offset. */
1334 relocation
-= reloc
->address
;
1337 reloc
->addend
= relocation
;
1338 return bfd_reloc_ok
;
1342 v850_elf_is_local_label_name (abfd
, name
)
1343 bfd
* abfd ATTRIBUTE_UNUSED
;
1346 return ( (name
[0] == '.' && (name
[1] == 'L' || name
[1] == '.'))
1347 || (name
[0] == '_' && name
[1] == '.' && name
[2] == 'L' && name
[3] == '_'));
1350 /* Perform a relocation as part of a final link. */
1352 static bfd_reloc_status_type
1353 v850_elf_final_link_relocate (howto
, input_bfd
, output_bfd
,
1354 input_section
, contents
, offset
, value
,
1355 addend
, info
, sym_sec
, is_local
)
1356 reloc_howto_type
* howto
;
1358 bfd
* output_bfd ATTRIBUTE_UNUSED
;
1359 asection
* input_section
;
1360 bfd_byte
* contents
;
1364 struct bfd_link_info
* info
;
1366 int is_local ATTRIBUTE_UNUSED
;
1368 unsigned int r_type
= howto
->type
;
1369 bfd_byte
* hit_data
= contents
+ offset
;
1371 /* Adjust the value according to the relocation. */
1374 case R_V850_9_PCREL
:
1375 value
-= (input_section
->output_section
->vma
1376 + input_section
->output_offset
);
1380 case R_V850_22_PCREL
:
1381 value
-= (input_section
->output_section
->vma
1382 + input_section
->output_offset
1385 /* If the sign extension will corrupt the value then we have overflowed. */
1386 if (((value
& 0xff000000) != 0x0) && ((value
& 0xff000000) != 0xff000000))
1387 return bfd_reloc_overflow
;
1389 /* Only the bottom 24 bits of the PC are valid */
1390 value
= SEXT24 (value
);
1401 case R_V850_ZDA_15_16_OFFSET
:
1402 case R_V850_ZDA_16_16_OFFSET
:
1403 case R_V850_ZDA_16_16_SPLIT_OFFSET
:
1404 if (sym_sec
== NULL
)
1405 return bfd_reloc_undefined
;
1407 value
-= sym_sec
->output_section
->vma
;
1410 case R_V850_SDA_15_16_OFFSET
:
1411 case R_V850_SDA_16_16_OFFSET
:
1412 case R_V850_SDA_16_16_SPLIT_OFFSET
:
1415 struct bfd_link_hash_entry
* h
;
1417 if (sym_sec
== NULL
)
1418 return bfd_reloc_undefined
;
1420 /* Get the value of __gp. */
1421 h
= bfd_link_hash_lookup (info
->hash
, "__gp", false, false, true);
1422 if (h
== (struct bfd_link_hash_entry
*) NULL
1423 || h
->type
!= bfd_link_hash_defined
)
1424 return bfd_reloc_other
;
1426 gp
= (h
->u
.def
.value
1427 + h
->u
.def
.section
->output_section
->vma
1428 + h
->u
.def
.section
->output_offset
);
1430 value
-= sym_sec
->output_section
->vma
;
1431 value
-= (gp
- sym_sec
->output_section
->vma
);
1435 case R_V850_TDA_4_4_OFFSET
:
1436 case R_V850_TDA_4_5_OFFSET
:
1437 case R_V850_TDA_16_16_OFFSET
:
1438 case R_V850_TDA_7_7_OFFSET
:
1439 case R_V850_TDA_7_8_OFFSET
:
1440 case R_V850_TDA_6_8_OFFSET
:
1443 struct bfd_link_hash_entry
* h
;
1445 /* Get the value of __ep. */
1446 h
= bfd_link_hash_lookup (info
->hash
, "__ep", false, false, true);
1447 if (h
== (struct bfd_link_hash_entry
*) NULL
1448 || h
->type
!= bfd_link_hash_defined
)
1449 /* Actually this indicates that __ep could not be found. */
1450 return bfd_reloc_continue
;
1452 ep
= (h
->u
.def
.value
1453 + h
->u
.def
.section
->output_section
->vma
1454 + h
->u
.def
.section
->output_offset
);
1460 case R_V850_CALLT_6_7_OFFSET
:
1463 struct bfd_link_hash_entry
* h
;
1465 /* Get the value of __ctbp. */
1466 h
= bfd_link_hash_lookup (info
->hash
, "__ctbp", false, false, true);
1467 if (h
== (struct bfd_link_hash_entry
*) NULL
1468 || h
->type
!= bfd_link_hash_defined
)
1469 /* Actually this indicates that __ctbp could not be found. */
1470 return bfd_reloc_dangerous
+ 1;
1472 ctbp
= (h
->u
.def
.value
1473 + h
->u
.def
.section
->output_section
->vma
1474 + h
->u
.def
.section
->output_offset
);
1479 case R_V850_CALLT_16_16_OFFSET
:
1482 struct bfd_link_hash_entry
* h
;
1484 if (sym_sec
== NULL
)
1485 return bfd_reloc_undefined
;
1487 /* Get the value of __ctbp. */
1488 h
= bfd_link_hash_lookup (info
->hash
, "__ctbp", false, false, true);
1489 if (h
== (struct bfd_link_hash_entry
*) NULL
1490 || h
->type
!= bfd_link_hash_defined
)
1491 return (bfd_reloc_dangerous
+ 1);
1493 ctbp
= (h
->u
.def
.value
1494 + h
->u
.def
.section
->output_section
->vma
1495 + h
->u
.def
.section
->output_offset
);
1497 value
-= sym_sec
->output_section
->vma
;
1498 value
-= (ctbp
- sym_sec
->output_section
->vma
);
1503 case R_V850_GNU_VTINHERIT
:
1504 case R_V850_GNU_VTENTRY
:
1505 return bfd_reloc_ok
;
1508 return bfd_reloc_notsupported
;
1511 /* Perform the relocation. */
1512 return v850_elf_perform_relocation (input_bfd
, r_type
, value
+ addend
, hit_data
);
1515 /* Relocate an V850 ELF section. */
1518 v850_elf_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
1519 contents
, relocs
, local_syms
, local_sections
)
1521 struct bfd_link_info
* info
;
1523 asection
* input_section
;
1524 bfd_byte
* contents
;
1525 Elf_Internal_Rela
* relocs
;
1526 Elf_Internal_Sym
* local_syms
;
1527 asection
** local_sections
;
1529 Elf_Internal_Shdr
* symtab_hdr
;
1530 struct elf_link_hash_entry
** sym_hashes
;
1531 Elf_Internal_Rela
* rel
;
1532 Elf_Internal_Rela
* relend
;
1534 symtab_hdr
= & elf_tdata (input_bfd
)->symtab_hdr
;
1535 sym_hashes
= elf_sym_hashes (input_bfd
);
1537 if (sym_hashes
== NULL
)
1539 info
->callbacks
->warning
1540 (info
, "no hash table available",
1541 NULL
, input_bfd
, input_section
, (bfd_vma
) 0);
1546 /* Reset the list of remembered HI16S relocs to empty. */
1547 free_hi16s
= previous_hi16s
;
1548 previous_hi16s
= NULL
;
1552 relend
= relocs
+ input_section
->reloc_count
;
1553 for (; rel
< relend
; rel
++)
1556 reloc_howto_type
* howto
;
1557 unsigned long r_symndx
;
1558 Elf_Internal_Sym
* sym
;
1560 struct elf_link_hash_entry
* h
;
1562 bfd_reloc_status_type r
;
1564 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1565 r_type
= ELF32_R_TYPE (rel
->r_info
);
1567 if (r_type
== R_V850_GNU_VTENTRY
1568 || r_type
== R_V850_GNU_VTINHERIT
)
1571 howto
= v850_elf_howto_table
+ r_type
;
1573 if (info
->relocateable
)
1575 /* This is a relocateable link. We don't have to change
1576 anything, unless the reloc is against a section symbol,
1577 in which case we have to adjust according to where the
1578 section symbol winds up in the output section. */
1579 if (r_symndx
< symtab_hdr
->sh_info
)
1581 sym
= local_syms
+ r_symndx
;
1582 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
1584 sec
= local_sections
[r_symndx
];
1585 rel
->r_addend
+= sec
->output_offset
+ sym
->st_value
;
1592 /* This is a final link. */
1596 if (r_symndx
< symtab_hdr
->sh_info
)
1598 sym
= local_syms
+ r_symndx
;
1599 sec
= local_sections
[r_symndx
];
1600 relocation
= _bfd_elf_rela_local_sym (output_bfd
, sym
, sec
, rel
);
1605 name
= bfd_elf_string_from_elf_section (input_bfd
, symtab_hdr
->sh_link
, sym
->st_name
);
1606 name
= (name
== NULL
) ? "<none>" : name
;
1607 fprintf (stderr
, "local: sec: %s, sym: %s (%d), value: %x + %x + %x addend %x\n",
1608 sec
->name
, name
, sym
->st_name
,
1609 sec
->output_section
->vma
, sec
->output_offset
, sym
->st_value
, rel
->r_addend
);
1615 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1617 while (h
->root
.type
== bfd_link_hash_indirect
1618 || h
->root
.type
== bfd_link_hash_warning
)
1619 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
1621 if (h
->root
.type
== bfd_link_hash_defined
1622 || h
->root
.type
== bfd_link_hash_defweak
)
1624 sec
= h
->root
.u
.def
.section
;
1625 relocation
= (h
->root
.u
.def
.value
1626 + sec
->output_section
->vma
1627 + sec
->output_offset
);
1629 fprintf (stderr
, "defined: sec: %s, name: %s, value: %x + %x + %x gives: %x\n",
1630 sec
->name
, h
->root
.root
.string
, h
->root
.u
.def
.value
, sec
->output_section
->vma
, sec
->output_offset
, relocation
);
1633 else if (h
->root
.type
== bfd_link_hash_undefweak
)
1636 fprintf (stderr
, "undefined: sec: %s, name: %s\n",
1637 sec
->name
, h
->root
.root
.string
);
1643 if (! ((*info
->callbacks
->undefined_symbol
)
1644 (info
, h
->root
.root
.string
, input_bfd
,
1645 input_section
, rel
->r_offset
, true)))
1648 fprintf (stderr
, "unknown: name: %s\n", h
->root
.root
.string
);
1654 /* FIXME: We should use the addend, but the COFF relocations don't. */
1655 r
= v850_elf_final_link_relocate (howto
, input_bfd
, output_bfd
,
1657 contents
, rel
->r_offset
,
1658 relocation
, rel
->r_addend
,
1659 info
, sec
, h
== NULL
);
1661 if (r
!= bfd_reloc_ok
)
1664 const char * msg
= (const char *)0;
1667 name
= h
->root
.root
.string
;
1670 name
= (bfd_elf_string_from_elf_section
1671 (input_bfd
, symtab_hdr
->sh_link
, sym
->st_name
));
1672 if (name
== NULL
|| *name
== '\0')
1673 name
= bfd_section_name (input_bfd
, sec
);
1678 case bfd_reloc_overflow
:
1679 if (! ((*info
->callbacks
->reloc_overflow
)
1680 (info
, name
, howto
->name
, (bfd_vma
) 0,
1681 input_bfd
, input_section
, rel
->r_offset
)))
1685 case bfd_reloc_undefined
:
1686 if (! ((*info
->callbacks
->undefined_symbol
)
1687 (info
, name
, input_bfd
, input_section
,
1688 rel
->r_offset
, true)))
1692 case bfd_reloc_outofrange
:
1693 msg
= _("internal error: out of range error");
1696 case bfd_reloc_notsupported
:
1697 msg
= _("internal error: unsupported relocation error");
1700 case bfd_reloc_dangerous
:
1701 msg
= _("internal error: dangerous relocation");
1704 case bfd_reloc_other
:
1705 msg
= _("could not locate special linker symbol __gp");
1708 case bfd_reloc_continue
:
1709 msg
= _("could not locate special linker symbol __ep");
1712 case (bfd_reloc_dangerous
+ 1):
1713 msg
= _("could not locate special linker symbol __ctbp");
1717 msg
= _("internal error: unknown error");
1721 if (!((*info
->callbacks
->warning
)
1722 (info
, msg
, name
, input_bfd
, input_section
,
1734 v850_elf_gc_sweep_hook (abfd
, info
, sec
, relocs
)
1735 bfd
*abfd ATTRIBUTE_UNUSED
;
1736 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1737 asection
*sec ATTRIBUTE_UNUSED
;
1738 const Elf_Internal_Rela
*relocs ATTRIBUTE_UNUSED
;
1740 /* No got and plt entries for v850-elf. */
1745 v850_elf_gc_mark_hook (abfd
, info
, rel
, h
, sym
)
1747 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1748 Elf_Internal_Rela
*rel
;
1749 struct elf_link_hash_entry
*h
;
1750 Elf_Internal_Sym
*sym
;
1754 switch (ELF32_R_TYPE (rel
->r_info
))
1756 case R_V850_GNU_VTINHERIT
:
1757 case R_V850_GNU_VTENTRY
:
1761 switch (h
->root
.type
)
1763 case bfd_link_hash_defined
:
1764 case bfd_link_hash_defweak
:
1765 return h
->root
.u
.def
.section
;
1767 case bfd_link_hash_common
:
1768 return h
->root
.u
.c
.p
->section
;
1777 return bfd_section_from_elf_index (abfd
, sym
->st_shndx
);
1783 /* Set the right machine number. */
1786 v850_elf_object_p (abfd
)
1789 switch (elf_elfheader (abfd
)->e_flags
& EF_V850_ARCH
)
1792 case E_V850_ARCH
: (void) bfd_default_set_arch_mach (abfd
, bfd_arch_v850
, 0); break;
1793 case E_V850E_ARCH
: (void) bfd_default_set_arch_mach (abfd
, bfd_arch_v850
, bfd_mach_v850e
); break;
1794 case E_V850EA_ARCH
: (void) bfd_default_set_arch_mach (abfd
, bfd_arch_v850
, bfd_mach_v850ea
); break;
1799 /* Store the machine number in the flags field. */
1802 v850_elf_final_write_processing (abfd
, linker
)
1804 boolean linker ATTRIBUTE_UNUSED
;
1808 switch (bfd_get_mach (abfd
))
1811 case 0: val
= E_V850_ARCH
; break;
1812 case bfd_mach_v850e
: val
= E_V850E_ARCH
; break;
1813 case bfd_mach_v850ea
: val
= E_V850EA_ARCH
; break;
1816 elf_elfheader (abfd
)->e_flags
&=~ EF_V850_ARCH
;
1817 elf_elfheader (abfd
)->e_flags
|= val
;
1820 /* Function to keep V850 specific file flags. */
1823 v850_elf_set_private_flags (abfd
, flags
)
1827 BFD_ASSERT (!elf_flags_init (abfd
)
1828 || elf_elfheader (abfd
)->e_flags
== flags
);
1830 elf_elfheader (abfd
)->e_flags
= flags
;
1831 elf_flags_init (abfd
) = true;
1835 /* Copy backend specific data from one object module to another. */
1838 v850_elf_copy_private_bfd_data (ibfd
, obfd
)
1842 if ( bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
1843 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
1846 BFD_ASSERT (!elf_flags_init (obfd
)
1847 || (elf_elfheader (obfd
)->e_flags
1848 == elf_elfheader (ibfd
)->e_flags
));
1850 elf_gp (obfd
) = elf_gp (ibfd
);
1851 elf_elfheader (obfd
)->e_flags
= elf_elfheader (ibfd
)->e_flags
;
1852 elf_flags_init (obfd
) = true;
1857 /* Merge backend specific data from an object file
1858 to the output object file when linking. */
1860 v850_elf_merge_private_bfd_data (ibfd
, obfd
)
1867 if ( bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
1868 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
1871 in_flags
= elf_elfheader (ibfd
)->e_flags
;
1872 out_flags
= elf_elfheader (obfd
)->e_flags
;
1874 if (! elf_flags_init (obfd
))
1876 /* If the input is the default architecture then do not
1877 bother setting the flags for the output architecture,
1878 instead allow future merges to do this. If no future
1879 merges ever set these flags then they will retain their
1880 unitialised values, which surprise surprise, correspond
1881 to the default values. */
1882 if (bfd_get_arch_info (ibfd
)->the_default
)
1885 elf_flags_init (obfd
) = true;
1886 elf_elfheader (obfd
)->e_flags
= in_flags
;
1888 if (bfd_get_arch (obfd
) == bfd_get_arch (ibfd
)
1889 && bfd_get_arch_info (obfd
)->the_default
)
1890 return bfd_set_arch_mach (obfd
, bfd_get_arch (ibfd
), bfd_get_mach (ibfd
));
1895 /* Check flag compatibility. */
1896 if (in_flags
== out_flags
)
1899 if ((in_flags
& EF_V850_ARCH
) != (out_flags
& EF_V850_ARCH
)
1900 && (in_flags
& EF_V850_ARCH
) != E_V850_ARCH
)
1901 _bfd_error_handler (_("%s: Architecture mismatch with previous modules"),
1902 bfd_archive_filename (ibfd
));
1907 /* Display the flags field. */
1910 v850_elf_print_private_bfd_data (abfd
, ptr
)
1914 FILE * file
= (FILE *) ptr
;
1916 BFD_ASSERT (abfd
!= NULL
&& ptr
!= NULL
);
1918 _bfd_elf_print_private_bfd_data (abfd
, ptr
);
1920 /* xgettext:c-format */
1921 fprintf (file
, _("private flags = %lx: "), elf_elfheader (abfd
)->e_flags
);
1923 switch (elf_elfheader (abfd
)->e_flags
& EF_V850_ARCH
)
1926 case E_V850_ARCH
: fprintf (file
, _("v850 architecture")); break;
1927 case E_V850E_ARCH
: fprintf (file
, _("v850e architecture")); break;
1928 case E_V850EA_ARCH
: fprintf (file
, _("v850ea architecture")); break;
1936 /* V850 ELF uses four common sections. One is the usual one, and the
1937 others are for (small) objects in one of the special data areas:
1938 small, tiny and zero. All the objects are kept together, and then
1939 referenced via the gp register, the ep register or the r0 register
1940 respectively, which yields smaller, faster assembler code. This
1941 approach is copied from elf32-mips.c. */
1943 static asection v850_elf_scom_section
;
1944 static asymbol v850_elf_scom_symbol
;
1945 static asymbol
* v850_elf_scom_symbol_ptr
;
1946 static asection v850_elf_tcom_section
;
1947 static asymbol v850_elf_tcom_symbol
;
1948 static asymbol
* v850_elf_tcom_symbol_ptr
;
1949 static asection v850_elf_zcom_section
;
1950 static asymbol v850_elf_zcom_symbol
;
1951 static asymbol
* v850_elf_zcom_symbol_ptr
;
1953 /* Given a BFD section, try to locate the
1954 corresponding ELF section index. */
1957 v850_elf_section_from_bfd_section (abfd
, hdr
, sec
, retval
)
1958 bfd
* abfd ATTRIBUTE_UNUSED
;
1959 Elf32_Internal_Shdr
* hdr ATTRIBUTE_UNUSED
;
1963 if (strcmp (bfd_get_section_name (abfd
, sec
), ".scommon") == 0)
1964 *retval
= SHN_V850_SCOMMON
;
1965 else if (strcmp (bfd_get_section_name (abfd
, sec
), ".tcommon") == 0)
1966 *retval
= SHN_V850_TCOMMON
;
1967 else if (strcmp (bfd_get_section_name (abfd
, sec
), ".zcommon") == 0)
1968 *retval
= SHN_V850_ZCOMMON
;
1975 /* Handle the special V850 section numbers that a symbol may use. */
1978 v850_elf_symbol_processing (abfd
, asym
)
1982 elf_symbol_type
* elfsym
= (elf_symbol_type
*) asym
;
1985 indx
= elfsym
->internal_elf_sym
.st_shndx
;
1987 /* If the section index is an "ordinary" index, then it may
1988 refer to a v850 specific section created by the assembler.
1989 Check the section's type and change the index it matches.
1991 FIXME: Should we alter the st_shndx field as well ? */
1993 if (indx
< elf_numsections (abfd
))
1994 switch (elf_elfsections(abfd
)[indx
]->sh_type
)
1996 case SHT_V850_SCOMMON
:
1997 indx
= SHN_V850_SCOMMON
;
2000 case SHT_V850_TCOMMON
:
2001 indx
= SHN_V850_TCOMMON
;
2004 case SHT_V850_ZCOMMON
:
2005 indx
= SHN_V850_ZCOMMON
;
2014 case SHN_V850_SCOMMON
:
2015 if (v850_elf_scom_section
.name
== NULL
)
2017 /* Initialize the small common section. */
2018 v850_elf_scom_section
.name
= ".scommon";
2019 v850_elf_scom_section
.flags
= SEC_IS_COMMON
| SEC_ALLOC
| SEC_DATA
;
2020 v850_elf_scom_section
.output_section
= & v850_elf_scom_section
;
2021 v850_elf_scom_section
.symbol
= & v850_elf_scom_symbol
;
2022 v850_elf_scom_section
.symbol_ptr_ptr
= & v850_elf_scom_symbol_ptr
;
2023 v850_elf_scom_symbol
.name
= ".scommon";
2024 v850_elf_scom_symbol
.flags
= BSF_SECTION_SYM
;
2025 v850_elf_scom_symbol
.section
= & v850_elf_scom_section
;
2026 v850_elf_scom_symbol_ptr
= & v850_elf_scom_symbol
;
2028 asym
->section
= & v850_elf_scom_section
;
2029 asym
->value
= elfsym
->internal_elf_sym
.st_size
;
2032 case SHN_V850_TCOMMON
:
2033 if (v850_elf_tcom_section
.name
== NULL
)
2035 /* Initialize the tcommon section. */
2036 v850_elf_tcom_section
.name
= ".tcommon";
2037 v850_elf_tcom_section
.flags
= SEC_IS_COMMON
;
2038 v850_elf_tcom_section
.output_section
= & v850_elf_tcom_section
;
2039 v850_elf_tcom_section
.symbol
= & v850_elf_tcom_symbol
;
2040 v850_elf_tcom_section
.symbol_ptr_ptr
= & v850_elf_tcom_symbol_ptr
;
2041 v850_elf_tcom_symbol
.name
= ".tcommon";
2042 v850_elf_tcom_symbol
.flags
= BSF_SECTION_SYM
;
2043 v850_elf_tcom_symbol
.section
= & v850_elf_tcom_section
;
2044 v850_elf_tcom_symbol_ptr
= & v850_elf_tcom_symbol
;
2046 asym
->section
= & v850_elf_tcom_section
;
2047 asym
->value
= elfsym
->internal_elf_sym
.st_size
;
2050 case SHN_V850_ZCOMMON
:
2051 if (v850_elf_zcom_section
.name
== NULL
)
2053 /* Initialize the zcommon section. */
2054 v850_elf_zcom_section
.name
= ".zcommon";
2055 v850_elf_zcom_section
.flags
= SEC_IS_COMMON
;
2056 v850_elf_zcom_section
.output_section
= & v850_elf_zcom_section
;
2057 v850_elf_zcom_section
.symbol
= & v850_elf_zcom_symbol
;
2058 v850_elf_zcom_section
.symbol_ptr_ptr
= & v850_elf_zcom_symbol_ptr
;
2059 v850_elf_zcom_symbol
.name
= ".zcommon";
2060 v850_elf_zcom_symbol
.flags
= BSF_SECTION_SYM
;
2061 v850_elf_zcom_symbol
.section
= & v850_elf_zcom_section
;
2062 v850_elf_zcom_symbol_ptr
= & v850_elf_zcom_symbol
;
2064 asym
->section
= & v850_elf_zcom_section
;
2065 asym
->value
= elfsym
->internal_elf_sym
.st_size
;
2070 /* Hook called by the linker routine which adds symbols from an object
2071 file. We must handle the special v850 section numbers here. */
2074 v850_elf_add_symbol_hook (abfd
, info
, sym
, namep
, flagsp
, secp
, valp
)
2076 struct bfd_link_info
* info ATTRIBUTE_UNUSED
;
2077 const Elf_Internal_Sym
* sym
;
2078 const char ** namep ATTRIBUTE_UNUSED
;
2079 flagword
* flagsp ATTRIBUTE_UNUSED
;
2083 unsigned int indx
= sym
->st_shndx
;
2085 /* If the section index is an "ordinary" index, then it may
2086 refer to a v850 specific section created by the assembler.
2087 Check the section's type and change the index it matches.
2089 FIXME: Should we alter the st_shndx field as well ? */
2091 if (indx
< elf_numsections (abfd
))
2092 switch (elf_elfsections(abfd
)[indx
]->sh_type
)
2094 case SHT_V850_SCOMMON
:
2095 indx
= SHN_V850_SCOMMON
;
2098 case SHT_V850_TCOMMON
:
2099 indx
= SHN_V850_TCOMMON
;
2102 case SHT_V850_ZCOMMON
:
2103 indx
= SHN_V850_ZCOMMON
;
2112 case SHN_V850_SCOMMON
:
2113 *secp
= bfd_make_section_old_way (abfd
, ".scommon");
2114 (*secp
)->flags
|= SEC_IS_COMMON
;
2115 *valp
= sym
->st_size
;
2118 case SHN_V850_TCOMMON
:
2119 *secp
= bfd_make_section_old_way (abfd
, ".tcommon");
2120 (*secp
)->flags
|= SEC_IS_COMMON
;
2121 *valp
= sym
->st_size
;
2124 case SHN_V850_ZCOMMON
:
2125 *secp
= bfd_make_section_old_way (abfd
, ".zcommon");
2126 (*secp
)->flags
|= SEC_IS_COMMON
;
2127 *valp
= sym
->st_size
;
2135 v850_elf_link_output_symbol_hook (abfd
, info
, name
, sym
, input_sec
)
2136 bfd
* abfd ATTRIBUTE_UNUSED
;
2137 struct bfd_link_info
* info ATTRIBUTE_UNUSED
;
2138 const char * name ATTRIBUTE_UNUSED
;
2139 Elf_Internal_Sym
* sym
;
2140 asection
* input_sec
;
2142 /* If we see a common symbol, which implies a relocatable link, then
2143 if a symbol was in a special common section in an input file, mark
2144 it as a special common in the output file. */
2146 if (sym
->st_shndx
== SHN_COMMON
)
2148 if (strcmp (input_sec
->name
, ".scommon") == 0)
2149 sym
->st_shndx
= SHN_V850_SCOMMON
;
2150 else if (strcmp (input_sec
->name
, ".tcommon") == 0)
2151 sym
->st_shndx
= SHN_V850_TCOMMON
;
2152 else if (strcmp (input_sec
->name
, ".zcommon") == 0)
2153 sym
->st_shndx
= SHN_V850_ZCOMMON
;
2160 v850_elf_section_from_shdr (abfd
, hdr
, name
)
2162 Elf_Internal_Shdr
* hdr
;
2165 /* There ought to be a place to keep ELF backend specific flags, but
2166 at the moment there isn't one. We just keep track of the
2167 sections by their name, instead. */
2169 if (! _bfd_elf_make_section_from_shdr (abfd
, hdr
, name
))
2172 switch (hdr
->sh_type
)
2174 case SHT_V850_SCOMMON
:
2175 case SHT_V850_TCOMMON
:
2176 case SHT_V850_ZCOMMON
:
2177 if (! bfd_set_section_flags (abfd
, hdr
->bfd_section
,
2178 (bfd_get_section_flags (abfd
,
2187 /* Set the correct type for a V850 ELF section. We do this
2188 by the section name, which is a hack, but ought to work. */
2191 v850_elf_fake_sections (abfd
, hdr
, sec
)
2192 bfd
* abfd ATTRIBUTE_UNUSED
;
2193 Elf32_Internal_Shdr
* hdr
;
2196 register const char * name
;
2198 name
= bfd_get_section_name (abfd
, sec
);
2200 if (strcmp (name
, ".scommon") == 0)
2202 hdr
->sh_type
= SHT_V850_SCOMMON
;
2204 else if (strcmp (name
, ".tcommon") == 0)
2206 hdr
->sh_type
= SHT_V850_TCOMMON
;
2208 else if (strcmp (name
, ".zcommon") == 0)
2209 hdr
->sh_type
= SHT_V850_ZCOMMON
;
2214 #define TARGET_LITTLE_SYM bfd_elf32_v850_vec
2215 #define TARGET_LITTLE_NAME "elf32-v850"
2216 #define ELF_ARCH bfd_arch_v850
2217 #define ELF_MACHINE_CODE EM_V850
2218 #define ELF_MACHINE_ALT1 EM_CYGNUS_V850
2219 #define ELF_MAXPAGESIZE 0x1000
2221 #define elf_info_to_howto v850_elf_info_to_howto_rela
2222 #define elf_info_to_howto_rel v850_elf_info_to_howto_rel
2224 #define elf_backend_check_relocs v850_elf_check_relocs
2225 #define elf_backend_relocate_section v850_elf_relocate_section
2226 #define elf_backend_object_p v850_elf_object_p
2227 #define elf_backend_final_write_processing v850_elf_final_write_processing
2228 #define elf_backend_section_from_bfd_section v850_elf_section_from_bfd_section
2229 #define elf_backend_symbol_processing v850_elf_symbol_processing
2230 #define elf_backend_add_symbol_hook v850_elf_add_symbol_hook
2231 #define elf_backend_link_output_symbol_hook v850_elf_link_output_symbol_hook
2232 #define elf_backend_section_from_shdr v850_elf_section_from_shdr
2233 #define elf_backend_fake_sections v850_elf_fake_sections
2234 #define elf_backend_gc_mark_hook v850_elf_gc_mark_hook
2235 #define elf_backend_gc_sweep_hook v850_elf_gc_sweep_hook
2237 #define elf_backend_can_gc_sections 1
2239 #define bfd_elf32_bfd_is_local_label_name v850_elf_is_local_label_name
2240 #define bfd_elf32_bfd_reloc_type_lookup v850_elf_reloc_type_lookup
2241 #define bfd_elf32_bfd_copy_private_bfd_data v850_elf_copy_private_bfd_data
2242 #define bfd_elf32_bfd_merge_private_bfd_data v850_elf_merge_private_bfd_data
2243 #define bfd_elf32_bfd_set_private_flags v850_elf_set_private_flags
2244 #define bfd_elf32_bfd_print_private_bfd_data v850_elf_print_private_bfd_data
2246 #define elf_symbol_leading_char '_'
2248 #include "elf32-target.h"