elf32-d10v.c revision 1.1 1 1.1 christos /* D10V-specific support for 32-bit ELF
2 1.1 christos Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
3 1.1 christos 2007, 2010, 2012 Free Software Foundation, Inc.
4 1.1 christos Contributed by Martin Hunt (hunt (at) cygnus.com).
5 1.1 christos
6 1.1 christos This file is part of BFD, the Binary File Descriptor library.
7 1.1 christos
8 1.1 christos This program is free software; you can redistribute it and/or modify
9 1.1 christos it under the terms of the GNU General Public License as published by
10 1.1 christos the Free Software Foundation; either version 3 of the License, or
11 1.1 christos (at your option) any later version.
12 1.1 christos
13 1.1 christos This program is distributed in the hope that it will be useful,
14 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
15 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 1.1 christos GNU General Public License for more details.
17 1.1 christos
18 1.1 christos You should have received a copy of the GNU General Public License
19 1.1 christos along with this program; if not, write to the Free Software
20 1.1 christos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 1.1 christos MA 02110-1301, USA. */
22 1.1 christos
23 1.1 christos #include "sysdep.h"
24 1.1 christos #include "bfd.h"
25 1.1 christos #include "libbfd.h"
26 1.1 christos #include "elf-bfd.h"
27 1.1 christos #include "elf/d10v.h"
28 1.1 christos
29 1.1 christos /* Use REL instead of RELA to save space. */
30 1.1 christos #define USE_REL 1
31 1.1 christos
32 1.1 christos static reloc_howto_type elf_d10v_howto_table[] =
33 1.1 christos {
34 1.1 christos /* This reloc does nothing. */
35 1.1 christos HOWTO (R_D10V_NONE, /* Type. */
36 1.1 christos 0, /* Rightshift. */
37 1.1 christos 2, /* Size (0 = byte, 1 = short, 2 = long). */
38 1.1 christos 32, /* Bitsize. */
39 1.1 christos FALSE, /* PC_relative. */
40 1.1 christos 0, /* Bitpos. */
41 1.1 christos complain_overflow_dont,/* Complain_on_overflow. */
42 1.1 christos bfd_elf_generic_reloc, /* Special_function. */
43 1.1 christos "R_D10V_NONE", /* Name. */
44 1.1 christos FALSE, /* Partial_inplace. */
45 1.1 christos 0, /* Src_mask. */
46 1.1 christos 0, /* Dst_mask. */
47 1.1 christos FALSE), /* PCrel_offset. */
48 1.1 christos
49 1.1 christos /* An PC Relative 10-bit relocation, shifted by 2, right container. */
50 1.1 christos HOWTO (R_D10V_10_PCREL_R, /* Type. */
51 1.1 christos 2, /* Rightshift. */
52 1.1 christos 2, /* Size (0 = byte, 1 = short, 2 = long). */
53 1.1 christos 8, /* Bitsize. */
54 1.1 christos TRUE, /* PC_relative. */
55 1.1 christos 0, /* Bitpos. */
56 1.1 christos complain_overflow_signed, /* Complain_on_overflow. */
57 1.1 christos bfd_elf_generic_reloc, /* Special_function. */
58 1.1 christos "R_D10V_10_PCREL_R", /* Name. */
59 1.1 christos FALSE, /* Partial_inplace. */
60 1.1 christos 0xff, /* Src_mask. */
61 1.1 christos 0xff, /* Dst_mask. */
62 1.1 christos TRUE), /* PCrel_offset. */
63 1.1 christos
64 1.1 christos /* An PC Relative 10-bit relocation, shifted by 2, left container. */
65 1.1 christos HOWTO (R_D10V_10_PCREL_L, /* Type. */
66 1.1 christos 2, /* Rightshift. */
67 1.1 christos 2, /* Size (0 = byte, 1 = short, 2 = long). */
68 1.1 christos 8, /* Bitsize. */
69 1.1 christos TRUE, /* PC_relative. */
70 1.1 christos 15, /* Bitpos. */
71 1.1 christos complain_overflow_signed, /* Complain_on_overflow. */
72 1.1 christos bfd_elf_generic_reloc, /* Special_function. */
73 1.1 christos "R_D10V_10_PCREL_L", /* Name. */
74 1.1 christos FALSE, /* Partial_inplace. */
75 1.1 christos 0x07f8000, /* Src_mask. */
76 1.1 christos 0x07f8000, /* Dst_mask. */
77 1.1 christos TRUE), /* PCrel_offset. */
78 1.1 christos
79 1.1 christos /* A 16 bit absolute relocation. */
80 1.1 christos HOWTO (R_D10V_16, /* Type. */
81 1.1 christos 0, /* Rightshift. */
82 1.1 christos 1, /* Size (0 = byte, 1 = short, 2 = long). */
83 1.1 christos 16, /* Bitsize. */
84 1.1 christos FALSE, /* PC_relative. */
85 1.1 christos 0, /* Bitpos. */
86 1.1 christos complain_overflow_dont,/* Complain_on_overflow. */
87 1.1 christos bfd_elf_generic_reloc, /* Special_function. */
88 1.1 christos "R_D10V_16", /* Name. */
89 1.1 christos FALSE, /* Partial_inplace. */
90 1.1 christos 0xffff, /* Src_mask. */
91 1.1 christos 0xffff, /* Dst_mask. */
92 1.1 christos FALSE), /* PCrel_offset. */
93 1.1 christos
94 1.1 christos /* An 18 bit absolute relocation, right shifted 2. */
95 1.1 christos HOWTO (R_D10V_18, /* Type. */
96 1.1 christos 2, /* Rightshift. */
97 1.1 christos 1, /* Size (0 = byte, 1 = short, 2 = long). */
98 1.1 christos 16, /* Bitsize. */
99 1.1 christos FALSE, /* PC_relative. */
100 1.1 christos 0, /* Bitpos. */
101 1.1 christos complain_overflow_dont, /* Complain_on_overflow. */
102 1.1 christos bfd_elf_generic_reloc, /* Special_function. */
103 1.1 christos "R_D10V_18", /* Name. */
104 1.1 christos FALSE, /* Partial_inplace. */
105 1.1 christos 0xffff, /* Src_mask. */
106 1.1 christos 0xffff, /* Dst_mask. */
107 1.1 christos FALSE), /* PCrel_offset. */
108 1.1 christos
109 1.1 christos /* A relative 18 bit relocation, right shifted by 2. */
110 1.1 christos HOWTO (R_D10V_18_PCREL, /* Type. */
111 1.1 christos 2, /* Rightshift. */
112 1.1 christos 2, /* Size (0 = byte, 1 = short, 2 = long). */
113 1.1 christos 16, /* Bitsize. */
114 1.1 christos TRUE, /* PC_relative. */
115 1.1 christos 0, /* Bitpos. */
116 1.1 christos complain_overflow_signed, /* Complain_on_overflow. */
117 1.1 christos bfd_elf_generic_reloc, /* Special_function. */
118 1.1 christos "R_D10V_18_PCREL", /* Name. */
119 1.1 christos FALSE, /* Partial_inplace. */
120 1.1 christos 0xffff, /* Src_mask. */
121 1.1 christos 0xffff, /* Dst_mask. */
122 1.1 christos TRUE), /* PCrel_offset. */
123 1.1 christos
124 1.1 christos /* A 32 bit absolute relocation. */
125 1.1 christos HOWTO (R_D10V_32, /* Type. */
126 1.1 christos 0, /* Rightshift. */
127 1.1 christos 2, /* Size (0 = byte, 1 = short, 2 = long). */
128 1.1 christos 32, /* Bitsize. */
129 1.1 christos FALSE, /* PC_relative. */
130 1.1 christos 0, /* Bitpos. */
131 1.1 christos complain_overflow_dont,/* Complain_on_overflow. */
132 1.1 christos bfd_elf_generic_reloc, /* Special_function. */
133 1.1 christos "R_D10V_32", /* Name. */
134 1.1 christos FALSE, /* Partial_inplace. */
135 1.1 christos 0xffffffff, /* Src_mask. */
136 1.1 christos 0xffffffff, /* Dst_mask. */
137 1.1 christos FALSE), /* PCrel_offset. */
138 1.1 christos
139 1.1 christos /* GNU extension to record C++ vtable hierarchy. */
140 1.1 christos HOWTO (R_D10V_GNU_VTINHERIT, /* Type. */
141 1.1 christos 0, /* Rightshift. */
142 1.1 christos 2, /* Size (0 = byte, 1 = short, 2 = long). */
143 1.1 christos 0, /* Bitsize. */
144 1.1 christos FALSE, /* PC_relative. */
145 1.1 christos 0, /* Bitpos. */
146 1.1 christos complain_overflow_dont,/* Complain_on_overflow. */
147 1.1 christos NULL, /* Special_function. */
148 1.1 christos "R_D10V_GNU_VTINHERIT",/* Name. */
149 1.1 christos FALSE, /* Partial_inplace. */
150 1.1 christos 0, /* Src_mask. */
151 1.1 christos 0, /* Dst_mask. */
152 1.1 christos FALSE), /* PCrel_offset. */
153 1.1 christos
154 1.1 christos /* GNU extension to record C++ vtable member usage. */
155 1.1 christos HOWTO (R_D10V_GNU_VTENTRY, /* Type. */
156 1.1 christos 0, /* Rightshift. */
157 1.1 christos 2, /* Size (0 = byte, 1 = short, 2 = long). */
158 1.1 christos 0, /* Bitsize. */
159 1.1 christos FALSE, /* PC_relative. */
160 1.1 christos 0, /* Bitpos. */
161 1.1 christos complain_overflow_dont,/* Complain_on_overflow. */
162 1.1 christos _bfd_elf_rel_vtable_reloc_fn, /* Special_function. */
163 1.1 christos "R_D10V_GNU_VTENTRY", /* Name. */
164 1.1 christos FALSE, /* Partial_inplace. */
165 1.1 christos 0, /* Src_mask. */
166 1.1 christos 0, /* Dst_mask. */
167 1.1 christos FALSE), /* PCrel_offset. */
168 1.1 christos };
169 1.1 christos
170 1.1 christos /* Map BFD reloc types to D10V ELF reloc types. */
171 1.1 christos
172 1.1 christos struct d10v_reloc_map
173 1.1 christos {
174 1.1 christos bfd_reloc_code_real_type bfd_reloc_val;
175 1.1 christos unsigned char elf_reloc_val;
176 1.1 christos };
177 1.1 christos
178 1.1 christos static const struct d10v_reloc_map d10v_reloc_map[] =
179 1.1 christos {
180 1.1 christos { BFD_RELOC_NONE, R_D10V_NONE, },
181 1.1 christos { BFD_RELOC_D10V_10_PCREL_R, R_D10V_10_PCREL_R },
182 1.1 christos { BFD_RELOC_D10V_10_PCREL_L, R_D10V_10_PCREL_L },
183 1.1 christos { BFD_RELOC_16, R_D10V_16 },
184 1.1 christos { BFD_RELOC_D10V_18, R_D10V_18 },
185 1.1 christos { BFD_RELOC_D10V_18_PCREL, R_D10V_18_PCREL },
186 1.1 christos { BFD_RELOC_32, R_D10V_32 },
187 1.1 christos { BFD_RELOC_VTABLE_INHERIT, R_D10V_GNU_VTINHERIT },
188 1.1 christos { BFD_RELOC_VTABLE_ENTRY, R_D10V_GNU_VTENTRY },
189 1.1 christos };
190 1.1 christos
191 1.1 christos static reloc_howto_type *
192 1.1 christos bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
193 1.1 christos bfd_reloc_code_real_type code)
194 1.1 christos {
195 1.1 christos unsigned int i;
196 1.1 christos
197 1.1 christos for (i = 0;
198 1.1 christos i < sizeof (d10v_reloc_map) / sizeof (struct d10v_reloc_map);
199 1.1 christos i++)
200 1.1 christos if (d10v_reloc_map[i].bfd_reloc_val == code)
201 1.1 christos return &elf_d10v_howto_table[d10v_reloc_map[i].elf_reloc_val];
202 1.1 christos
203 1.1 christos return NULL;
204 1.1 christos }
205 1.1 christos
206 1.1 christos static reloc_howto_type *
207 1.1 christos bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
208 1.1 christos const char *r_name)
209 1.1 christos {
210 1.1 christos unsigned int i;
211 1.1 christos
212 1.1 christos for (i = 0;
213 1.1 christos i < sizeof (elf_d10v_howto_table) / sizeof (elf_d10v_howto_table[0]);
214 1.1 christos i++)
215 1.1 christos if (elf_d10v_howto_table[i].name != NULL
216 1.1 christos && strcasecmp (elf_d10v_howto_table[i].name, r_name) == 0)
217 1.1 christos return &elf_d10v_howto_table[i];
218 1.1 christos
219 1.1 christos return NULL;
220 1.1 christos }
221 1.1 christos
222 1.1 christos /* Set the howto pointer for an D10V ELF reloc. */
223 1.1 christos
224 1.1 christos static void
225 1.1 christos d10v_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
226 1.1 christos arelent *cache_ptr,
227 1.1 christos Elf_Internal_Rela *dst)
228 1.1 christos {
229 1.1 christos unsigned int r_type;
230 1.1 christos
231 1.1 christos r_type = ELF32_R_TYPE (dst->r_info);
232 1.1 christos BFD_ASSERT (r_type < (unsigned int) R_D10V_max);
233 1.1 christos cache_ptr->howto = &elf_d10v_howto_table[r_type];
234 1.1 christos }
235 1.1 christos
236 1.1 christos static asection *
237 1.1 christos elf32_d10v_gc_mark_hook (asection *sec,
238 1.1 christos struct bfd_link_info *info,
239 1.1 christos Elf_Internal_Rela *rel,
240 1.1 christos struct elf_link_hash_entry *h,
241 1.1 christos Elf_Internal_Sym *sym)
242 1.1 christos {
243 1.1 christos if (h != NULL)
244 1.1 christos switch (ELF32_R_TYPE (rel->r_info))
245 1.1 christos {
246 1.1 christos case R_D10V_GNU_VTINHERIT:
247 1.1 christos case R_D10V_GNU_VTENTRY:
248 1.1 christos return NULL;
249 1.1 christos }
250 1.1 christos
251 1.1 christos return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
252 1.1 christos }
253 1.1 christos
254 1.1 christos /* Look through the relocs for a section during the first phase.
255 1.1 christos Since we don't do .gots or .plts, we just need to consider the
256 1.1 christos virtual table relocs for gc. */
257 1.1 christos
258 1.1 christos static bfd_boolean
259 1.1 christos elf32_d10v_check_relocs (bfd *abfd,
260 1.1 christos struct bfd_link_info *info,
261 1.1 christos asection *sec,
262 1.1 christos const Elf_Internal_Rela *relocs)
263 1.1 christos {
264 1.1 christos Elf_Internal_Shdr *symtab_hdr;
265 1.1 christos struct elf_link_hash_entry **sym_hashes;
266 1.1 christos const Elf_Internal_Rela *rel;
267 1.1 christos const Elf_Internal_Rela *rel_end;
268 1.1 christos
269 1.1 christos if (info->relocatable)
270 1.1 christos return TRUE;
271 1.1 christos
272 1.1 christos symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
273 1.1 christos sym_hashes = elf_sym_hashes (abfd);
274 1.1 christos
275 1.1 christos rel_end = relocs + sec->reloc_count;
276 1.1 christos for (rel = relocs; rel < rel_end; rel++)
277 1.1 christos {
278 1.1 christos struct elf_link_hash_entry *h;
279 1.1 christos unsigned long r_symndx;
280 1.1 christos
281 1.1 christos r_symndx = ELF32_R_SYM (rel->r_info);
282 1.1 christos if (r_symndx < symtab_hdr->sh_info)
283 1.1 christos h = NULL;
284 1.1 christos else
285 1.1 christos {
286 1.1 christos h = sym_hashes[r_symndx - symtab_hdr->sh_info];
287 1.1 christos while (h->root.type == bfd_link_hash_indirect
288 1.1 christos || h->root.type == bfd_link_hash_warning)
289 1.1 christos h = (struct elf_link_hash_entry *) h->root.u.i.link;
290 1.1 christos }
291 1.1 christos
292 1.1 christos switch (ELF32_R_TYPE (rel->r_info))
293 1.1 christos {
294 1.1 christos /* This relocation describes the C++ object vtable hierarchy.
295 1.1 christos Reconstruct it for later use during GC. */
296 1.1 christos case R_D10V_GNU_VTINHERIT:
297 1.1 christos if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
298 1.1 christos return FALSE;
299 1.1 christos break;
300 1.1 christos
301 1.1 christos /* This relocation describes which C++ vtable entries are actually
302 1.1 christos used. Record for later use during GC. */
303 1.1 christos case R_D10V_GNU_VTENTRY:
304 1.1 christos BFD_ASSERT (h != NULL);
305 1.1 christos if (h != NULL
306 1.1 christos && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
307 1.1 christos return FALSE;
308 1.1 christos break;
309 1.1 christos }
310 1.1 christos }
311 1.1 christos
312 1.1 christos return TRUE;
313 1.1 christos }
314 1.1 christos
315 1.1 christos static bfd_vma
316 1.1 christos extract_rel_addend (bfd *abfd,
317 1.1 christos bfd_byte *where,
318 1.1 christos reloc_howto_type *howto)
319 1.1 christos {
320 1.1 christos bfd_vma insn, val;
321 1.1 christos
322 1.1 christos switch (howto->size)
323 1.1 christos {
324 1.1 christos case 0:
325 1.1 christos insn = bfd_get_8 (abfd, where);
326 1.1 christos break;
327 1.1 christos case 1:
328 1.1 christos insn = bfd_get_16 (abfd, where);
329 1.1 christos break;
330 1.1 christos case 2:
331 1.1 christos insn = bfd_get_32 (abfd, where);
332 1.1 christos break;
333 1.1 christos default:
334 1.1 christos abort ();
335 1.1 christos }
336 1.1 christos
337 1.1 christos val = (insn & howto->dst_mask) >> howto->bitpos << howto->rightshift;
338 1.1 christos /* We should really be testing for signed addends here, but we don't
339 1.1 christos have that info directly in the howto. */
340 1.1 christos if (howto->pc_relative)
341 1.1 christos {
342 1.1 christos bfd_vma sign;
343 1.1 christos sign = howto->dst_mask & (~howto->dst_mask >> 1 | ~(-(bfd_vma) 1 >> 1));
344 1.1 christos sign = sign >> howto->bitpos << howto->rightshift;
345 1.1 christos val = (val ^ sign) - sign;
346 1.1 christos }
347 1.1 christos return val;
348 1.1 christos }
349 1.1 christos
350 1.1 christos static void
351 1.1 christos insert_rel_addend (bfd *abfd,
352 1.1 christos bfd_byte *where,
353 1.1 christos reloc_howto_type *howto,
354 1.1 christos bfd_vma addend)
355 1.1 christos {
356 1.1 christos bfd_vma insn;
357 1.1 christos
358 1.1 christos addend = (addend >> howto->rightshift << howto->bitpos) & howto->dst_mask;
359 1.1 christos insn = ~howto->dst_mask;
360 1.1 christos switch (howto->size)
361 1.1 christos {
362 1.1 christos case 0:
363 1.1 christos insn &= bfd_get_8 (abfd, where);
364 1.1 christos insn |= addend;
365 1.1 christos bfd_put_8 (abfd, insn, where);
366 1.1 christos break;
367 1.1 christos case 1:
368 1.1 christos insn &= bfd_get_16 (abfd, where);
369 1.1 christos insn |= addend;
370 1.1 christos bfd_put_16 (abfd, insn, where);
371 1.1 christos break;
372 1.1 christos case 2:
373 1.1 christos insn &= bfd_get_32 (abfd, where);
374 1.1 christos insn |= addend;
375 1.1 christos bfd_put_32 (abfd, insn, where);
376 1.1 christos break;
377 1.1 christos default:
378 1.1 christos abort ();
379 1.1 christos }
380 1.1 christos }
381 1.1 christos
382 1.1 christos /* Relocate a D10V ELF section. */
383 1.1 christos
384 1.1 christos static bfd_boolean
385 1.1 christos elf32_d10v_relocate_section (bfd *output_bfd,
386 1.1 christos struct bfd_link_info *info,
387 1.1 christos bfd *input_bfd,
388 1.1 christos asection *input_section,
389 1.1 christos bfd_byte *contents,
390 1.1 christos Elf_Internal_Rela *relocs,
391 1.1 christos Elf_Internal_Sym *local_syms,
392 1.1 christos asection **local_sections)
393 1.1 christos {
394 1.1 christos Elf_Internal_Shdr *symtab_hdr;
395 1.1 christos struct elf_link_hash_entry **sym_hashes;
396 1.1 christos Elf_Internal_Rela *rel, *relend;
397 1.1 christos const char *name;
398 1.1 christos
399 1.1 christos symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
400 1.1 christos sym_hashes = elf_sym_hashes (input_bfd);
401 1.1 christos
402 1.1 christos rel = relocs;
403 1.1 christos relend = relocs + input_section->reloc_count;
404 1.1 christos for (; rel < relend; rel++)
405 1.1 christos {
406 1.1 christos int r_type;
407 1.1 christos reloc_howto_type *howto;
408 1.1 christos unsigned long r_symndx;
409 1.1 christos Elf_Internal_Sym *sym;
410 1.1 christos asection *sec;
411 1.1 christos struct elf_link_hash_entry *h;
412 1.1 christos bfd_vma relocation;
413 1.1 christos bfd_reloc_status_type r;
414 1.1 christos
415 1.1 christos r_symndx = ELF32_R_SYM (rel->r_info);
416 1.1 christos r_type = ELF32_R_TYPE (rel->r_info);
417 1.1 christos
418 1.1 christos if (r_type == R_D10V_GNU_VTENTRY
419 1.1 christos || r_type == R_D10V_GNU_VTINHERIT)
420 1.1 christos continue;
421 1.1 christos
422 1.1 christos howto = elf_d10v_howto_table + r_type;
423 1.1 christos h = NULL;
424 1.1 christos sym = NULL;
425 1.1 christos sec = NULL;
426 1.1 christos if (r_symndx < symtab_hdr->sh_info)
427 1.1 christos {
428 1.1 christos sym = local_syms + r_symndx;
429 1.1 christos sec = local_sections[r_symndx];
430 1.1 christos relocation = (sec->output_section->vma
431 1.1 christos + sec->output_offset
432 1.1 christos + sym->st_value);
433 1.1 christos if (ELF_ST_TYPE (sym->st_info) == STT_SECTION
434 1.1 christos && ((sec->flags & SEC_MERGE) != 0
435 1.1 christos || (info->relocatable
436 1.1 christos && sec->output_offset != 0)))
437 1.1 christos {
438 1.1 christos bfd_vma addend;
439 1.1 christos bfd_byte *where = contents + rel->r_offset;
440 1.1 christos
441 1.1 christos addend = extract_rel_addend (input_bfd, where, howto);
442 1.1 christos
443 1.1 christos if (info->relocatable)
444 1.1 christos addend += sec->output_offset;
445 1.1 christos else
446 1.1 christos {
447 1.1 christos asection *msec = sec;
448 1.1 christos addend = _bfd_elf_rel_local_sym (output_bfd, sym, &msec,
449 1.1 christos addend);
450 1.1 christos addend -= relocation;
451 1.1 christos addend += msec->output_section->vma + msec->output_offset;
452 1.1 christos }
453 1.1 christos insert_rel_addend (input_bfd, where, howto, addend);
454 1.1 christos }
455 1.1 christos }
456 1.1 christos else
457 1.1 christos {
458 1.1 christos bfd_boolean unresolved_reloc, warned;
459 1.1 christos
460 1.1 christos RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
461 1.1 christos r_symndx, symtab_hdr, sym_hashes,
462 1.1 christos h, sec, relocation,
463 1.1 christos unresolved_reloc, warned);
464 1.1 christos }
465 1.1 christos
466 1.1 christos if (sec != NULL && discarded_section (sec))
467 1.1 christos RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
468 1.1 christos rel, 1, relend, howto, 0, contents);
469 1.1 christos
470 1.1 christos if (info->relocatable)
471 1.1 christos continue;
472 1.1 christos
473 1.1 christos if (h != NULL)
474 1.1 christos name = h->root.root.string;
475 1.1 christos else
476 1.1 christos {
477 1.1 christos name = (bfd_elf_string_from_elf_section
478 1.1 christos (input_bfd, symtab_hdr->sh_link, sym->st_name));
479 1.1 christos if (name == NULL || *name == '\0')
480 1.1 christos name = bfd_section_name (input_bfd, sec);
481 1.1 christos }
482 1.1 christos
483 1.1 christos r = _bfd_final_link_relocate (howto, input_bfd, input_section,
484 1.1 christos contents, rel->r_offset,
485 1.1 christos relocation, (bfd_vma) 0);
486 1.1 christos
487 1.1 christos if (r != bfd_reloc_ok)
488 1.1 christos {
489 1.1 christos const char * msg = (const char *) 0;
490 1.1 christos
491 1.1 christos switch (r)
492 1.1 christos {
493 1.1 christos case bfd_reloc_overflow:
494 1.1 christos if (!((*info->callbacks->reloc_overflow)
495 1.1 christos (info, (h ? &h->root : NULL), name, howto->name,
496 1.1 christos (bfd_vma) 0, input_bfd, input_section,
497 1.1 christos rel->r_offset)))
498 1.1 christos return FALSE;
499 1.1 christos break;
500 1.1 christos
501 1.1 christos case bfd_reloc_undefined:
502 1.1 christos if (!((*info->callbacks->undefined_symbol)
503 1.1 christos (info, name, input_bfd, input_section,
504 1.1 christos rel->r_offset, TRUE)))
505 1.1 christos return FALSE;
506 1.1 christos break;
507 1.1 christos
508 1.1 christos case bfd_reloc_outofrange:
509 1.1 christos msg = _("internal error: out of range error");
510 1.1 christos goto common_error;
511 1.1 christos
512 1.1 christos case bfd_reloc_notsupported:
513 1.1 christos msg = _("internal error: unsupported relocation error");
514 1.1 christos goto common_error;
515 1.1 christos
516 1.1 christos case bfd_reloc_dangerous:
517 1.1 christos msg = _("internal error: dangerous error");
518 1.1 christos goto common_error;
519 1.1 christos
520 1.1 christos default:
521 1.1 christos msg = _("internal error: unknown error");
522 1.1 christos /* fall through */
523 1.1 christos
524 1.1 christos common_error:
525 1.1 christos if (!((*info->callbacks->warning)
526 1.1 christos (info, msg, name, input_bfd, input_section,
527 1.1 christos rel->r_offset)))
528 1.1 christos return FALSE;
529 1.1 christos break;
530 1.1 christos }
531 1.1 christos }
532 1.1 christos }
533 1.1 christos
534 1.1 christos return TRUE;
535 1.1 christos }
536 1.1 christos #define ELF_ARCH bfd_arch_d10v
537 1.1 christos #define ELF_MACHINE_CODE EM_D10V
538 1.1 christos #define ELF_MACHINE_ALT1 EM_CYGNUS_D10V
539 1.1 christos #define ELF_MAXPAGESIZE 0x1000
540 1.1 christos
541 1.1 christos #define TARGET_BIG_SYM bfd_elf32_d10v_vec
542 1.1 christos #define TARGET_BIG_NAME "elf32-d10v"
543 1.1 christos
544 1.1 christos #define elf_info_to_howto 0
545 1.1 christos #define elf_info_to_howto_rel d10v_info_to_howto_rel
546 1.1 christos #define elf_backend_object_p 0
547 1.1 christos #define elf_backend_final_write_processing 0
548 1.1 christos #define elf_backend_gc_mark_hook elf32_d10v_gc_mark_hook
549 1.1 christos #define elf_backend_check_relocs elf32_d10v_check_relocs
550 1.1 christos #define elf_backend_relocate_section elf32_d10v_relocate_section
551 1.1 christos #define elf_backend_can_gc_sections 1
552 1.1 christos
553 1.1 christos #include "elf32-target.h"
554