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