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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [bfd/] [versados.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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