OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [bfd/] [versados.c] - Blame information for rev 199

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
/* BFD back-end for VERSAdos-E objects.
2
   Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3
   2006, 2007 Free Software Foundation, Inc.
4
   Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
5
 
6
   Versados is a Motorola trademark.
7
 
8
   This file is part of BFD, the Binary File Descriptor library.
9
 
10
   This program is free software; you can redistribute it and/or modify
11
   it under the terms of the GNU General Public License as published by
12
   the Free Software Foundation; either version 3 of the License, or
13
   (at your option) any later version.
14
 
15
   This program is distributed in the hope that it will be useful,
16
   but WITHOUT ANY WARRANTY; without even the implied warranty of
17
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
   GNU General Public License for more details.
19
 
20
   You should have received a copy of the GNU General Public License
21
   along with this program; if not, write to the Free Software
22
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
23
   MA 02110-1301, USA.  */
24
 
25
/*
26
   SUBSECTION
27
   VERSAdos-E relocatable object file format
28
 
29
   DESCRIPTION
30
 
31
   This module supports reading of VERSAdos relocatable
32
   object files.
33
 
34
   A VERSAdos file looks like contains
35
 
36
   o Identification Record
37
   o External Symbol Definition Record
38
   o Object Text Record
39
   o End Record.  */
40
 
41
#include "sysdep.h"
42
#include "bfd.h"
43
#include "libbfd.h"
44
#include "libiberty.h"
45
 
46
 
47
#define VHEADER '1'
48
#define VESTDEF '2'
49
#define VOTR '3'
50
#define VEND '4'
51
 
52
#define ES_BASE 17              /* First symbol has esdid 17.  */
53
 
54
/* Per file target dependent information.  */
55
 
56
/* One for each section.  */
57
struct esdid
58
{
59
  asection *section;            /* Ptr to bfd version.  */
60
  unsigned char *contents;      /* Used to build image.  */
61
  int pc;
62
  int relocs;                   /* Reloc count, valid end of pass 1.  */
63
  int donerel;                  /* Have relocs been translated.  */
64
};
65
 
66
typedef struct versados_data_struct
67
{
68
  int es_done;                  /* Count of symbol index, starts at ES_BASE.  */
69
  asymbol *symbols;             /* Pointer to local symbols.  */
70
  char *strings;                /* Strings of all the above.  */
71
  int stringlen;                /* Len of string table (valid end of pass1).  */
72
  int nsecsyms;                 /* Number of sections.  */
73
 
74
  int ndefs;                    /* Number of exported symbols (they dont get esdids).  */
75
  int nrefs;                    /* Number of imported symbols  (valid end of pass1).  */
76
 
77
  int ref_idx;                  /* Current processed value of the above.  */
78
  int def_idx;
79
 
80
  int pass_2_done;
81
 
82
  struct esdid e[16];           /* Per section info.  */
83
  int alert;                    /* To see if we're trampling.  */
84
  asymbol *rest[256 - 16];      /* Per symbol info.  */
85
}
86
tdata_type;
87
 
88
#define VDATA(abfd)       (abfd->tdata.versados_data)
89
#define EDATA(abfd, n)    (abfd->tdata.versados_data->e[n])
90
#define RDATA(abfd, n)    (abfd->tdata.versados_data->rest[n])
91
 
92
struct ext_otr
93
{
94
  unsigned char size;
95
  char type;
96
  unsigned char map[4];
97
  unsigned char esdid;
98
  unsigned char data[200];
99
};
100
 
101
struct ext_vheader
102
{
103
  unsigned char size;
104
  char type;                    /* Record type.  */
105
  char name[10];                /* Module name.  */
106
  char rev;                     /* Module rev number.  */
107
  char lang;
108
  char vol[4];
109
  char user[2];
110
  char cat[8];
111
  char fname[8];
112
  char ext[2];
113
  char time[3];
114
  char date[3];
115
  char rest[211];
116
};
117
 
118
struct ext_esd
119
{
120
  unsigned char size;
121
  char type;
122
  unsigned char esd_entries[1];
123
};
124
 
125
#define ESD_ABS           0
126
#define ESD_COMMON        1
127
#define ESD_STD_REL_SEC   2
128
#define ESD_SHRT_REL_SEC  3
129
#define ESD_XDEF_IN_SEC   4
130
#define ESD_XDEF_IN_ABS   5
131
#define ESD_XREF_SEC      6
132
#define ESD_XREF_SYM      7
133
 
134
union ext_any
135
{
136
  unsigned char size;
137
  struct ext_vheader header;
138
  struct ext_esd esd;
139
  struct ext_otr otr;
140
};
141
 
142
/* Initialize by filling in the hex conversion array.  */
143
 
144
/* Set up the tdata information.  */
145
 
146
static bfd_boolean
147
versados_mkobject (bfd *abfd)
148
{
149
  if (abfd->tdata.versados_data == NULL)
150
    {
151
      bfd_size_type amt = sizeof (tdata_type);
152
      tdata_type *tdata = bfd_alloc (abfd, amt);
153
 
154
      if (tdata == NULL)
155
        return FALSE;
156
      abfd->tdata.versados_data = tdata;
157
      tdata->symbols = NULL;
158
      VDATA (abfd)->alert = 0x12345678;
159
    }
160
 
161
  bfd_default_set_arch_mach (abfd, bfd_arch_m68k, 0);
162
  return TRUE;
163
}
164
 
165
/* Report a problem in an S record file.  FIXME: This probably should
166
   not call fprintf, but we really do need some mechanism for printing
167
   error messages.  */
168
 
169
static asymbol *
170
versados_new_symbol (bfd *abfd,
171
                     int snum,
172
                     const char *name,
173
                     bfd_vma val,
174
                     asection *sec)
175
{
176
  asymbol *n = VDATA (abfd)->symbols + snum;
177
  n->name = name;
178
  n->value = val;
179
  n->section = sec;
180
  n->the_bfd = abfd;
181
  n->flags = 0;
182
  return n;
183
}
184
 
185
static int
186
get_record (bfd *abfd, union ext_any *ptr)
187
{
188
  if (bfd_bread (&ptr->size, (bfd_size_type) 1, abfd) != 1
189
      || (bfd_bread ((char *) ptr + 1, (bfd_size_type) ptr->size, abfd)
190
          != ptr->size))
191
    return 0;
192
  return 1;
193
}
194
 
195
static int
196
get_4 (unsigned char **pp)
197
{
198
  unsigned char *p = *pp;
199
 
200
  *pp += 4;
201
  return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | (p[3] << 0);
202
}
203
 
204
static void
205
get_10 (unsigned char **pp, char *name)
206
{
207
  char *p = (char *) *pp;
208
  int len = 10;
209
 
210
  *pp += len;
211
  while (*p != ' ' && len)
212
    {
213
      *name++ = *p++;
214
      len--;
215
    }
216
  *name = 0;
217
}
218
 
219
static char *
220
new_symbol_string (bfd *abfd, const char *name)
221
{
222
  char *n = VDATA (abfd)->strings;
223
 
224
  strcpy (VDATA (abfd)->strings, name);
225
  VDATA (abfd)->strings += strlen (VDATA (abfd)->strings) + 1;
226
  return n;
227
}
228
 
229
static void
230
process_esd (bfd *abfd, struct ext_esd *esd, int pass)
231
{
232
  /* Read through the ext def for the est entries.  */
233
  int togo = esd->size - 2;
234
  bfd_vma size;
235
  bfd_vma start;
236
  asection *sec;
237
  char name[11];
238
  unsigned char *ptr = esd->esd_entries;
239
  unsigned char *end = ptr + togo;
240
 
241
  while (ptr < end)
242
    {
243
      int scn = *ptr & 0xf;
244
      int typ = (*ptr >> 4) & 0xf;
245
 
246
      /* Declare this section.  */
247
      sprintf (name, "%d", scn);
248
      sec = bfd_make_section_old_way (abfd, strdup (name));
249
      sec->target_index = scn;
250
      EDATA (abfd, scn).section = sec;
251
      ptr++;
252
 
253
      switch (typ)
254
        {
255
        default:
256
          abort ();
257
        case ESD_XREF_SEC:
258
        case ESD_XREF_SYM:
259
          {
260
            int snum = VDATA (abfd)->ref_idx++;
261
            get_10 (&ptr, name);
262
            if (pass == 1)
263
              VDATA (abfd)->stringlen += strlen (name) + 1;
264
            else
265
              {
266
                int esidx;
267
                asymbol *s;
268
                char *n = new_symbol_string (abfd, name);
269
 
270
                s = versados_new_symbol (abfd, snum, n, (bfd_vma) 0,
271
                                         bfd_und_section_ptr);
272
                esidx = VDATA (abfd)->es_done++;
273
                RDATA (abfd, esidx - ES_BASE) = s;
274
              }
275
          }
276
          break;
277
 
278
        case ESD_ABS:
279
          size = get_4 (&ptr);
280
          start = get_4 (&ptr);
281
          break;
282
        case ESD_STD_REL_SEC:
283
        case ESD_SHRT_REL_SEC:
284
          sec->size = get_4 (&ptr);
285
          sec->flags |= SEC_ALLOC;
286
          break;
287
        case ESD_XDEF_IN_ABS:
288
          sec = (asection *) & bfd_abs_section;
289
        case ESD_XDEF_IN_SEC:
290
          {
291
            int snum = VDATA (abfd)->def_idx++;
292
            bfd_vma val;
293
 
294
            get_10 (&ptr, name);
295
            val = get_4 (&ptr);
296
            if (pass == 1)
297
              /* Just remember the symbol.  */
298
              VDATA (abfd)->stringlen += strlen (name) + 1;
299
            else
300
              {
301
                asymbol *s;
302
                char *n = new_symbol_string (abfd, name);
303
 
304
                s = versados_new_symbol (abfd, snum + VDATA (abfd)->nrefs, n,
305
                                         val, sec);
306
                s->flags |= BSF_GLOBAL;
307
              }
308
          }
309
          break;
310
        }
311
    }
312
}
313
 
314
#define R_RELWORD     1
315
#define R_RELLONG     2
316
#define R_RELWORD_NEG 3
317
#define R_RELLONG_NEG 4
318
 
319
reloc_howto_type versados_howto_table[] =
320
{
321
  HOWTO (R_RELWORD, 0, 1, 16, FALSE,
322
         0, complain_overflow_dont, 0,
323
         "+v16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
324
  HOWTO (R_RELLONG, 0, 2, 32, FALSE,
325
         0, complain_overflow_dont, 0,
326
         "+v32", TRUE, 0xffffffff, 0xffffffff, FALSE),
327
 
328
  HOWTO (R_RELWORD_NEG, 0, -1, 16, FALSE,
329
         0, complain_overflow_dont, 0,
330
         "-v16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
331
  HOWTO (R_RELLONG_NEG, 0, -2, 32, FALSE,
332
         0, complain_overflow_dont, 0,
333
         "-v32", TRUE, 0xffffffff, 0xffffffff, FALSE),
334
};
335
 
336
static int
337
get_offset (int len, unsigned char *ptr)
338
{
339
  int val = 0;
340
 
341
  if (len)
342
    {
343
      int i;
344
 
345
      val = *ptr++;
346
      if (val & 0x80)
347
        val |= ~0xff;
348
      for (i = 1; i < len; i++)
349
        val = (val << 8) | *ptr++;
350
    }
351
 
352
  return val;
353
}
354
 
355
static void
356
process_otr (bfd *abfd, struct ext_otr *otr, int pass)
357
{
358
  unsigned long shift;
359
  unsigned char *srcp = otr->data;
360
  unsigned char *endp = (unsigned char *) otr + otr->size;
361
  unsigned int bits = (otr->map[0] << 24)
362
  | (otr->map[1] << 16)
363
  | (otr->map[2] << 8)
364
  | (otr->map[3] << 0);
365
 
366
  struct esdid *esdid = &EDATA (abfd, otr->esdid - 1);
367
  unsigned char *contents = esdid->contents;
368
  int need_contents = 0;
369
  unsigned int dst_idx = esdid->pc;
370
 
371
  for (shift = ((unsigned long) 1 << 31); shift && srcp < endp; shift >>= 1)
372
    {
373
      if (bits & shift)
374
        {
375
          int flag = *srcp++;
376
          int esdids = (flag >> 5) & 0x7;
377
          int sizeinwords = ((flag >> 3) & 1) ? 2 : 1;
378
          int offsetlen = flag & 0x7;
379
          int j;
380
 
381
          if (esdids == 0)
382
            {
383
              /* A zero esdid means the new pc is the offset given.  */
384
              dst_idx += get_offset (offsetlen, srcp);
385
              srcp += offsetlen;
386
            }
387
          else
388
            {
389
              int val = get_offset (offsetlen, srcp + esdids);
390
 
391
              if (pass == 1)
392
                need_contents = 1;
393
              else
394
                for (j = 0; j < sizeinwords * 2; j++)
395
                  {
396
                    contents[dst_idx + (sizeinwords * 2) - j - 1] = val;
397
                    val >>= 8;
398
                  }
399
 
400
              for (j = 0; j < esdids; j++)
401
                {
402
                  int esdid = *srcp++;
403
 
404
                  if (esdid)
405
                    {
406
                      int rn = EDATA (abfd, otr->esdid - 1).relocs++;
407
 
408
                      if (pass == 1)
409
                        {
410
                          /* This is the first pass over the data,
411
                             just remember that we need a reloc.  */
412
                        }
413
                      else
414
                        {
415
                          arelent *n =
416
                          EDATA (abfd, otr->esdid - 1).section->relocation + rn;
417
                          n->address = dst_idx;
418
 
419
                          n->sym_ptr_ptr = (asymbol **) (size_t) esdid;
420
                          n->addend = 0;
421
                          n->howto = versados_howto_table + ((j & 1) * 2) + (sizeinwords - 1);
422
                        }
423
                    }
424
                }
425
              srcp += offsetlen;
426
              dst_idx += sizeinwords * 2;
427
            }
428
        }
429
      else
430
        {
431
          need_contents = 1;
432
          if (dst_idx < esdid->section->size)
433
            if (pass == 2)
434
              {
435
                /* Absolute code, comes in 16 bit lumps.  */
436
                contents[dst_idx] = srcp[0];
437
                contents[dst_idx + 1] = srcp[1];
438
              }
439
          dst_idx += 2;
440
          srcp += 2;
441
        }
442
    }
443
  EDATA (abfd, otr->esdid - 1).pc = dst_idx;
444
 
445
  if (!contents && need_contents)
446
    {
447
      bfd_size_type size = esdid->section->size;
448
      esdid->contents = bfd_alloc (abfd, size);
449
    }
450
}
451
 
452
static bfd_boolean
453
versados_scan (bfd *abfd)
454
{
455
  int loop = 1;
456
  int i;
457
  int j;
458
  int nsecs = 0;
459
  bfd_size_type amt;
460
 
461
  VDATA (abfd)->stringlen = 0;
462
  VDATA (abfd)->nrefs = 0;
463
  VDATA (abfd)->ndefs = 0;
464
  VDATA (abfd)->ref_idx = 0;
465
  VDATA (abfd)->def_idx = 0;
466
  VDATA (abfd)->pass_2_done = 0;
467
 
468
  while (loop)
469
    {
470
      union ext_any any;
471
 
472
      if (!get_record (abfd, &any))
473
        return TRUE;
474
      switch (any.header.type)
475
        {
476
        case VHEADER:
477
          break;
478
        case VEND:
479
          loop = 0;
480
          break;
481
        case VESTDEF:
482
          process_esd (abfd, &any.esd, 1);
483
          break;
484
        case VOTR:
485
          process_otr (abfd, &any.otr, 1);
486
          break;
487
        }
488
    }
489
 
490
  /* Now allocate space for the relocs and sections.  */
491
  VDATA (abfd)->nrefs = VDATA (abfd)->ref_idx;
492
  VDATA (abfd)->ndefs = VDATA (abfd)->def_idx;
493
  VDATA (abfd)->ref_idx = 0;
494
  VDATA (abfd)->def_idx = 0;
495
 
496
  abfd->symcount = VDATA (abfd)->nrefs + VDATA (abfd)->ndefs;
497
 
498
  for (i = 0; i < 16; i++)
499
    {
500
      struct esdid *esdid = &EDATA (abfd, i);
501
 
502
      if (esdid->section)
503
        {
504
          amt = (bfd_size_type) esdid->relocs * sizeof (arelent);
505
          esdid->section->relocation = bfd_alloc (abfd, amt);
506
 
507
          esdid->pc = 0;
508
 
509
          if (esdid->contents)
510
            esdid->section->flags |= SEC_HAS_CONTENTS | SEC_LOAD;
511
 
512
          esdid->section->reloc_count = esdid->relocs;
513
          if (esdid->relocs)
514
            esdid->section->flags |= SEC_RELOC;
515
 
516
          esdid->relocs = 0;
517
 
518
          /* Add an entry into the symbol table for it.  */
519
          nsecs++;
520
          VDATA (abfd)->stringlen += strlen (esdid->section->name) + 1;
521
        }
522
    }
523
 
524
  abfd->symcount += nsecs;
525
 
526
  amt = abfd->symcount;
527
  amt *= sizeof (asymbol);
528
  VDATA (abfd)->symbols = bfd_alloc (abfd, amt);
529
 
530
  amt = VDATA (abfd)->stringlen;
531
  VDATA (abfd)->strings = bfd_alloc (abfd, amt);
532
 
533
  if ((VDATA (abfd)->symbols == NULL && abfd->symcount > 0)
534
      || (VDATA (abfd)->strings == NULL && VDATA (abfd)->stringlen > 0))
535
    return FALSE;
536
 
537
  /* Actually fill in the section symbols,
538
     we stick them at the end of the table.  */
539
  for (j = VDATA (abfd)->nrefs + VDATA (abfd)->ndefs, i = 0; i < 16; i++)
540
    {
541
      struct esdid *esdid = &EDATA (abfd, i);
542
      asection *sec = esdid->section;
543
 
544
      if (sec)
545
        {
546
          asymbol *s = VDATA (abfd)->symbols + j;
547
          s->name = new_symbol_string (abfd, sec->name);
548
          s->section = sec;
549
          s->flags = BSF_LOCAL;
550
          s->value = 0;
551
          s->the_bfd = abfd;
552
          j++;
553
        }
554
    }
555
 
556
  if (abfd->symcount)
557
    abfd->flags |= HAS_SYMS;
558
 
559
  /* Set this to nsecs - since we've already planted the section
560
     symbols.  */
561
  VDATA (abfd)->nsecsyms = nsecs;
562
 
563
  VDATA (abfd)->ref_idx = 0;
564
 
565
  return 1;
566
}
567
 
568
/* Check whether an existing file is a versados  file.  */
569
 
570
static const bfd_target *
571
versados_object_p (bfd *abfd)
572
{
573
  struct ext_vheader ext;
574
  unsigned char len;
575
  tdata_type *tdata_save;
576
 
577
  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
578
    return NULL;
579
 
580
  if (bfd_bread (&len, (bfd_size_type) 1, abfd) != 1)
581
    {
582
      if (bfd_get_error () != bfd_error_system_call)
583
        bfd_set_error (bfd_error_wrong_format);
584
      return NULL;
585
    }
586
 
587
  if (bfd_bread (&ext.type, (bfd_size_type) len, abfd) != len)
588
    {
589
      if (bfd_get_error () != bfd_error_system_call)
590
        bfd_set_error (bfd_error_wrong_format);
591
      return NULL;
592
    }
593
 
594
  /* We guess that the language field will never be larger than 10.
595
     In sample files, it is always either 0 or 1.  Checking for this
596
     prevents confusion with Intel Hex files.  */
597
  if (ext.type != VHEADER
598
      || ext.lang > 10)
599
    {
600
      bfd_set_error (bfd_error_wrong_format);
601
      return NULL;
602
    }
603
 
604
  /* OK, looks like a record, build the tdata and read in.  */
605
  tdata_save = abfd->tdata.versados_data;
606
  if (!versados_mkobject (abfd) || !versados_scan (abfd))
607
    {
608
      abfd->tdata.versados_data = tdata_save;
609
      return NULL;
610
    }
611
 
612
  return abfd->xvec;
613
}
614
 
615
static bfd_boolean
616
versados_pass_2 (bfd *abfd)
617
{
618
  union ext_any any;
619
 
620
  if (VDATA (abfd)->pass_2_done)
621
    return 1;
622
 
623
  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
624
    return 0;
625
 
626
  VDATA (abfd)->es_done = ES_BASE;
627
 
628
  /* Read records till we get to where we want to be.  */
629
  while (1)
630
    {
631
      get_record (abfd, &any);
632
      switch (any.header.type)
633
        {
634
        case VEND:
635
          VDATA (abfd)->pass_2_done = 1;
636
          return 1;
637
        case VESTDEF:
638
          process_esd (abfd, &any.esd, 2);
639
          break;
640
        case VOTR:
641
          process_otr (abfd, &any.otr, 2);
642
          break;
643
        }
644
    }
645
}
646
 
647
static bfd_boolean
648
versados_get_section_contents (bfd *abfd,
649
                               asection *section,
650
                               void * location,
651
                               file_ptr offset,
652
                               bfd_size_type count)
653
{
654
  if (!versados_pass_2 (abfd))
655
    return FALSE;
656
 
657
  memcpy (location,
658
          EDATA (abfd, section->target_index).contents + offset,
659
          (size_t) count);
660
 
661
  return TRUE;
662
}
663
 
664
#define versados_get_section_contents_in_window \
665
  _bfd_generic_get_section_contents_in_window
666
 
667
static bfd_boolean
668
versados_set_section_contents (bfd *abfd ATTRIBUTE_UNUSED,
669
                               sec_ptr section ATTRIBUTE_UNUSED,
670
                               const void * location ATTRIBUTE_UNUSED,
671
                               file_ptr offset ATTRIBUTE_UNUSED,
672
                               bfd_size_type bytes_to_do ATTRIBUTE_UNUSED)
673
{
674
  return FALSE;
675
}
676
 
677
static int
678
versados_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
679
                         struct bfd_link_info *info ATTRIBUTE_UNUSED)
680
{
681
  return 0;
682
}
683
 
684
/* Return the amount of memory needed to read the symbol table.  */
685
 
686
static long
687
versados_get_symtab_upper_bound (bfd *abfd)
688
{
689
  return (bfd_get_symcount (abfd) + 1) * sizeof (asymbol *);
690
}
691
 
692
/* Return the symbol table.  */
693
 
694
static long
695
versados_canonicalize_symtab (bfd *abfd, asymbol **alocation)
696
{
697
  unsigned int symcount = bfd_get_symcount (abfd);
698
  unsigned int i;
699
  asymbol *s;
700
 
701
  versados_pass_2 (abfd);
702
 
703
  for (i = 0, s = VDATA (abfd)->symbols;
704
       i < symcount;
705
       s++, i++)
706
    *alocation++ = s;
707
 
708
  *alocation = NULL;
709
 
710
  return symcount;
711
}
712
 
713
static void
714
versados_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED,
715
                          asymbol *symbol,
716
                          symbol_info *ret)
717
{
718
  bfd_symbol_info (symbol, ret);
719
}
720
 
721
static void
722
versados_print_symbol (bfd *abfd,
723
                       void * afile,
724
                       asymbol *symbol,
725
                       bfd_print_symbol_type how)
726
{
727
  FILE *file = (FILE *) afile;
728
 
729
  switch (how)
730
    {
731
    case bfd_print_symbol_name:
732
      fprintf (file, "%s", symbol->name);
733
      break;
734
    default:
735
      bfd_print_symbol_vandf (abfd, (void *) file, symbol);
736
      fprintf (file, " %-5s %s",
737
               symbol->section->name,
738
               symbol->name);
739
    }
740
}
741
 
742
static long
743
versados_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED,
744
                                sec_ptr asect)
745
{
746
  return (asect->reloc_count + 1) * sizeof (arelent *);
747
}
748
 
749
static long
750
versados_canonicalize_reloc (bfd *abfd,
751
                             sec_ptr section,
752
                             arelent **relptr,
753
                             asymbol **symbols)
754
{
755
  unsigned int count;
756
  arelent *src;
757
 
758
  versados_pass_2 (abfd);
759
  src = section->relocation;
760
  if (!EDATA (abfd, section->target_index).donerel)
761
    {
762
      EDATA (abfd, section->target_index).donerel = 1;
763
      /* Translate from indexes to symptr ptrs.  */
764
      for (count = 0; count < section->reloc_count; count++)
765
        {
766
          int esdid = (int) (size_t) src[count].sym_ptr_ptr;
767
 
768
          if (esdid == 0)
769
            src[count].sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
770
          else if (esdid < ES_BASE)
771
            {
772
              /* Section relative thing.  */
773
              struct esdid *e = &EDATA (abfd, esdid - 1);
774
 
775
              src[count].sym_ptr_ptr = e->section->symbol_ptr_ptr;
776
            }
777
          else
778
            src[count].sym_ptr_ptr = symbols + esdid - ES_BASE;
779
        }
780
    }
781
 
782
  for (count = 0; count < section->reloc_count; count++)
783
    *relptr++ = src++;
784
 
785
  *relptr = 0;
786
  return section->reloc_count;
787
}
788
 
789
#define versados_close_and_cleanup                    _bfd_generic_close_and_cleanup
790
#define versados_bfd_free_cached_info                 _bfd_generic_bfd_free_cached_info
791
#define versados_new_section_hook                     _bfd_generic_new_section_hook
792
#define versados_bfd_is_target_special_symbol   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
793
#define versados_bfd_is_local_label_name              bfd_generic_is_local_label_name
794
#define versados_get_lineno                           _bfd_nosymbols_get_lineno
795
#define versados_find_nearest_line                    _bfd_nosymbols_find_nearest_line
796
#define versados_find_inliner_info                    _bfd_nosymbols_find_inliner_info
797
#define versados_make_empty_symbol                    _bfd_generic_make_empty_symbol
798
#define versados_bfd_make_debug_symbol                _bfd_nosymbols_bfd_make_debug_symbol
799
#define versados_read_minisymbols                     _bfd_generic_read_minisymbols
800
#define versados_minisymbol_to_symbol                 _bfd_generic_minisymbol_to_symbol
801
#define versados_bfd_reloc_type_lookup                _bfd_norelocs_bfd_reloc_type_lookup
802
#define versados_bfd_reloc_name_lookup          _bfd_norelocs_bfd_reloc_name_lookup
803
#define versados_set_arch_mach                        bfd_default_set_arch_mach
804
#define versados_bfd_get_relocated_section_contents   bfd_generic_get_relocated_section_contents
805
#define versados_bfd_relax_section                    bfd_generic_relax_section
806
#define versados_bfd_gc_sections                      bfd_generic_gc_sections
807
#define versados_bfd_merge_sections                   bfd_generic_merge_sections
808
#define versados_bfd_is_group_section                 bfd_generic_is_group_section
809
#define versados_bfd_discard_group                    bfd_generic_discard_group
810
#define versados_section_already_linked               _bfd_generic_section_already_linked
811
#define versados_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
812
#define versados_bfd_link_hash_table_free             _bfd_generic_link_hash_table_free
813
#define versados_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
814
#define versados_bfd_link_just_syms                   _bfd_generic_link_just_syms
815
#define versados_bfd_final_link                       _bfd_generic_final_link
816
#define versados_bfd_link_split_section               _bfd_generic_link_split_section
817
 
818
const bfd_target versados_vec =
819
{
820
  "versados",                   /* Name.  */
821
  bfd_target_versados_flavour,
822
  BFD_ENDIAN_BIG,               /* Target byte order.  */
823
  BFD_ENDIAN_BIG,               /* Target headers byte order.  */
824
  (HAS_RELOC | EXEC_P |         /* Object flags.  */
825
   HAS_LINENO | HAS_DEBUG |
826
   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
827
  (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
828
   | SEC_ALLOC | SEC_LOAD | SEC_RELOC),         /* Section flags.  */
829
  0,                             /* Leading underscore.  */
830
  ' ',                          /* AR_pad_char.  */
831
  16,                           /* AR_max_namelen.  */
832
  bfd_getb64, bfd_getb_signed_64, bfd_putb64,
833
  bfd_getb32, bfd_getb_signed_32, bfd_putb32,
834
  bfd_getb16, bfd_getb_signed_16, bfd_putb16,   /* Data.  */
835
  bfd_getb64, bfd_getb_signed_64, bfd_putb64,
836
  bfd_getb32, bfd_getb_signed_32, bfd_putb32,
837
  bfd_getb16, bfd_getb_signed_16, bfd_putb16,   /* Headers.  */
838
 
839
  {
840
    _bfd_dummy_target,
841
    versados_object_p,          /* bfd_check_format.  */
842
    _bfd_dummy_target,
843
    _bfd_dummy_target,
844
  },
845
  {
846
    bfd_false,
847
    versados_mkobject,
848
    _bfd_generic_mkarchive,
849
    bfd_false,
850
  },
851
  {                             /* bfd_write_contents.  */
852
    bfd_false,
853
    bfd_false,
854
    _bfd_write_archive_contents,
855
    bfd_false,
856
  },
857
 
858
  BFD_JUMP_TABLE_GENERIC (versados),
859
  BFD_JUMP_TABLE_COPY (_bfd_generic),
860
  BFD_JUMP_TABLE_CORE (_bfd_nocore),
861
  BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
862
  BFD_JUMP_TABLE_SYMBOLS (versados),
863
  BFD_JUMP_TABLE_RELOCS (versados),
864
  BFD_JUMP_TABLE_WRITE (versados),
865
  BFD_JUMP_TABLE_LINK (versados),
866
  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
867
 
868
  NULL,
869
 
870
  NULL
871
};

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.