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