Coverage Report

Created: 2023-08-28 06:25

/src/binutils-gdb/bfd/elf32-epiphany.c
Line
Count
Source (jump to first uncovered line)
1
/* Adapteva epiphany specific support for 32-bit ELF
2
   Copyright (C) 2000-2023 Free Software Foundation, Inc.
3
   Contributed by Embecosm on behalf of Adapteva, Inc.
4
5
   This file is part of BFD, the Binary File Descriptor library.
6
7
   This program is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3 of the License, or
10
   (at your option) any later version.
11
12
   This program is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
16
17
   You should have received a copy of the GNU General Public License
18
   along with this program; if not, write to the Free Software
19
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20
   MA 02110-1301, USA.  */
21
22
#include "sysdep.h"
23
#include "bfd.h"
24
#include "libbfd.h"
25
#include "elf-bfd.h"
26
#include "elf/epiphany.h"
27
#include "libiberty.h"
28
29
/* Struct used to pass miscellaneous paramaters which
30
   helps to avoid overly long parameter lists.  */
31
struct misc
32
{
33
  Elf_Internal_Shdr *  symtab_hdr;
34
  Elf_Internal_Rela *  irelbase;
35
  bfd_byte *         contents;
36
  Elf_Internal_Sym *   isymbuf;
37
};
38
39
struct epiphany_opcode
40
{
41
  unsigned short opcode;
42
  unsigned short mask;
43
};
44
45
static bool epiphany_relaxed = false;
46
47
/* Relocation tables.  */
48
static reloc_howto_type epiphany_elf_howto_table [] =
49
{
50
#define AHOW(t,rs,s,bs,pr,bp,co,name,sm,dm) \
51
    HOWTO(t,      /* type */ \
52
    rs,     /* rightshift */ \
53
    s,      /* size */ \
54
    bs,     /* bitsize */ \
55
    pr,     /* pc_relative */ \
56
    bp,     /* bitpos */ \
57
    co,     /* complain_on_overflow */         \
58
    bfd_elf_generic_reloc,/* special_function */ \
59
    name,     /* name */ \
60
    false,    /* partial_inplace */ \
61
    sm,     /* src_mask */ \
62
    dm,     /* dst_mask */ \
63
    pr)     /* pcrel_offset */
64
65
  /* This reloc does nothing.  */
66
  AHOW (R_EPIPHANY_NONE,    0, 0,0, false, 0, complain_overflow_dont,   "R_EPIPHANY_NONE",      0,    0),
67
68
  /* 8 bit absolute (not likely) */
69
  AHOW (R_EPIPHANY_8,     0, 1, 8, false, 0, complain_overflow_bitfield, "R_EPIPHANY_8",  0x000000ff, 0x000000ff),
70
  /* 16 bit absolute */
71
  AHOW (R_EPIPHANY_16,      0, 2,16, false, 0, complain_overflow_bitfield, "R_EPIPHANY_16", 0x0000ffff, 0x00ff1fe0),
72
  /* A 32 bit absolute relocation.  */
73
  AHOW (R_EPIPHANY_32,      0, 4,32, false, 0, complain_overflow_dont,     "R_EPIPHANY_32", 0xffffffff, 0xffffffff),
74
75
  /*  8 bit relative relocation */
76
  HOWTO ( R_EPIPHANY_8_PCREL,  0, 1,  8, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_EPIPHANY_8_PCREL", false, 0x000000ff, 0x000000ff, false),
77
  /* 16 bit relative relocation */
78
  HOWTO ( R_EPIPHANY_16_PCREL, 0, 2, 16, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_EPIPHANY_8_PCREL", false, 0x000000ff, 0x000000ff, false),
79
  /* 32 bit relative relocation */
80
  HOWTO ( R_EPIPHANY_32_PCREL, 0, 4, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_EPIPHANY_8_PCREL", false, 0x000000ff, 0x000000ff, false),
81
82
  /* 8 bit pc-relative relocation */
83
  AHOW (R_EPIPHANY_SIMM8,   1, 1, 8,  true, 8, complain_overflow_signed,   "R_EPIPHANY_SIMM8",   0x000000ff, 0x0000ff00),
84
  /* 24 bit pc-relative relocation */
85
  AHOW (R_EPIPHANY_SIMM24,  1, 4,24,  true, 8, complain_overflow_signed,   "R_EPIPHANY_SIMM24",  0x00ffffff, 0xffffff00),
86
87
  /* %HIGH(EA) */
88
  AHOW (R_EPIPHANY_HIGH,    0, 4,16, false, 0, complain_overflow_dont,     "R_EPIPHANY_HIGH",  0x0ff01fe0, 0x0ff01fe0),
89
90
  /* %LOW(EA) */
91
  AHOW (R_EPIPHANY_LOW,     0, 4,16, false, 0, complain_overflow_dont,  "R_EPIPHANY_LOW",     0x0ff01fe0, 0x0ff01fe0),
92
93
  /* simm11 */
94
  AHOW (R_EPIPHANY_SIMM11,  0, 4,11, false, 0, complain_overflow_bitfield, "R_EPIPHANY_SIMM11",  0x00ff0380, 0x00ff0380),
95
  /* imm12 - sign-magnitude */
96
  AHOW (R_EPIPHANY_IMM11,   0, 4,11, false, 0, complain_overflow_bitfield, "R_EPIPHANY_IMM12",   0x00ff0380, 0x00ff0380),
97
  /* imm8 */
98
  AHOW (R_EPIPHANY_IMM8,    0, 2, 8, false, 8, complain_overflow_signed,   "R_EPIPHANY_IMM8",  0x0000ff00, 0x0000ff00)
99
100
101
};
102
#undef AHOW
103
104
/* Map BFD reloc types to EPIPHANY ELF reloc types.  */
105
106
static reloc_howto_type *
107
epiphany_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
108
          bfd_reloc_code_real_type code)
109
0
{
110
  /* Note that the epiphany_elf_howto_table is indxed by the R_
111
     constants.  Thus, the order that the howto records appear in the
112
     table *must* match the order of the relocation types defined in
113
     include/elf/epiphany.h.  */
114
115
0
  switch (code)
116
0
    {
117
0
    case BFD_RELOC_NONE:
118
0
      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_NONE];
119
120
0
    case BFD_RELOC_EPIPHANY_SIMM8:
121
0
      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_SIMM8];
122
0
    case BFD_RELOC_EPIPHANY_SIMM24:
123
0
      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_SIMM24];
124
125
0
    case BFD_RELOC_8_PCREL:
126
0
      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_8_PCREL];
127
0
    case BFD_RELOC_16_PCREL:
128
0
      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_16_PCREL];
129
0
    case BFD_RELOC_32_PCREL:
130
0
      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_32_PCREL];
131
132
0
    case BFD_RELOC_8:
133
0
      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_8];
134
0
    case BFD_RELOC_16:
135
0
      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_16];
136
0
    case BFD_RELOC_32:
137
0
      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_32];
138
139
0
    case BFD_RELOC_EPIPHANY_HIGH:
140
0
      return & epiphany_elf_howto_table[ (int) R_EPIPHANY_HIGH];
141
0
    case BFD_RELOC_EPIPHANY_LOW:
142
0
      return & epiphany_elf_howto_table[ (int) R_EPIPHANY_LOW];
143
144
0
    case BFD_RELOC_EPIPHANY_SIMM11:
145
0
      return & epiphany_elf_howto_table[ (int) R_EPIPHANY_SIMM11];
146
0
    case BFD_RELOC_EPIPHANY_IMM11:
147
0
      return & epiphany_elf_howto_table[ (int) R_EPIPHANY_IMM11];
148
149
0
    case BFD_RELOC_EPIPHANY_IMM8:
150
0
      return & epiphany_elf_howto_table[ (int) R_EPIPHANY_IMM8];
151
152
0
    default:
153
      /* Pacify gcc -Wall.  */
154
0
      return NULL;
155
0
    }
156
0
  return NULL;
157
0
}
158
159
static reloc_howto_type *
160
epiphany_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
161
0
{
162
0
  unsigned int i;
163
164
0
  for (i = 0; i < ARRAY_SIZE (epiphany_elf_howto_table); i++)
165
0
    if (epiphany_elf_howto_table[i].name != NULL
166
0
  && strcasecmp (epiphany_elf_howto_table[i].name, r_name) == 0)
167
0
      return &epiphany_elf_howto_table[i];
168
169
0
  return NULL;
170
0
}
171
172
0
#define PAGENO(ABSADDR) ((ABSADDR) & 0xFFFFC000)
173
0
#define BASEADDR(SEC) ((SEC)->output_section->vma + (SEC)->output_offset)
174
175
/* This function handles relaxing for the epiphany.
176
   Dummy placeholder for future optimizations.  */
177
178
static bool
179
epiphany_elf_relax_section (bfd *abfd, asection *sec,
180
          struct bfd_link_info *link_info,
181
          bool *again)
182
0
{
183
0
  Elf_Internal_Shdr *symtab_hdr;
184
0
  Elf_Internal_Rela *internal_relocs;
185
0
  bfd_byte *contents = NULL;
186
0
  Elf_Internal_Sym *isymbuf = NULL;
187
0
  static asection * first_section = NULL;
188
0
  static unsigned long search_addr;
189
0
  static unsigned long page_start = 0;
190
0
  static unsigned long page_end = 0;
191
0
  static unsigned int pass = 0;
192
0
  static bool new_pass = false;
193
0
  static bool changed = false;
194
0
  struct misc misc ATTRIBUTE_UNUSED;
195
0
  asection *stab;
196
197
  /* Assume nothing changes.  */
198
0
  *again = false;
199
200
0
  if (first_section == NULL)
201
0
    {
202
0
      epiphany_relaxed = true;
203
0
      first_section = sec;
204
0
    }
205
206
0
  if (first_section == sec)
207
0
    {
208
0
      pass++;
209
0
      new_pass = true;
210
0
    }
211
212
  /* We don't have to do anything for a relocatable link,
213
     if this section does not have relocs, or if this is
214
     not a code section.  */
215
0
  if (bfd_link_relocatable (link_info)
216
0
      || sec->reloc_count == 0
217
0
      || (sec->flags & SEC_RELOC) == 0
218
0
      || (sec->flags & SEC_HAS_CONTENTS) == 0
219
0
      || (sec->flags & SEC_CODE) == 0)
220
0
    return true;
221
222
0
  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
223
224
0
  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
225
0
                 link_info->keep_memory);
226
0
  if (internal_relocs == NULL)
227
0
    goto error_return;
228
229
  /* Make sure the stac.rela stuff gets read in.  */
230
0
  stab = bfd_get_section_by_name (abfd, ".stab");
231
232
0
  if (stab)
233
0
    {
234
      /* So stab does exits.  */
235
0
      Elf_Internal_Rela * irelbase ATTRIBUTE_UNUSED;
236
237
0
      irelbase = _bfd_elf_link_read_relocs (abfd, stab, NULL, NULL,
238
0
              link_info->keep_memory);
239
0
    }
240
241
  /* Get section contents cached copy if it exists.  */
242
0
  if (contents == NULL)
243
0
    {
244
      /* Get cached copy if it exists.  */
245
0
      if (elf_section_data (sec)->this_hdr.contents != NULL)
246
0
  contents = elf_section_data (sec)->this_hdr.contents;
247
0
      else
248
0
  {
249
    /* Go get them off disk.  */
250
0
    if (!bfd_malloc_and_get_section (abfd, sec, &contents))
251
0
      goto error_return;
252
0
  }
253
0
    }
254
255
  /* Read this BFD's symbols cached copy if it exists.  */
256
0
  if (isymbuf == NULL && symtab_hdr->sh_info != 0)
257
0
    {
258
0
      isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
259
0
      if (isymbuf == NULL)
260
0
  isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
261
0
          symtab_hdr->sh_info, 0,
262
0
          NULL, NULL, NULL);
263
0
      if (isymbuf == NULL)
264
0
  goto error_return;
265
0
    }
266
267
0
  misc.symtab_hdr = symtab_hdr;
268
0
  misc.isymbuf = isymbuf;
269
0
  misc.irelbase = internal_relocs;
270
0
  misc.contents = contents;
271
272
  /* This is where all the relaxation actually get done.  */
273
0
  if ((pass == 1) || (new_pass && !changed))
274
0
    {
275
      /* On the first pass we simply search for the lowest page that
276
   we havn't relaxed yet. Note that the pass count is reset
277
   each time a page is complete in order to move on to the next page.
278
   If we can't find any more pages then we are finished.  */
279
0
      if (new_pass)
280
0
  {
281
0
    pass = 1;
282
0
    new_pass = false;
283
0
    changed = true; /* Pre-initialize to break out of pass 1.  */
284
0
    search_addr = 0xFFFFFFFF;
285
0
  }
286
287
0
      if ((BASEADDR (sec) + sec->size < search_addr)
288
0
    && (BASEADDR (sec) + sec->size > page_end))
289
0
  {
290
0
    if (BASEADDR (sec) <= page_end)
291
0
      search_addr = page_end + 1;
292
0
    else
293
0
      search_addr = BASEADDR (sec);
294
295
    /* Found a page => more work to do.  */
296
0
    *again = true;
297
0
  }
298
0
    }
299
0
  else
300
0
    {
301
0
      if (new_pass)
302
0
  {
303
0
    new_pass = false;
304
0
    changed = false;
305
0
    page_start = PAGENO (search_addr);
306
0
    page_end = page_start | 0x00003FFF;
307
0
  }
308
309
      /* Only process sections in range.  */
310
0
      if ((BASEADDR (sec) + sec->size >= page_start)
311
0
    && (BASEADDR (sec) <= page_end))
312
0
  {
313
#if 0
314
    if (!epiphany_elf_relax_section_page (abfd, sec, &changed, &misc,
315
            page_start, page_end))
316
#endif
317
0
      return false;
318
0
  }
319
0
      *again = true;
320
0
    }
321
322
  /* Perform some house keeping after relaxing the section.  */
323
324
0
  if (isymbuf != NULL
325
0
      && symtab_hdr->contents != (unsigned char *) isymbuf)
326
0
    {
327
0
      if (! link_info->keep_memory)
328
0
  free (isymbuf);
329
0
      else
330
0
  symtab_hdr->contents = (unsigned char *) isymbuf;
331
0
    }
332
333
0
  if (contents != NULL
334
0
      && elf_section_data (sec)->this_hdr.contents != contents)
335
0
    {
336
0
      if (! link_info->keep_memory)
337
0
  free (contents);
338
0
      else
339
0
  {
340
    /* Cache the section contents for elf_link_input_bfd.  */
341
0
    elf_section_data (sec)->this_hdr.contents = contents;
342
0
  }
343
0
    }
344
345
0
  if (elf_section_data (sec)->relocs != internal_relocs)
346
0
    free (internal_relocs);
347
348
0
  return true;
349
350
0
 error_return:
351
0
  if (symtab_hdr->contents != (unsigned char *) isymbuf)
352
0
    free (isymbuf);
353
0
  if (elf_section_data (sec)->this_hdr.contents != contents)
354
0
    free (contents);
355
0
  if (elf_section_data (sec)->relocs != internal_relocs)
356
0
    free (internal_relocs);
357
0
  return false;
358
0
}
359
360
/* Set the howto pointer for a EPIPHANY ELF reloc.  */
361
362
static bool
363
epiphany_info_to_howto_rela (bfd * abfd,
364
           arelent * cache_ptr,
365
           Elf_Internal_Rela * dst)
366
0
{
367
0
  unsigned int r_type;
368
369
0
  r_type = ELF32_R_TYPE (dst->r_info);
370
0
  if (r_type >= (unsigned int) R_EPIPHANY_max)
371
0
    {
372
      /* xgettext:c-format */
373
0
      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
374
0
        abfd, r_type);
375
0
      bfd_set_error (bfd_error_bad_value);
376
0
      return false;
377
0
    }
378
0
  cache_ptr->howto = & epiphany_elf_howto_table [r_type];
379
0
  return true;
380
0
}
381
382
/* Perform a single relocation.
383
   By default we use the standard BFD routines.  */
384
385
static bfd_reloc_status_type
386
epiphany_final_link_relocate (reloc_howto_type *  howto,
387
            bfd *     input_bfd,
388
            asection *    input_section,
389
            bfd_byte *    contents,
390
            Elf_Internal_Rela * rel,
391
            bfd_vma     relocation)
392
0
{
393
0
  switch (howto->type)
394
0
    {
395
      /* Handle 16 bit immediates.  */
396
0
    case R_EPIPHANY_HIGH:
397
0
      relocation += rel->r_addend;
398
0
      relocation >>= 16;
399
0
      goto common;
400
401
0
    case R_EPIPHANY_LOW:
402
0
      relocation += rel->r_addend;
403
0
    common:
404
0
      relocation = ((relocation & 0xff00L) << 12)
405
0
  | ((relocation & 0x00ffL) << 5);
406
      /* Sanity check the address.  */
407
0
      if (rel->r_offset > bfd_get_section_limit (input_bfd, input_section))
408
0
  return bfd_reloc_outofrange;
409
410
0
      return _bfd_relocate_contents (howto, input_bfd, relocation,
411
0
             contents + rel->r_offset);
412
413
0
    case R_EPIPHANY_SIMM11:
414
0
      relocation += rel->r_addend;
415
      /* Check signed overflow.  */
416
0
      if ((int)relocation > 1023 || (int)relocation < -1024)
417
0
  return bfd_reloc_outofrange;
418
0
      goto disp11;
419
420
0
    case R_EPIPHANY_IMM11:
421
0
      relocation += rel->r_addend;
422
0
      if ((unsigned int) relocation > 0x7ff)
423
0
  return bfd_reloc_outofrange;
424
      /* Fall through.  */
425
0
    disp11:
426
0
      relocation = (((relocation & 7) << 5)
427
0
        | ((relocation & 0x7f8 ) << 13));
428
0
      return _bfd_relocate_contents (howto, input_bfd, relocation,
429
0
             contents + rel->r_offset);
430
431
      /* Pass others through.  */
432
0
    default:
433
0
      break;
434
0
    }
435
436
  /* Only install relocation if above tests did not disqualify it.  */
437
0
  return _bfd_final_link_relocate (howto, input_bfd, input_section,
438
0
           contents, rel->r_offset,
439
0
           relocation, rel->r_addend);
440
0
}
441
442
/* Relocate an EPIPHANY ELF section.
443
444
   The RELOCATE_SECTION function is called by the new ELF backend linker
445
   to handle the relocations for a section.
446
447
   The relocs are always passed as Rela structures; if the section
448
   actually uses Rel structures, the r_addend field will always be
449
   zero.
450
451
   This function is responsible for adjusting the section contents as
452
   necessary, and (if using Rela relocs and generating a relocatable
453
   output file) adjusting the reloc addend as necessary.
454
455
   This function does not have to worry about setting the reloc
456
   address or the reloc symbol index.
457
458
   LOCAL_SYMS is a pointer to the swapped in local symbols.
459
460
   LOCAL_SECTIONS is an array giving the section in the input file
461
   corresponding to the st_shndx field of each local symbol.
462
463
   The global hash table entry for the global symbols can be found
464
   via elf_sym_hashes (input_bfd).
465
466
   When generating relocatable output, this function must handle
467
   STB_LOCAL/STT_SECTION symbols specially.  The output symbol is
468
   going to be the section symbol corresponding to the output
469
   section, which means that the addend must be adjusted
470
   accordingly.  */
471
472
static int
473
epiphany_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
474
             struct bfd_link_info *info,
475
             bfd *input_bfd,
476
             asection *input_section,
477
             bfd_byte *contents,
478
             Elf_Internal_Rela *relocs,
479
             Elf_Internal_Sym *local_syms,
480
             asection **local_sections)
481
0
{
482
0
  Elf_Internal_Shdr *symtab_hdr;
483
0
  struct elf_link_hash_entry **sym_hashes;
484
0
  Elf_Internal_Rela *rel;
485
0
  Elf_Internal_Rela *relend;
486
487
0
  symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
488
0
  sym_hashes = elf_sym_hashes (input_bfd);
489
0
  relend     = relocs + input_section->reloc_count;
490
491
0
  for (rel = relocs; rel < relend; rel ++)
492
0
    {
493
0
      reloc_howto_type *     howto;
494
0
      unsigned long      r_symndx;
495
0
      Elf_Internal_Sym *     sym;
496
0
      asection *       sec;
497
0
      struct elf_link_hash_entry * h;
498
0
      bfd_vma        relocation;
499
0
      bfd_reloc_status_type    r;
500
0
      const char *       name = NULL;
501
0
      int        r_type ATTRIBUTE_UNUSED;
502
503
0
      r_type = ELF32_R_TYPE (rel->r_info);
504
0
      r_symndx = ELF32_R_SYM (rel->r_info);
505
0
      howto  = epiphany_elf_howto_table + ELF32_R_TYPE (rel->r_info);
506
0
      h      = NULL;
507
0
      sym    = NULL;
508
0
      sec    = NULL;
509
510
0
      if (r_symndx < symtab_hdr->sh_info)
511
0
  {
512
0
    sym = local_syms + r_symndx;
513
0
    sec = local_sections [r_symndx];
514
0
    relocation = BASEADDR (sec) + sym->st_value;
515
516
0
    name = bfd_elf_string_from_elf_section
517
0
      (input_bfd, symtab_hdr->sh_link, sym->st_name);
518
0
    name = name == NULL ? bfd_section_name (sec) : name;
519
0
  }
520
0
      else
521
0
  {
522
0
    bool warned ATTRIBUTE_UNUSED;
523
0
    bool unresolved_reloc ATTRIBUTE_UNUSED;
524
0
    bool ignored ATTRIBUTE_UNUSED;
525
526
0
    RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
527
0
           r_symndx, symtab_hdr, sym_hashes,
528
0
           h, sec, relocation,
529
0
           unresolved_reloc, warned, ignored);
530
531
0
    name = h->root.root.string;
532
0
  }
533
534
0
      if (sec != NULL && discarded_section (sec))
535
0
  RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
536
0
           rel, 1, relend, howto, 0, contents);
537
538
0
      if (bfd_link_relocatable (info))
539
0
  continue;
540
541
      /* Finally, the sole EPIPHANY-specific part.  */
542
0
      r = epiphany_final_link_relocate (howto, input_bfd, input_section,
543
0
             contents, rel, relocation);
544
545
0
      if (r != bfd_reloc_ok)
546
0
  {
547
0
    const char * msg = NULL;
548
549
0
    switch (r)
550
0
      {
551
0
      case bfd_reloc_overflow:
552
0
        (*info->callbacks->reloc_overflow)
553
0
    (info, (h ? &h->root : NULL), name, howto->name,
554
0
     (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
555
0
        break;
556
557
0
      case bfd_reloc_undefined:
558
0
        (*info->callbacks->undefined_symbol)
559
0
    (info, name, input_bfd, input_section, rel->r_offset, true);
560
0
        break;
561
562
0
      case bfd_reloc_outofrange:
563
0
        msg = _("internal error: out of range error");
564
0
        break;
565
566
        /* This is how epiphany_final_link_relocate tells us of a
567
     non-kosher reference between insn & data address spaces.  */
568
0
      case bfd_reloc_notsupported:
569
0
        if (sym != NULL) /* Only if it's not an unresolved symbol.  */
570
0
     msg = _("unsupported relocation between data/insn address spaces");
571
0
        break;
572
573
0
      case bfd_reloc_dangerous:
574
0
        msg = _("internal error: dangerous relocation");
575
0
        break;
576
577
0
      default:
578
0
        msg = _("internal error: unknown error");
579
0
        break;
580
0
      }
581
582
0
    if (msg)
583
0
      (*info->callbacks->warning) (info, msg, name, input_bfd,
584
0
           input_section, rel->r_offset);
585
0
  }
586
0
    }
587
588
0
  return true;
589
0
}
590
591
/* We only have a little-endian target.  */
592
#define TARGET_LITTLE_SYM  epiphany_elf32_vec
593
#define TARGET_LITTLE_NAME  "elf32-epiphany"
594
595
#define ELF_ARCH   bfd_arch_epiphany
596
#define ELF_MACHINE_CODE EM_ADAPTEVA_EPIPHANY
597
598
#define ELF_MAXPAGESIZE  0x8000 /* No pages on the EPIPHANY.  */
599
600
#define elf_info_to_howto_rel     NULL
601
#define elf_info_to_howto     epiphany_info_to_howto_rela
602
603
#define elf_backend_can_gc_sections   1
604
#define elf_backend_rela_normal     1
605
#define elf_backend_relocate_section    epiphany_elf_relocate_section
606
607
#define elf_symbol_leading_char     '_'
608
#define bfd_elf32_bfd_reloc_type_lookup   epiphany_reloc_type_lookup
609
#define bfd_elf32_bfd_reloc_name_lookup   epiphany_reloc_name_lookup
610
#define bfd_elf32_bfd_relax_section   epiphany_elf_relax_section
611
612
#include "elf32-target.h"