* cris.h: Add leading comment about PC-relative location.
[deliverable/binutils-gdb.git] / bfd / elf32-cris.c
CommitLineData
06c15ad7 1/* CRIS-specific support for 32-bit ELF.
7898deda 2 Copyright 2000 Free Software Foundation, Inc.
06c15ad7
HPN
3 Contributed by Axis Communications AB.
4 Written by Hans-Peter Nilsson, based on elf32-fr30.c
5
6This file is part of BFD, the Binary File Descriptor library.
7
8This program is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21
22#include "bfd.h"
23#include "sysdep.h"
24#include "libbfd.h"
25#include "elf-bfd.h"
26#include "elf/cris.h"
27
28/* Forward declarations. */
29static reloc_howto_type * cris_reloc_type_lookup
30 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
31
a7c10850 32static void cris_info_to_howto_rela
06c15ad7
HPN
33 PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
34
a7c10850 35static boolean cris_elf_relocate_section
06c15ad7
HPN
36 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
37 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
38
39static bfd_reloc_status_type cris_final_link_relocate
40 PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
41 Elf_Internal_Rela *, bfd_vma));
42
43static boolean cris_elf_gc_sweep_hook
44 PARAMS ((bfd *, struct bfd_link_info *, asection *,
45 const Elf_Internal_Rela *));
46
47static asection * cris_elf_gc_mark_hook
48 PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
49 struct elf_link_hash_entry *, Elf_Internal_Sym *));
50
4da81684
HPN
51static boolean cris_elf_object_p PARAMS ((bfd *));
52
53static void cris_elf_final_write_processing PARAMS ((bfd *, boolean));
54
55static boolean cris_elf_print_private_bfd_data PARAMS ((bfd *, PTR));
56
57static boolean cris_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
58
06c15ad7
HPN
59static reloc_howto_type cris_elf_howto_table [] =
60{
61 /* This reloc does nothing. */
62 HOWTO (R_CRIS_NONE, /* type */
63 0, /* rightshift */
64 2, /* size (0 = byte, 1 = short, 2 = long) */
65 32, /* bitsize */
66 false, /* pc_relative */
67 0, /* bitpos */
68 complain_overflow_bitfield, /* complain_on_overflow */
69 bfd_elf_generic_reloc, /* special_function */
70 "R_CRIS_NONE", /* name */
71 false, /* partial_inplace */
72 0, /* src_mask */
73 0, /* dst_mask */
74 false), /* pcrel_offset */
75
76 /* An 8 bit absolute relocation. */
77 HOWTO (R_CRIS_8, /* type */
78 0, /* rightshift */
79 0, /* size (0 = byte, 1 = short, 2 = long) */
80 8, /* bitsize */
81 false, /* pc_relative */
82 0, /* bitpos */
83 complain_overflow_bitfield, /* complain_on_overflow */
84 bfd_elf_generic_reloc, /* special_function */
85 "R_CRIS_8", /* name */
86 false, /* partial_inplace */
87 0x0000, /* src_mask */
88 0x00ff, /* dst_mask */
89 false), /* pcrel_offset */
90
91 /* A 16 bit absolute relocation. */
92 HOWTO (R_CRIS_16, /* type */
93 0, /* rightshift */
94 1, /* size (0 = byte, 1 = short, 2 = long) */
95 16, /* bitsize */
96 false, /* pc_relative */
97 0, /* bitpos */
98 complain_overflow_bitfield, /* complain_on_overflow */
99 bfd_elf_generic_reloc, /* special_function */
100 "R_CRIS_16", /* name */
101 false, /* partial_inplace */
102 0x00000000, /* src_mask */
103 0x0000ffff, /* dst_mask */
104 false), /* pcrel_offset */
105
106 /* A 32 bit absolute relocation. */
107 HOWTO (R_CRIS_32, /* type */
108 0, /* rightshift */
109 2, /* size (0 = byte, 1 = short, 2 = long) */
110 32, /* bitsize */
111 false, /* pc_relative */
112 0, /* bitpos */
113 complain_overflow_bitfield, /* complain_on_overflow */
114 bfd_elf_generic_reloc, /* special_function */
115 "R_CRIS_32", /* name */
116 false, /* partial_inplace */
117 0x00000000, /* src_mask */
118 0xffffffff, /* dst_mask */
119 false), /* pcrel_offset */
120
121 /* An 8 bit absolute relocation. */
122 HOWTO (R_CRIS_8_PCREL, /* type */
123 0, /* rightshift */
124 0, /* size (0 = byte, 1 = short, 2 = long) */
125 8, /* bitsize */
126 true, /* pc_relative */
127 0, /* bitpos */
128 complain_overflow_bitfield, /* complain_on_overflow */
129 bfd_elf_generic_reloc, /* special_function */
130 "R_CRIS_8_PCREL", /* name */
131 false, /* partial_inplace */
132 0x0000, /* src_mask */
133 0x00ff, /* dst_mask */
134 false), /* pcrel_offset */
135
136 /* A 16 bit absolute relocation. */
137 HOWTO (R_CRIS_16_PCREL, /* type */
138 0, /* rightshift */
139 1, /* size (0 = byte, 1 = short, 2 = long) */
140 16, /* bitsize */
141 true, /* pc_relative */
142 0, /* bitpos */
143 complain_overflow_bitfield, /* complain_on_overflow */
144 bfd_elf_generic_reloc, /* special_function */
145 "R_CRIS_16", /* name */
146 false, /* partial_inplace */
147 0x00000000, /* src_mask */
148 0x0000ffff, /* dst_mask */
149 false), /* pcrel_offset */
150
151 /* A 32 bit absolute relocation. */
152 HOWTO (R_CRIS_32_PCREL, /* type */
153 0, /* rightshift */
154 2, /* size (0 = byte, 1 = short, 2 = long) */
155 32, /* bitsize */
156 true, /* pc_relative */
157 0, /* bitpos */
158 complain_overflow_bitfield, /* complain_on_overflow */
159 bfd_elf_generic_reloc, /* special_function */
160 "R_CRIS_32", /* name */
161 false, /* partial_inplace */
162 0x00000000, /* src_mask */
163 0xffffffff, /* dst_mask */
164 false), /* pcrel_offset */
165
166 /* GNU extension to record C++ vtable hierarchy */
167 HOWTO (R_CRIS_GNU_VTINHERIT, /* type */
168 0, /* rightshift */
169 2, /* size (0 = byte, 1 = short, 2 = long) */
170 0, /* bitsize */
171 false, /* pc_relative */
172 0, /* bitpos */
173 complain_overflow_dont, /* complain_on_overflow */
174 NULL, /* special_function */
175 "R_CRIS_GNU_VTINHERIT", /* name */
176 false, /* partial_inplace */
177 0, /* src_mask */
178 0, /* dst_mask */
179 false), /* pcrel_offset */
180
181 /* GNU extension to record C++ vtable member usage */
182 HOWTO (R_CRIS_GNU_VTENTRY, /* type */
183 0, /* rightshift */
184 2, /* size (0 = byte, 1 = short, 2 = long) */
185 0, /* bitsize */
186 false, /* pc_relative */
187 0, /* bitpos */
188 complain_overflow_dont, /* complain_on_overflow */
189 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
190 "R_CRIS_GNU_VTENTRY", /* name */
191 false, /* partial_inplace */
192 0, /* src_mask */
193 0, /* dst_mask */
194 false) /* pcrel_offset */
195};
196\f
197/* Map BFD reloc types to CRIS ELF reloc types. */
198
199struct cris_reloc_map
200{
201 bfd_reloc_code_real_type bfd_reloc_val;
202 unsigned int cris_reloc_val;
203};
204
205static const struct cris_reloc_map cris_reloc_map [] =
206{
207 { BFD_RELOC_NONE, R_CRIS_NONE },
208 { BFD_RELOC_8, R_CRIS_8 },
209 { BFD_RELOC_16, R_CRIS_16 },
210 { BFD_RELOC_32, R_CRIS_32 },
211 { BFD_RELOC_8_PCREL, R_CRIS_8_PCREL },
212 { BFD_RELOC_16_PCREL, R_CRIS_16_PCREL },
213 { BFD_RELOC_32_PCREL, R_CRIS_32_PCREL },
214 { BFD_RELOC_VTABLE_INHERIT, R_CRIS_GNU_VTINHERIT },
215 { BFD_RELOC_VTABLE_ENTRY, R_CRIS_GNU_VTENTRY }
216};
217
218static reloc_howto_type *
219cris_reloc_type_lookup (abfd, code)
220 bfd * abfd ATTRIBUTE_UNUSED;
221 bfd_reloc_code_real_type code;
222{
223 unsigned int i;
224
225 for (i = sizeof (cris_reloc_map) / sizeof (cris_reloc_map[0]);
226 --i;)
227 if (cris_reloc_map [i].bfd_reloc_val == code)
228 return & cris_elf_howto_table [cris_reloc_map[i].cris_reloc_val];
a7c10850 229
06c15ad7
HPN
230 return NULL;
231}
232
233/* Set the howto pointer for an CRIS ELF reloc. */
234
235static void
236cris_info_to_howto_rela (abfd, cache_ptr, dst)
237 bfd * abfd ATTRIBUTE_UNUSED;
238 arelent * cache_ptr;
239 Elf32_Internal_Rela * dst;
240{
241 unsigned int r_type;
242
243 r_type = ELF32_R_TYPE (dst->r_info);
244 BFD_ASSERT (r_type < (unsigned int) R_CRIS_max);
245 cache_ptr->howto = & cris_elf_howto_table [r_type];
246}
247\f
248/* Perform a single relocation. By default we use the standard BFD
249 routines, but we might have to do a few relocs ourselves in the future. */
250
251static bfd_reloc_status_type
252cris_final_link_relocate (howto, input_bfd, input_section, contents, rel,
253 relocation)
254 reloc_howto_type * howto;
255 bfd * input_bfd;
256 asection * input_section;
257 bfd_byte * contents;
258 Elf_Internal_Rela * rel;
259 bfd_vma relocation;
260{
261 bfd_reloc_status_type r
262 = _bfd_final_link_relocate (howto, input_bfd, input_section,
263 contents, rel->r_offset,
264 relocation, rel->r_addend);
265 return r;
266}
267\f
268/* Relocate an CRIS ELF section. See elf32-fr30.c, from where this was
269 copied, for further comments. */
270
271static boolean
272cris_elf_relocate_section (output_bfd, info, input_bfd, input_section,
273 contents, relocs, local_syms, local_sections)
274 bfd * output_bfd ATTRIBUTE_UNUSED;
275 struct bfd_link_info * info;
276 bfd * input_bfd;
277 asection * input_section;
278 bfd_byte * contents;
279 Elf_Internal_Rela * relocs;
280 Elf_Internal_Sym * local_syms;
281 asection ** local_sections;
282{
283 Elf_Internal_Shdr * symtab_hdr;
284 struct elf_link_hash_entry ** sym_hashes;
285 Elf_Internal_Rela * rel;
286 Elf_Internal_Rela * relend;
287
288 symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
289 sym_hashes = elf_sym_hashes (input_bfd);
290 relend = relocs + input_section->reloc_count;
291
292 /* It seems this can happen with erroneous or unsupported input (mixing
293 a.out and elf in an archive, for example.) */
294 if (sym_hashes == NULL)
295 return false;
296
297 for (rel = relocs; rel < relend; rel ++)
298 {
299 reloc_howto_type * howto;
300 unsigned long r_symndx;
301 Elf_Internal_Sym * sym;
302 asection * sec;
303 struct elf_link_hash_entry * h;
304 bfd_vma relocation;
305 bfd_reloc_status_type r;
306 const char * name = NULL;
307 int r_type;
a7c10850 308
06c15ad7 309 r_type = ELF32_R_TYPE (rel->r_info);
a7c10850 310
06c15ad7
HPN
311 if ( r_type == R_CRIS_GNU_VTINHERIT
312 || r_type == R_CRIS_GNU_VTENTRY)
313 continue;
a7c10850 314
06c15ad7
HPN
315 r_symndx = ELF32_R_SYM (rel->r_info);
316
317 if (info->relocateable)
318 {
319 /* This is a relocateable link. We don't have to change
320 anything, unless the reloc is against a section symbol,
321 in which case we have to adjust according to where the
322 section symbol winds up in the output section. */
323 if (r_symndx < symtab_hdr->sh_info)
324 {
325 sym = local_syms + r_symndx;
a7c10850 326
06c15ad7
HPN
327 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
328 {
329 sec = local_sections [r_symndx];
330 rel->r_addend += sec->output_offset + sym->st_value;
331 }
332 }
333
334 continue;
335 }
336
337 /* This is a final link. */
338 howto = cris_elf_howto_table + ELF32_R_TYPE (rel->r_info);
339 h = NULL;
340 sym = NULL;
341 sec = NULL;
a7c10850 342
06c15ad7
HPN
343 if (r_symndx < symtab_hdr->sh_info)
344 {
345 sym = local_syms + r_symndx;
346 sec = local_sections [r_symndx];
347 relocation = (sec->output_section->vma
348 + sec->output_offset
349 + sym->st_value);
a7c10850 350
06c15ad7
HPN
351 name = bfd_elf_string_from_elf_section
352 (input_bfd, symtab_hdr->sh_link, sym->st_name);
353 name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
354#if 0
355 fprintf (stderr, "local: sec: %s, sym: %s (%d), value: %x + %x + %x addend %x\n",
356 sec->name, name, sym->st_name,
357 sec->output_section->vma, sec->output_offset,
358 sym->st_value, rel->r_addend);
359#endif
360 }
361 else
362 {
363 h = sym_hashes [r_symndx - symtab_hdr->sh_info];
a7c10850 364
06c15ad7
HPN
365 while (h->root.type == bfd_link_hash_indirect
366 || h->root.type == bfd_link_hash_warning)
367 h = (struct elf_link_hash_entry *) h->root.u.i.link;
368
369 name = h->root.root.string;
a7c10850 370
06c15ad7
HPN
371 if (h->root.type == bfd_link_hash_defined
372 || h->root.type == bfd_link_hash_defweak)
373 {
374 sec = h->root.u.def.section;
375 relocation = (h->root.u.def.value
376 + sec->output_section->vma
377 + sec->output_offset);
378#if 0
379 fprintf (stderr,
380 "defined: sec: %s, name: %s, value: %x + %x + %x gives: %x\n",
381 sec->name, name, h->root.u.def.value,
382 sec->output_section->vma, sec->output_offset, relocation);
383#endif
384 }
385 else if (h->root.type == bfd_link_hash_undefweak)
386 {
387#if 0
388 fprintf (stderr, "undefined: sec: %s, name: %s\n",
389 sec->name, name);
390#endif
391 relocation = 0;
392 }
393 else if (info->shared
394 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
395 relocation = 0;
396 else
397 {
398 if (! ((*info->callbacks->undefined_symbol)
399 (info, h->root.root.string, input_bfd,
400 input_section, rel->r_offset, true)))
401 return false;
402#if 0
403 fprintf (stderr, "unknown: name: %s\n", name);
404#endif
405 relocation = 0;
406 }
407 }
a7c10850 408
06c15ad7
HPN
409 r = cris_final_link_relocate (howto, input_bfd, input_section,
410 contents, rel, relocation);
411
412 if (r != bfd_reloc_ok)
413 {
414 const char * msg = (const char *) NULL;
415
416 switch (r)
417 {
418 case bfd_reloc_overflow:
419 r = info->callbacks->reloc_overflow
420 (info, name, howto->name, (bfd_vma) 0,
421 input_bfd, input_section, rel->r_offset);
422 break;
a7c10850 423
06c15ad7
HPN
424 case bfd_reloc_undefined:
425 r = info->callbacks->undefined_symbol
426 (info, name, input_bfd, input_section, rel->r_offset,
427 true);
428 break;
a7c10850 429
06c15ad7
HPN
430 case bfd_reloc_outofrange:
431 msg = _("internal error: out of range error");
432 break;
433
434 case bfd_reloc_notsupported:
435 msg = _("internal error: unsupported relocation error");
436 break;
437
438 case bfd_reloc_dangerous:
439 msg = _("internal error: dangerous relocation");
440 break;
441
442 default:
443 msg = _("internal error: unknown error");
444 break;
445 }
446
447 if (msg)
448 r = info->callbacks->warning
449 (info, msg, name, input_bfd, input_section, rel->r_offset);
450
451 if (! r)
452 return false;
453 }
454 }
455
456 return true;
457}
458\f
459/* Return the section that should be marked against GC for a given
460 relocation. */
461
462static asection *
463cris_elf_gc_mark_hook (abfd, info, rel, h, sym)
464 bfd * abfd;
465 struct bfd_link_info * info ATTRIBUTE_UNUSED;
466 Elf_Internal_Rela * rel;
467 struct elf_link_hash_entry * h;
468 Elf_Internal_Sym * sym;
469{
470 if (h != NULL)
471 {
472 switch (ELF32_R_TYPE (rel->r_info))
473 {
474 case R_CRIS_GNU_VTINHERIT:
475 case R_CRIS_GNU_VTENTRY:
476 break;
477
478 default:
479 switch (h->root.type)
480 {
481 case bfd_link_hash_defined:
482 case bfd_link_hash_defweak:
483 return h->root.u.def.section;
484
485 case bfd_link_hash_common:
486 return h->root.u.c.p->section;
487
488 default:
489 break;
490 }
491 }
492 }
493 else
494 {
495 if (!(elf_bad_symtab (abfd)
496 && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
497 && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
498 && sym->st_shndx != SHN_COMMON))
499 {
500 return bfd_section_from_elf_index (abfd, sym->st_shndx);
501 }
502 }
503
504 return NULL;
505}
506
507/* Update the got entry reference counts for the section being removed. */
508
509static boolean
510cris_elf_gc_sweep_hook (abfd, info, sec, relocs)
511 bfd * abfd ATTRIBUTE_UNUSED;
512 struct bfd_link_info * info ATTRIBUTE_UNUSED;
513 asection * sec ATTRIBUTE_UNUSED;
514 const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED;
515{
516 return true;
517}
518
519/* Look through the relocs for a section during the first phase.
520 Since we don't do .gots or .plts, we just need to consider the
521 virtual table relocs for gc. */
a7c10850 522
06c15ad7
HPN
523static boolean
524cris_elf_check_relocs (abfd, info, sec, relocs)
525 bfd *abfd;
526 struct bfd_link_info *info;
527 asection *sec;
528 const Elf_Internal_Rela *relocs;
529{
530 Elf_Internal_Shdr *symtab_hdr;
531 struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
532 const Elf_Internal_Rela *rel;
533 const Elf_Internal_Rela *rel_end;
a7c10850 534
06c15ad7
HPN
535 if (info->relocateable)
536 return true;
a7c10850 537
06c15ad7
HPN
538 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
539 sym_hashes = elf_sym_hashes (abfd);
a7c10850 540 sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof (Elf32_External_Sym);
06c15ad7
HPN
541 if (!elf_bad_symtab (abfd))
542 sym_hashes_end -= symtab_hdr->sh_info;
a7c10850 543
06c15ad7
HPN
544 rel_end = relocs + sec->reloc_count;
545 for (rel = relocs; rel < rel_end; rel++)
546 {
547 struct elf_link_hash_entry *h;
548 unsigned long r_symndx;
a7c10850 549
06c15ad7
HPN
550 r_symndx = ELF32_R_SYM (rel->r_info);
551 if (r_symndx < symtab_hdr->sh_info)
552 h = NULL;
553 else
554 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
a7c10850 555
06c15ad7
HPN
556 switch (ELF32_R_TYPE (rel->r_info))
557 {
558 /* This relocation describes the C++ object vtable hierarchy.
559 Reconstruct it for later use during GC. */
560 case R_CRIS_GNU_VTINHERIT:
561 if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
562 return false;
563 break;
a7c10850 564
06c15ad7
HPN
565 /* This relocation describes which C++ vtable entries are actually
566 used. Record for later use during GC. */
567 case R_CRIS_GNU_VTENTRY:
568 if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
569 return false;
570 break;
571 }
572 }
a7c10850 573
06c15ad7
HPN
574 return true;
575}
4da81684
HPN
576
577/* Reject a file depending on underscores on symbols. */
578
579static boolean
580cris_elf_object_p (abfd)
581 bfd *abfd;
582{
583 if ((elf_elfheader (abfd)->e_flags & EF_CRIS_UNDERSCORE))
584 return (bfd_get_symbol_leading_char (abfd) == '_');
585 else
586 return (bfd_get_symbol_leading_char (abfd) == 0);
587}
588
589/* Mark presence or absence of leading underscore. */
590
591static void
592cris_elf_final_write_processing (abfd, linker)
593 bfd *abfd;
594 boolean linker ATTRIBUTE_UNUSED;
595{
596 if (bfd_get_symbol_leading_char (abfd) == '_')
597 elf_elfheader (abfd)->e_flags |= EF_CRIS_UNDERSCORE;
598 else
599 elf_elfheader (abfd)->e_flags &= ~EF_CRIS_UNDERSCORE;
600}
601
602/* Display the flags field. */
603
604static boolean
605cris_elf_print_private_bfd_data (abfd, ptr)
606 bfd *abfd;
607 PTR ptr;
608{
609 FILE *file = (FILE *) ptr;
610
611 BFD_ASSERT (abfd != NULL && ptr != NULL)
612
613 _bfd_elf_print_private_bfd_data (abfd, ptr);
614
615 fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
616
617 if (elf_elfheader (abfd)->e_flags & EF_CRIS_UNDERSCORE)
618 fprintf (file, _(" [symbols have a _ prefix]"));
619
620 fputc ('\n', file);
621 return true;
622}
623
624/* Don't mix files with and without a leading underscore. */
625
626static boolean
627cris_elf_merge_private_bfd_data (ibfd, obfd)
628 bfd *ibfd;
629 bfd *obfd;
630{
631 flagword old_flags, new_flags;
632
633 if (_bfd_generic_verify_endian_match (ibfd, obfd) == false)
634 return false;
635
636 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
637 || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
638 return true;
639
640 if (! elf_flags_init (obfd))
641 {
642 /* This happens when ld starts out with a 'blank' output file. */
643 elf_flags_init (obfd) = true;
644
645 /* Set flags according to current bfd_target. */
646 cris_elf_final_write_processing (obfd, false);
647 }
648
649 old_flags = elf_elfheader (obfd)->e_flags;
650 new_flags = elf_elfheader (ibfd)->e_flags;
651
652 /* Is this good or bad? We'll follow with other excluding flags. */
653 if ((old_flags & EF_CRIS_UNDERSCORE) != (new_flags & EF_CRIS_UNDERSCORE))
654 {
655 (*_bfd_error_handler)
656 ((new_flags & EF_CRIS_UNDERSCORE)
657 ? _("%s: uses _-prefixed symbols, but writing file with non-prefixed symbols")
658 : _("%s: uses non-prefixed symbols, but writing file with _-prefixed symbols"),
659 bfd_get_filename (ibfd));
660 bfd_set_error (bfd_error_bad_value);
661 return false;
662 }
663
664 return true;
665}
06c15ad7
HPN
666\f
667#define ELF_ARCH bfd_arch_cris
668#define ELF_MACHINE_CODE EM_CRIS
669#define ELF_MAXPAGESIZE 0x2000
670
671#define TARGET_LITTLE_SYM bfd_elf32_cris_vec
672#define TARGET_LITTLE_NAME "elf32-cris"
4da81684 673#define elf_symbol_leading_char 0
06c15ad7
HPN
674
675#define elf_info_to_howto_rel NULL
676#define elf_info_to_howto cris_info_to_howto_rela
677#define elf_backend_relocate_section cris_elf_relocate_section
678#define elf_backend_gc_mark_hook cris_elf_gc_mark_hook
679#define elf_backend_gc_sweep_hook cris_elf_gc_sweep_hook
680#define elf_backend_check_relocs cris_elf_check_relocs
681
682#define elf_backend_can_gc_sections 1
683
4da81684
HPN
684#define elf_backend_object_p cris_elf_object_p
685#define elf_backend_final_write_processing \
686 cris_elf_final_write_processing
687#define bfd_elf32_bfd_print_private_bfd_data \
688 cris_elf_print_private_bfd_data
689#define bfd_elf32_bfd_merge_private_bfd_data \
690 cris_elf_merge_private_bfd_data
691
06c15ad7
HPN
692#define bfd_elf32_bfd_reloc_type_lookup cris_reloc_type_lookup
693
694/* Later, we my want to optimize RELA entries into REL entries for dynamic
695 linking and libraries (if it's a win of any significance). Until then,
696 take the easy route. */
697#define elf_backend_may_use_rel_p 0
698#define elf_backend_may_use_rela_p 1
699
700#include "elf32-target.h"
4da81684
HPN
701
702#define INCLUDED_TARGET_FILE
703
704#undef TARGET_LITTLE_SYM
705#undef TARGET_LITTLE_NAME
706#undef elf_symbol_leading_char
707
708#define TARGET_LITTLE_SYM bfd_elf32_us_cris_vec
709#define TARGET_LITTLE_NAME "elf32-us-cris"
710#define elf_symbol_leading_char '_'
711
712#include "elf32-target.h"
This page took 0.092294 seconds and 4 git commands to generate.