opcodes/ChangeLog
[deliverable/binutils-gdb.git] / bfd / oasys.c
CommitLineData
252b5132 1/* BFD back-end for oasys objects.
68bfbfcc 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2001,
0aabe54e 3 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011
4f608e79 4 Free Software Foundation, Inc.
252b5132
RH
5 Written by Steve Chamberlain of Cygnus Support, <sac@cygnus.com>.
6
42ef282f 7 This file is part of BFD, the Binary File Descriptor library.
252b5132 8
42ef282f
NC
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
cd123cb7 11 the Free Software Foundation; either version 3 of the License, or
42ef282f 12 (at your option) any later version.
252b5132 13
42ef282f
NC
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.
252b5132 18
42ef282f
NC
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
cd123cb7
NC
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
252b5132
RH
23
24#define UNDERSCORE_HACK 1
252b5132 25#include "sysdep.h"
3db64b00 26#include "bfd.h"
3882b010 27#include "safe-ctype.h"
252b5132
RH
28#include "libbfd.h"
29#include "oasys.h"
30#include "liboasys.h"
31
42ef282f 32/* Read in all the section data and relocation stuff too. */
252b5132 33
b34976b6 34static bfd_boolean
116c20d2 35oasys_read_record (bfd *abfd, oasys_record_union_type *record)
252b5132 36{
dc810e39 37 bfd_size_type amt = sizeof (record->header);
116c20d2
NC
38
39 if (bfd_bread ((void *) record, amt, abfd) != amt)
b34976b6 40 return FALSE;
252b5132 41
dc810e39
AM
42 amt = record->header.length - sizeof (record->header);
43 if ((long) amt <= 0)
b34976b6 44 return TRUE;
116c20d2 45 if (bfd_bread ((void *) ((char *) record + sizeof (record->header)), amt, abfd)
dc810e39 46 != amt)
b34976b6
AM
47 return FALSE;
48 return TRUE;
252b5132 49}
dc810e39 50
252b5132 51static size_t
116c20d2 52oasys_string_length (oasys_record_union_type *record)
252b5132
RH
53{
54 return record->header.length
55 - ((char *) record->symbol.name - (char *) record);
56}
57
116c20d2
NC
58/* Slurp the symbol table by reading in all the records at the start file
59 till we get to the first section record.
252b5132 60
116c20d2
NC
61 We'll sort the symbolss into two lists, defined and undefined. The
62 undefined symbols will be placed into the table according to their
63 refno.
252b5132 64
116c20d2
NC
65 We do this by placing all undefined symbols at the front of the table
66 moving in, and the defined symbols at the end of the table moving back. */
252b5132 67
b34976b6 68static bfd_boolean
116c20d2 69oasys_slurp_symbol_table (bfd *const abfd)
252b5132
RH
70{
71 oasys_record_union_type record;
72 oasys_data_type *data = OASYS_DATA (abfd);
b34976b6 73 bfd_boolean loop = TRUE;
252b5132
RH
74 asymbol *dest_defined;
75 asymbol *dest;
76 char *string_ptr;
dc810e39 77 bfd_size_type amt;
252b5132 78
116c20d2
NC
79 if (data->symbols != NULL)
80 return TRUE;
81
82 /* Buy enough memory for all the symbols and all the names. */
dc810e39
AM
83 amt = abfd->symcount;
84 amt *= sizeof (asymbol);
116c20d2 85 data->symbols = bfd_alloc (abfd, amt);
dc810e39
AM
86
87 amt = data->symbol_string_length;
252b5132 88#ifdef UNDERSCORE_HACK
116c20d2 89 /* Buy 1 more char for each symbol to keep the underscore in. */
dc810e39 90 amt += abfd->symcount;
252b5132 91#endif
dc810e39
AM
92 data->strings = bfd_alloc (abfd, amt);
93
252b5132 94 if (!data->symbols || !data->strings)
b34976b6 95 return FALSE;
252b5132
RH
96
97 dest_defined = data->symbols + abfd->symcount - 1;
98
99 string_ptr = data->strings;
100 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
b34976b6 101 return FALSE;
252b5132
RH
102 while (loop)
103 {
252b5132 104 if (! oasys_read_record (abfd, &record))
b34976b6 105 return FALSE;
116c20d2 106
252b5132
RH
107 switch (record.header.type)
108 {
109 case oasys_record_is_header_enum:
110 break;
111 case oasys_record_is_local_enum:
112 case oasys_record_is_symbol_enum:
113 {
114 int flag = record.header.type == (int) oasys_record_is_local_enum ?
115 (BSF_LOCAL) : (BSF_GLOBAL | BSF_EXPORT);
116
252b5132
RH
117 size_t length = oasys_string_length (&record);
118 switch (record.symbol.relb & RELOCATION_TYPE_BITS)
119 {
120 case RELOCATION_TYPE_ABS:
121 dest = dest_defined--;
122 dest->section = bfd_abs_section_ptr;
123 dest->flags = 0;
124
125 break;
126 case RELOCATION_TYPE_REL:
127 dest = dest_defined--;
128 dest->section =
129 OASYS_DATA (abfd)->sections[record.symbol.relb &
130 RELOCATION_SECT_BITS];
131 if (record.header.type == (int) oasys_record_is_local_enum)
132 {
133 dest->flags = BSF_LOCAL;
134 if (dest->section == (asection *) (~0))
135 {
136 /* It seems that sometimes internal symbols are tied up, but
137 still get output, even though there is no
138 section */
139 dest->section = 0;
140 }
141 }
142 else
116c20d2 143 dest->flags = flag;
252b5132
RH
144 break;
145 case RELOCATION_TYPE_UND:
dc810e39 146 dest = data->symbols + H_GET_16 (abfd, record.symbol.refno);
252b5132
RH
147 dest->section = bfd_und_section_ptr;
148 break;
149 case RELOCATION_TYPE_COM:
150 dest = dest_defined--;
151 dest->name = string_ptr;
152 dest->the_bfd = abfd;
252b5132 153 dest->section = bfd_com_section_ptr;
252b5132
RH
154 break;
155 default:
156 dest = dest_defined--;
116c20d2 157 BFD_ASSERT (FALSE);
252b5132
RH
158 break;
159 }
160 dest->name = string_ptr;
161 dest->the_bfd = abfd;
116c20d2 162 dest->udata.p = NULL;
dc810e39 163 dest->value = H_GET_32 (abfd, record.symbol.value);
252b5132
RH
164
165#ifdef UNDERSCORE_HACK
166 if (record.symbol.name[0] != '_')
167 {
168 string_ptr[0] = '_';
169 string_ptr++;
170 }
171#endif
172 memcpy (string_ptr, record.symbol.name, length);
173
252b5132
RH
174 string_ptr[length] = 0;
175 string_ptr += length + 1;
176 }
177 break;
178 default:
b34976b6 179 loop = FALSE;
252b5132
RH
180 }
181 }
b34976b6 182 return TRUE;
252b5132
RH
183}
184
185static long
116c20d2 186oasys_get_symtab_upper_bound (bfd *const abfd)
252b5132
RH
187{
188 if (! oasys_slurp_symbol_table (abfd))
189 return -1;
190
191 return (abfd->symcount + 1) * (sizeof (oasys_symbol_type *));
192}
193
252b5132
RH
194extern const bfd_target oasys_vec;
195
116c20d2
NC
196static long
197oasys_canonicalize_symtab (bfd *abfd, asymbol **location)
252b5132
RH
198{
199 asymbol *symbase;
200 unsigned int counter;
116c20d2 201
82e51918 202 if (! oasys_slurp_symbol_table (abfd))
116c20d2
NC
203 return -1;
204
252b5132
RH
205 symbase = OASYS_DATA (abfd)->symbols;
206 for (counter = 0; counter < abfd->symcount; counter++)
116c20d2
NC
207 *(location++) = symbase++;
208
252b5132
RH
209 *location = 0;
210 return abfd->symcount;
211}
212
116c20d2 213/* Archive stuff. */
252b5132
RH
214
215static const bfd_target *
116c20d2 216oasys_archive_p (bfd *abfd)
252b5132
RH
217{
218 oasys_archive_header_type header;
219 oasys_extarchive_header_type header_ext;
220 unsigned int i;
221 file_ptr filepos;
dc810e39 222 bfd_size_type amt;
252b5132 223
dc810e39
AM
224 amt = sizeof (header_ext);
225 if (bfd_seek (abfd, (file_ptr) 0, 0) != 0
116c20d2 226 || bfd_bread ((void *) &header_ext, amt, abfd) != amt)
252b5132
RH
227 {
228 if (bfd_get_error () != bfd_error_system_call)
229 bfd_set_error (bfd_error_wrong_format);
230 return NULL;
231 }
232
dc810e39
AM
233 header.version = H_GET_32 (abfd, header_ext.version);
234 header.mod_count = H_GET_32 (abfd, header_ext.mod_count);
235 header.mod_tbl_offset = H_GET_32 (abfd, header_ext.mod_tbl_offset);
236 header.sym_tbl_size = H_GET_32 (abfd, header_ext.sym_tbl_size);
237 header.sym_count = H_GET_32 (abfd, header_ext.sym_count);
238 header.sym_tbl_offset = H_GET_32 (abfd, header_ext.sym_tbl_offset);
239 header.xref_count = H_GET_32 (abfd, header_ext.xref_count);
240 header.xref_lst_offset = H_GET_32 (abfd, header_ext.xref_lst_offset);
252b5132 241
116c20d2
NC
242 /* There isn't a magic number in an Oasys archive, so the best we
243 can do to verify reasonableness is to make sure that the values in
244 the header are too weird. */
245
246 if (header.version > 10000
247 || header.mod_count > 10000
248 || header.sym_count > 100000
249 || header.xref_count > 100000)
250 return NULL;
251
252 /* That all worked, let's buy the space for the header and read in
253 the headers. */
252b5132 254 {
dc810e39
AM
255 oasys_ar_data_type *ar;
256 oasys_module_info_type *module;
252b5132
RH
257 oasys_module_table_type record;
258
dc810e39 259 amt = sizeof (oasys_ar_data_type);
116c20d2 260 ar = bfd_alloc (abfd, amt);
dc810e39
AM
261
262 amt = header.mod_count;
263 amt *= sizeof (oasys_module_info_type);
116c20d2 264 module = bfd_alloc (abfd, amt);
dc810e39 265
252b5132
RH
266 if (!ar || !module)
267 return NULL;
268
269 abfd->tdata.oasys_ar_data = ar;
270 ar->module = module;
271 ar->module_count = header.mod_count;
272
273 filepos = header.mod_tbl_offset;
274 for (i = 0; i < header.mod_count; i++)
275 {
276 if (bfd_seek (abfd, filepos, SEEK_SET) != 0)
277 return NULL;
278
116c20d2 279 /* There are two ways of specifying the archive header. */
252b5132
RH
280 {
281 oasys_extmodule_table_type_b_type record_ext;
dc810e39
AM
282
283 amt = sizeof (record_ext);
116c20d2 284 if (bfd_bread ((void *) &record_ext, amt, abfd) != amt)
252b5132
RH
285 return NULL;
286
dc810e39
AM
287 record.mod_size = H_GET_32 (abfd, record_ext.mod_size);
288 record.file_offset = H_GET_32 (abfd, record_ext.file_offset);
252b5132 289
dc810e39
AM
290 record.dep_count = H_GET_32 (abfd, record_ext.dep_count);
291 record.depee_count = H_GET_32 (abfd, record_ext.depee_count);
292 record.sect_count = H_GET_32 (abfd, record_ext.sect_count);
293 record.module_name_size = H_GET_32 (abfd,
294 record_ext.mod_name_length);
252b5132 295
dc810e39
AM
296 amt = record.module_name_size;
297 module[i].name = bfd_alloc (abfd, amt + 1);
252b5132
RH
298 if (!module[i].name)
299 return NULL;
116c20d2 300 if (bfd_bread ((void *) module[i].name, amt, abfd) != amt)
252b5132
RH
301 return NULL;
302 module[i].name[record.module_name_size] = 0;
dc810e39
AM
303 filepos += (sizeof (record_ext)
304 + record.dep_count * 4
305 + record.module_name_size + 1);
252b5132
RH
306 }
307
252b5132
RH
308 module[i].size = record.mod_size;
309 module[i].pos = record.file_offset;
310 module[i].abfd = 0;
311 }
252b5132
RH
312 }
313 return abfd->xvec;
314}
315
b34976b6 316static bfd_boolean
116c20d2 317oasys_mkobject (bfd *abfd)
252b5132 318{
dc810e39 319 bfd_size_type amt = sizeof (oasys_data_type);
252b5132 320
116c20d2 321 abfd->tdata.oasys_obj_data = bfd_alloc (abfd, amt);
252b5132 322
116c20d2 323 return abfd->tdata.oasys_obj_data != NULL;
252b5132
RH
324}
325
116c20d2
NC
326/* The howto table is build using the top two bits of a reloc byte to
327 index into it. The bits are PCREL,WORD/LONG. */
252b5132 328
252b5132
RH
329static reloc_howto_type howto_table[] =
330{
331
116c20d2
NC
332 HOWTO (0, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, 0, "abs16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
333 HOWTO (0, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, 0, "abs32", TRUE, 0xffffffff, 0xffffffff, FALSE),
334 HOWTO (0, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0, "pcrel16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
335 HOWTO (0, 0, 2, 32, TRUE, 0, complain_overflow_signed, 0, "pcrel32", TRUE, 0xffffffff, 0xffffffff, FALSE)
252b5132
RH
336};
337
116c20d2
NC
338/* Read in all the section data and relocation stuff too. */
339
b34976b6 340static bfd_boolean
116c20d2 341oasys_slurp_section_data (bfd *const abfd)
252b5132
RH
342{
343 oasys_record_union_type record;
344 oasys_data_type *data = OASYS_DATA (abfd);
b34976b6 345 bfd_boolean loop = TRUE;
252b5132 346 oasys_per_section_type *per;
252b5132 347 asection *s;
dc810e39 348 bfd_size_type amt;
252b5132 349
116c20d2
NC
350 /* See if the data has been slurped already. */
351 for (s = abfd->sections; s != NULL; s = s->next)
252b5132
RH
352 {
353 per = oasys_per_section (s);
82e51918 354 if (per->initialized)
b34976b6 355 return TRUE;
252b5132
RH
356 }
357
358 if (data->first_data_record == 0)
b34976b6 359 return TRUE;
252b5132
RH
360
361 if (bfd_seek (abfd, data->first_data_record, SEEK_SET) != 0)
b34976b6 362 return FALSE;
116c20d2 363
252b5132
RH
364 while (loop)
365 {
366 if (! oasys_read_record (abfd, &record))
b34976b6 367 return FALSE;
116c20d2 368
252b5132
RH
369 switch (record.header.type)
370 {
371 case oasys_record_is_header_enum:
372 break;
373 case oasys_record_is_data_enum:
374 {
252b5132
RH
375 bfd_byte *src = record.data.data;
376 bfd_byte *end_src = ((bfd_byte *) & record) + record.header.length;
377 bfd_byte *dst_ptr;
378 bfd_byte *dst_base_ptr;
379 unsigned int relbit;
380 unsigned int count;
381 asection *section =
382 data->sections[record.data.relb & RELOCATION_SECT_BITS];
383 bfd_vma dst_offset;
384
385 per = oasys_per_section (section);
386
82e51918 387 if (! per->initialized)
252b5132 388 {
6edfbbad
DJ
389 arelent **relpp;
390
116c20d2 391 per->data = bfd_zalloc (abfd, section->size);
252b5132 392 if (!per->data)
b34976b6 393 return FALSE;
6edfbbad
DJ
394 relpp = &section->relocation;
395 per->reloc_tail_ptr = (oasys_reloc_type **) relpp;
b34976b6
AM
396 per->had_vma = FALSE;
397 per->initialized = TRUE;
252b5132
RH
398 section->reloc_count = 0;
399 section->flags = SEC_ALLOC;
400 }
401
dc810e39 402 dst_offset = H_GET_32 (abfd, record.data.addr);
82e51918 403 if (! per->had_vma)
252b5132 404 {
116c20d2 405 /* Take the first vma we see as the base. */
252b5132 406 section->vma = dst_offset;
b34976b6 407 per->had_vma = TRUE;
252b5132
RH
408 }
409
410 dst_offset -= section->vma;
411
412 dst_base_ptr = oasys_per_section (section)->data;
413 dst_ptr = oasys_per_section (section)->data +
414 dst_offset;
415
416 if (src < end_src)
116c20d2
NC
417 section->flags |= SEC_LOAD | SEC_HAS_CONTENTS;
418
252b5132
RH
419 while (src < end_src)
420 {
421 unsigned char mod_byte = *src++;
422 size_t gap = end_src - src;
423
424 count = 8;
425 if (mod_byte == 0 && gap >= 8)
426 {
427 dst_ptr[0] = src[0];
428 dst_ptr[1] = src[1];
429 dst_ptr[2] = src[2];
430 dst_ptr[3] = src[3];
431 dst_ptr[4] = src[4];
432 dst_ptr[5] = src[5];
433 dst_ptr[6] = src[6];
434 dst_ptr[7] = src[7];
435 dst_ptr += 8;
436 src += 8;
437 }
438 else
439 {
440 for (relbit = 1; count-- != 0 && src < end_src; relbit <<= 1)
441 {
442 if (relbit & mod_byte)
443 {
444 unsigned char reloc = *src;
116c20d2 445 /* This item needs to be relocated. */
252b5132
RH
446 switch (reloc & RELOCATION_TYPE_BITS)
447 {
448 case RELOCATION_TYPE_ABS:
252b5132
RH
449 break;
450
451 case RELOCATION_TYPE_REL:
452 {
116c20d2 453 /* Relocate the item relative to the section. */
dc810e39
AM
454 oasys_reloc_type *r;
455
456 amt = sizeof (oasys_reloc_type);
116c20d2 457 r = bfd_alloc (abfd, amt);
252b5132 458 if (!r)
b34976b6 459 return FALSE;
252b5132
RH
460 *(per->reloc_tail_ptr) = r;
461 per->reloc_tail_ptr = &r->next;
116c20d2
NC
462 r->next = NULL;
463 /* Reference to undefined symbol. */
252b5132 464 src++;
116c20d2 465 /* There is no symbol. */
252b5132 466 r->symbol = 0;
116c20d2 467 /* Work out the howto. */
252b5132 468 abort ();
252b5132
RH
469 r->relent.address = dst_ptr - dst_base_ptr;
470 r->relent.howto = &howto_table[reloc >> 6];
116c20d2 471 r->relent.sym_ptr_ptr = NULL;
252b5132
RH
472 section->reloc_count++;
473
82e51918
AM
474 /* Fake up the data to look like
475 it's got the -ve pc in it, this
476 makes it much easier to convert
477 into other formats. This is done
478 by hitting the addend. */
479 if (r->relent.howto->pc_relative)
480 r->relent.addend -= dst_ptr - dst_base_ptr;
252b5132
RH
481 }
482 break;
483
252b5132
RH
484 case RELOCATION_TYPE_UND:
485 {
dc810e39
AM
486 oasys_reloc_type *r;
487
488 amt = sizeof (oasys_reloc_type);
116c20d2 489 r = bfd_alloc (abfd, amt);
252b5132 490 if (!r)
b34976b6 491 return FALSE;
252b5132
RH
492 *(per->reloc_tail_ptr) = r;
493 per->reloc_tail_ptr = &r->next;
116c20d2
NC
494 r->next = NULL;
495 /* Reference to undefined symbol. */
252b5132 496 src++;
116c20d2 497 /* Get symbol number. */
252b5132 498 r->symbol = (src[0] << 8) | src[1];
116c20d2 499 /* Work out the howto. */
252b5132
RH
500 abort ();
501
252b5132
RH
502 r->relent.addend = 0;
503 r->relent.address = dst_ptr - dst_base_ptr;
504 r->relent.howto = &howto_table[reloc >> 6];
116c20d2 505 r->relent.sym_ptr_ptr = NULL;
252b5132
RH
506 section->reloc_count++;
507
508 src += 2;
82e51918
AM
509 /* Fake up the data to look like
510 it's got the -ve pc in it, this
511 makes it much easier to convert
512 into other formats. This is done
513 by hitting the addend. */
514 if (r->relent.howto->pc_relative)
515 r->relent.addend -= dst_ptr - dst_base_ptr;
252b5132
RH
516 }
517 break;
518 case RELOCATION_TYPE_COM:
519 BFD_FAIL ();
520 }
521 }
522 *dst_ptr++ = *src++;
523 }
524 }
525 }
526 }
527 break;
528 case oasys_record_is_local_enum:
529 case oasys_record_is_symbol_enum:
530 case oasys_record_is_section_enum:
531 break;
532 default:
b34976b6 533 loop = FALSE;
252b5132
RH
534 }
535 }
536
b34976b6 537 return TRUE;
252b5132
RH
538
539}
540
116c20d2
NC
541#define MAX_SECS 16
542
543static const bfd_target *
544oasys_object_p (bfd *abfd)
545{
546 oasys_data_type *oasys;
547 oasys_data_type *save = OASYS_DATA (abfd);
548 bfd_boolean loop = TRUE;
549 bfd_boolean had_usefull = FALSE;
550
551 abfd->tdata.oasys_obj_data = 0;
552 oasys_mkobject (abfd);
553 oasys = OASYS_DATA (abfd);
554 memset ((void *) oasys->sections, 0xff, sizeof (oasys->sections));
555
556 /* Point to the start of the file. */
557 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
558 goto fail;
559 oasys->symbol_string_length = 0;
560
561 /* Inspect the records, but only keep the section info -
562 remember the size of the symbols. */
563 oasys->first_data_record = 0;
564 while (loop)
565 {
566 oasys_record_union_type record;
567 if (! oasys_read_record (abfd, &record))
568 goto fail;
569 if ((size_t) record.header.length < (size_t) sizeof (record.header))
570 goto fail;
571
572 switch ((oasys_record_enum_type) (record.header.type))
573 {
574 case oasys_record_is_header_enum:
575 had_usefull = TRUE;
576 break;
577 case oasys_record_is_symbol_enum:
578 case oasys_record_is_local_enum:
579 /* Count symbols and remember their size for a future malloc. */
580 abfd->symcount++;
581 oasys->symbol_string_length += 1 + oasys_string_length (&record);
582 had_usefull = TRUE;
583 break;
584 case oasys_record_is_section_enum:
585 {
586 asection *s;
587 char *buffer;
588 unsigned int section_number;
589
590 if (record.section.header.length != sizeof (record.section))
591 goto fail;
592
593 buffer = bfd_alloc (abfd, (bfd_size_type) 3);
594 if (!buffer)
595 goto fail;
596 section_number = record.section.relb & RELOCATION_SECT_BITS;
597 sprintf (buffer, "%u", section_number);
598 s = bfd_make_section (abfd, buffer);
599 oasys->sections[section_number] = s;
600 switch (record.section.relb & RELOCATION_TYPE_BITS)
601 {
602 case RELOCATION_TYPE_ABS:
603 case RELOCATION_TYPE_REL:
604 break;
605 case RELOCATION_TYPE_UND:
606 case RELOCATION_TYPE_COM:
607 BFD_FAIL ();
608 }
609
610 s->size = H_GET_32 (abfd, record.section.value);
611 s->vma = H_GET_32 (abfd, record.section.vma);
612 s->flags = 0;
613 had_usefull = TRUE;
614 }
615 break;
616 case oasys_record_is_data_enum:
617 oasys->first_data_record = bfd_tell (abfd) - record.header.length;
618 case oasys_record_is_debug_enum:
619 case oasys_record_is_module_enum:
620 case oasys_record_is_named_section_enum:
621 case oasys_record_is_end_enum:
622 if (! had_usefull)
623 goto fail;
624 loop = FALSE;
625 break;
626 default:
627 goto fail;
628 }
629 }
630 oasys->symbols = NULL;
631
632 /* Oasys support several architectures, but I can't see a simple way
633 to discover which one is in a particular file - we'll guess. */
634 bfd_default_set_arch_mach (abfd, bfd_arch_m68k, 0);
635 if (abfd->symcount != 0)
636 abfd->flags |= HAS_SYMS;
637
638 /* We don't know if a section has data until we've read it. */
639 oasys_slurp_section_data (abfd);
640
641 return abfd->xvec;
642
643fail:
644 (void) bfd_release (abfd, oasys);
645 abfd->tdata.oasys_obj_data = save;
646 return NULL;
647}
648
649
650static void
651oasys_get_symbol_info (bfd *ignore_abfd ATTRIBUTE_UNUSED,
652 asymbol *symbol,
653 symbol_info *ret)
654{
655 bfd_symbol_info (symbol, ret);
656
657 if (!symbol->section)
658 ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A';
659}
660
661static void
662oasys_print_symbol (bfd *abfd, void * afile, asymbol *symbol, bfd_print_symbol_type how)
663{
664 FILE *file = (FILE *) afile;
665
666 switch (how)
667 {
668 case bfd_print_symbol_name:
669 case bfd_print_symbol_more:
670 fprintf (file, "%s", symbol->name);
671 break;
672 case bfd_print_symbol_all:
673 {
674 const char *section_name = symbol->section == NULL ?
675 (const char *) "*abs" : symbol->section->name;
676
677 bfd_print_symbol_vandf (abfd, (void *) file, symbol);
678
679 fprintf (file, " %-5s %s",
680 section_name,
681 symbol->name);
682 }
683 break;
684 }
685}
686
b34976b6 687static bfd_boolean
116c20d2 688oasys_new_section_hook (bfd *abfd, asection *newsect)
252b5132 689{
252b5132 690 if (!newsect->used_by_bfd)
f592407e
AM
691 {
692 newsect->used_by_bfd
693 = bfd_alloc (abfd, (bfd_size_type) sizeof (oasys_per_section_type));
694 if (!newsect->used_by_bfd)
695 return FALSE;
696 }
116c20d2 697 oasys_per_section (newsect)->data = NULL;
252b5132
RH
698 oasys_per_section (newsect)->section = newsect;
699 oasys_per_section (newsect)->offset = 0;
b34976b6 700 oasys_per_section (newsect)->initialized = FALSE;
252b5132 701 newsect->alignment_power = 1;
252b5132 702
116c20d2 703 /* Turn the section string into an index. */
252b5132
RH
704 sscanf (newsect->name, "%u", &newsect->target_index);
705
f592407e 706 return _bfd_generic_new_section_hook (abfd, newsect);
252b5132
RH
707}
708
709
710static long
116c20d2 711oasys_get_reloc_upper_bound (bfd *abfd, sec_ptr asect)
252b5132
RH
712{
713 if (! oasys_slurp_section_data (abfd))
714 return -1;
715 return (asect->reloc_count + 1) * sizeof (arelent *);
716}
717
b34976b6 718static bfd_boolean
116c20d2
NC
719oasys_get_section_contents (bfd *abfd,
720 sec_ptr section,
721 void * location,
722 file_ptr offset,
723 bfd_size_type count)
252b5132 724{
68bfbfcc 725 oasys_per_section_type *p = oasys_per_section (section);
116c20d2 726
252b5132 727 oasys_slurp_section_data (abfd);
116c20d2 728
82e51918 729 if (! p->initialized)
116c20d2 730 (void) memset (location, 0, (size_t) count);
252b5132 731 else
116c20d2
NC
732 (void) memcpy (location, (void *) (p->data + offset), (size_t) count);
733
b34976b6 734 return TRUE;
252b5132
RH
735}
736
116c20d2
NC
737static long
738oasys_canonicalize_reloc (bfd *ignore_abfd ATTRIBUTE_UNUSED,
739 sec_ptr section,
740 arelent **relptr,
741 asymbol **symbols ATTRIBUTE_UNUSED)
252b5132
RH
742{
743 unsigned int reloc_count = 0;
744 oasys_reloc_type *src = (oasys_reloc_type *) (section->relocation);
252b5132 745
116c20d2
NC
746 if (src != NULL)
747 abort ();
748
749 *relptr = NULL;
252b5132
RH
750 return section->reloc_count = reloc_count;
751}
752
753
116c20d2 754/* Writing. */
252b5132 755
116c20d2 756/* Calculate the checksum and write one record. */
252b5132 757
b34976b6 758static bfd_boolean
116c20d2
NC
759oasys_write_record (bfd *abfd,
760 oasys_record_enum_type type,
761 oasys_record_union_type *record,
762 size_t size)
252b5132
RH
763{
764 int checksum;
765 size_t i;
766 unsigned char *ptr;
767
768 record->header.length = size;
769 record->header.type = (int) type;
770 record->header.check_sum = 0;
771 record->header.fill = 0;
772 ptr = (unsigned char *) &record->pad[0];
773 checksum = 0;
774 for (i = 0; i < size; i++)
116c20d2 775 checksum += *ptr++;
252b5132 776 record->header.check_sum = 0xff & (-checksum);
116c20d2 777 if (bfd_bwrite ((void *) record, (bfd_size_type) size, abfd) != size)
b34976b6
AM
778 return FALSE;
779 return TRUE;
252b5132
RH
780}
781
782
116c20d2
NC
783/* Write out all the symbols. */
784
b34976b6 785static bfd_boolean
116c20d2 786oasys_write_syms (bfd *abfd)
252b5132
RH
787{
788 unsigned int count;
789 asymbol **generic = bfd_get_outsymbols (abfd);
91d6fa6a 790 unsigned int sym_index = 0;
116c20d2 791
252b5132
RH
792 for (count = 0; count < bfd_get_symcount (abfd); count++)
793 {
252b5132 794 oasys_symbol_record_type symbol;
dc810e39 795 asymbol *const g = generic[count];
dc810e39 796 const char *src = g->name;
252b5132
RH
797 char *dst = symbol.name;
798 unsigned int l = 0;
799
800 if (bfd_is_com_section (g->section))
801 {
802 symbol.relb = RELOCATION_TYPE_COM;
91d6fa6a
NC
803 H_PUT_16 (abfd, sym_index, symbol.refno);
804 sym_index++;
252b5132
RH
805 }
806 else if (bfd_is_abs_section (g->section))
807 {
808 symbol.relb = RELOCATION_TYPE_ABS;
dc810e39 809 H_PUT_16 (abfd, 0, symbol.refno);
252b5132
RH
810 }
811 else if (bfd_is_und_section (g->section))
812 {
813 symbol.relb = RELOCATION_TYPE_UND;
91d6fa6a
NC
814 H_PUT_16 (abfd, sym_index, symbol.refno);
815 /* Overload the value field with the output sym_index number */
816 sym_index++;
252b5132
RH
817 }
818 else if (g->flags & BSF_DEBUGGING)
116c20d2
NC
819 /* Throw it away. */
820 continue;
252b5132
RH
821 else
822 {
116c20d2
NC
823 if (g->section == NULL)
824 /* Sometime, the oasys tools give out a symbol with illegal
825 bits in it, we'll output it in the same broken way. */
826 symbol.relb = RELOCATION_TYPE_REL | 0;
252b5132 827 else
116c20d2
NC
828 symbol.relb = RELOCATION_TYPE_REL | g->section->output_section->target_index;
829
dc810e39 830 H_PUT_16 (abfd, 0, symbol.refno);
252b5132 831 }
116c20d2 832
252b5132
RH
833#ifdef UNDERSCORE_HACK
834 if (src[l] == '_')
835 dst[l++] = '.';
836#endif
837 while (src[l])
838 {
839 dst[l] = src[l];
840 l++;
841 }
842
dc810e39 843 H_PUT_32 (abfd, g->value, symbol.value);
252b5132 844
252b5132
RH
845 if (g->flags & BSF_LOCAL)
846 {
847 if (! oasys_write_record (abfd,
848 oasys_record_is_local_enum,
849 (oasys_record_union_type *) & symbol,
850 offsetof (oasys_symbol_record_type,
851 name[0]) + l))
b34976b6 852 return FALSE;
252b5132
RH
853 }
854 else
855 {
856 if (! oasys_write_record (abfd,
857 oasys_record_is_symbol_enum,
858 (oasys_record_union_type *) & symbol,
859 offsetof (oasys_symbol_record_type,
860 name[0]) + l))
b34976b6 861 return FALSE;
252b5132 862 }
91d6fa6a 863 g->value = sym_index - 1;
252b5132
RH
864 }
865
b34976b6 866 return TRUE;
252b5132
RH
867}
868
116c20d2 869/* Write a section header for each section. */
252b5132 870
b34976b6 871static bfd_boolean
116c20d2 872oasys_write_sections (bfd *abfd)
252b5132
RH
873{
874 asection *s;
875 static oasys_section_record_type out;
876
116c20d2 877 for (s = abfd->sections; s != NULL; s = s->next)
252b5132 878 {
3882b010 879 if (!ISDIGIT (s->name[0]))
252b5132
RH
880 {
881 (*_bfd_error_handler)
882 (_("%s: can not represent section `%s' in oasys"),
883 bfd_get_filename (abfd), s->name);
884 bfd_set_error (bfd_error_nonrepresentable_section);
b34976b6 885 return FALSE;
252b5132
RH
886 }
887 out.relb = RELOCATION_TYPE_REL | s->target_index;
eea6121a 888 H_PUT_32 (abfd, s->size, out.value);
dc810e39 889 H_PUT_32 (abfd, s->vma, out.vma);
252b5132
RH
890
891 if (! oasys_write_record (abfd,
892 oasys_record_is_section_enum,
893 (oasys_record_union_type *) & out,
894 sizeof (out)))
b34976b6 895 return FALSE;
252b5132 896 }
b34976b6 897 return TRUE;
252b5132
RH
898}
899
b34976b6 900static bfd_boolean
116c20d2 901oasys_write_header (bfd *abfd)
252b5132 902{
116c20d2 903 /* Create and write the header. */
252b5132
RH
904 oasys_header_record_type r;
905 size_t length = strlen (abfd->filename);
116c20d2 906
252b5132 907 if (length > (size_t) sizeof (r.module_name))
116c20d2 908 length = sizeof (r.module_name);
3e3c397d
JK
909 else if (length < (size_t) sizeof (r.module_name))
910 (void) memset (r.module_name + length, ' ',
911 sizeof (r.module_name) - length);
252b5132 912
116c20d2 913 (void) memcpy (r.module_name, abfd->filename, length);
252b5132
RH
914
915 r.version_number = OASYS_VERSION_NUMBER;
916 r.rev_number = OASYS_REV_NUMBER;
252b5132 917
116c20d2
NC
918 return oasys_write_record (abfd, oasys_record_is_header_enum,
919 (oasys_record_union_type *) & r,
920 offsetof (oasys_header_record_type,
921 description[0]));
252b5132
RH
922}
923
b34976b6 924static bfd_boolean
116c20d2 925oasys_write_end (bfd *abfd)
252b5132
RH
926{
927 oasys_end_record_type end;
928 unsigned char null = 0;
116c20d2 929
252b5132 930 end.relb = RELOCATION_TYPE_ABS;
dc810e39
AM
931 H_PUT_32 (abfd, abfd->start_address, end.entry);
932 H_PUT_16 (abfd, 0, end.fill);
252b5132
RH
933 end.zero = 0;
934 if (! oasys_write_record (abfd,
935 oasys_record_is_end_enum,
936 (oasys_record_union_type *) & end,
937 sizeof (end)))
b34976b6 938 return FALSE;
116c20d2
NC
939
940 return bfd_bwrite ((void *) &null, (bfd_size_type) 1, abfd) == 1;
252b5132
RH
941}
942
943static int
116c20d2 944comp (const void * ap, const void * bp)
252b5132
RH
945{
946 arelent *a = *((arelent **) ap);
947 arelent *b = *((arelent **) bp);
116c20d2 948
252b5132
RH
949 return a->address - b->address;
950}
951
b34976b6 952static bfd_boolean
116c20d2 953oasys_write_data (bfd *abfd)
252b5132
RH
954{
955 asection *s;
116c20d2
NC
956
957 for (s = abfd->sections; s != NULL; s = s->next)
252b5132
RH
958 {
959 if (s->flags & SEC_LOAD)
960 {
961 bfd_byte *raw_data = oasys_per_section (s)->data;
962 oasys_data_record_type processed_data;
963 bfd_size_type current_byte_index = 0;
964 unsigned int relocs_to_go = s->reloc_count;
965 arelent **p = s->orelocation;
116c20d2 966
252b5132 967 if (s->reloc_count != 0)
116c20d2
NC
968 /* Sort the reloc records so it's easy to insert the relocs into the
969 data. */
970 qsort (s->orelocation, s->reloc_count, sizeof (arelent **), comp);
252b5132 971
252b5132
RH
972 current_byte_index = 0;
973 processed_data.relb = s->target_index | RELOCATION_TYPE_REL;
974
eea6121a 975 while (current_byte_index < s->size)
252b5132
RH
976 {
977 /* Scan forwards by eight bytes or however much is left and see if
116c20d2 978 there are any relocations going on. */
252b5132
RH
979 bfd_byte *mod = &processed_data.data[0];
980 bfd_byte *dst = &processed_data.data[1];
981
982 unsigned int i = 0;
983 *mod = 0;
984
dc810e39
AM
985 H_PUT_32 (abfd, s->vma + current_byte_index,
986 processed_data.addr);
252b5132
RH
987
988 /* Don't start a relocation unless you're sure you can finish it
116c20d2
NC
989 within the same data record. The worst case relocation is a
990 4-byte relocatable value which is split across two modification
991 bytes (1 relocation byte + 2 symbol reference bytes + 2 data +
992 1 modification byte + 2 data = 8 bytes total). That's where
993 the magic number 8 comes from. */
eea6121a 994 while (current_byte_index < s->size && dst <=
116c20d2 995 & processed_data.data[sizeof (processed_data.data) - 8])
252b5132 996 {
252b5132
RH
997 if (relocs_to_go != 0)
998 {
999 arelent *r = *p;
252b5132 1000
116c20d2
NC
1001 /* There is a relocation, is it for this byte ? */
1002 if (r->address == current_byte_index)
1003 abort ();
252b5132 1004 }
116c20d2 1005
252b5132 1006 /* If this is coming from an unloadable section then copy
116c20d2 1007 zeros. */
252b5132 1008 if (raw_data == NULL)
116c20d2 1009 *dst++ = 0;
252b5132 1010 else
116c20d2
NC
1011 *dst++ = *raw_data++;
1012
1013 if (++i >= 8)
252b5132 1014 {
116c20d2
NC
1015 i = 0;
1016 mod = dst++;
1017 *mod = 0;
252b5132 1018 }
116c20d2 1019 current_byte_index++;
252b5132
RH
1020 }
1021
116c20d2 1022 /* Don't write a useless null modification byte. */
252b5132 1023 if (dst == mod + 1)
116c20d2 1024 --dst;
252b5132 1025
dc810e39
AM
1026 if (! (oasys_write_record
1027 (abfd, oasys_record_is_data_enum,
1028 ((oasys_record_union_type *) &processed_data),
1029 (size_t) (dst - (bfd_byte *) &processed_data))))
b34976b6 1030 return FALSE;
252b5132
RH
1031 }
1032 }
1033 }
1034
b34976b6 1035 return TRUE;
252b5132
RH
1036}
1037
b34976b6 1038static bfd_boolean
116c20d2 1039oasys_write_object_contents (bfd *abfd)
252b5132
RH
1040{
1041 if (! oasys_write_header (abfd))
b34976b6 1042 return FALSE;
252b5132 1043 if (! oasys_write_syms (abfd))
b34976b6 1044 return FALSE;
252b5132 1045 if (! oasys_write_sections (abfd))
b34976b6 1046 return FALSE;
252b5132 1047 if (! oasys_write_data (abfd))
b34976b6 1048 return FALSE;
252b5132 1049 if (! oasys_write_end (abfd))
b34976b6
AM
1050 return FALSE;
1051 return TRUE;
252b5132
RH
1052}
1053
116c20d2
NC
1054/* Set section contents is complicated with OASYS since the format is
1055 not a byte image, but a record stream. */
252b5132 1056
b34976b6 1057static bfd_boolean
116c20d2
NC
1058oasys_set_section_contents (bfd *abfd,
1059 sec_ptr section,
1060 const void * location,
1061 file_ptr offset,
1062 bfd_size_type count)
252b5132
RH
1063{
1064 if (count != 0)
1065 {
116c20d2 1066 if (oasys_per_section (section)->data == NULL)
252b5132 1067 {
116c20d2 1068 oasys_per_section (section)->data = bfd_alloc (abfd, section->size);
252b5132 1069 if (!oasys_per_section (section)->data)
b34976b6 1070 return FALSE;
252b5132 1071 }
116c20d2
NC
1072 (void) memcpy ((void *) (oasys_per_section (section)->data + offset),
1073 location, (size_t) count);
252b5132 1074 }
b34976b6 1075 return TRUE;
252b5132
RH
1076}
1077
1078
1079
116c20d2 1080/* Native-level interface to symbols. */
252b5132
RH
1081
1082/* We read the symbols into a buffer, which is discarded when this
116c20d2
NC
1083 function exits. We read the strings into a buffer large enough to
1084 hold them all plus all the cached symbol entries. */
252b5132
RH
1085
1086static asymbol *
116c20d2 1087oasys_make_empty_symbol (bfd *abfd)
252b5132 1088{
dc810e39 1089 bfd_size_type amt = sizeof (oasys_symbol_type);
d3ce72d0 1090 oasys_symbol_type *new_symbol_type = bfd_zalloc (abfd, amt);
116c20d2 1091
d3ce72d0 1092 if (!new_symbol_type)
252b5132 1093 return NULL;
d3ce72d0
NC
1094 new_symbol_type->symbol.the_bfd = abfd;
1095 return &new_symbol_type->symbol;
252b5132 1096}
252b5132
RH
1097
1098/* User should have checked the file flags; perhaps we should return
116c20d2 1099 BFD_NO_MORE_SYMBOLS if there are none? */
252b5132
RH
1100
1101static bfd *
116c20d2 1102oasys_openr_next_archived_file (bfd *arch, bfd *prev)
252b5132
RH
1103{
1104 oasys_ar_data_type *ar = OASYS_AR_DATA (arch);
1105 oasys_module_info_type *p;
116c20d2
NC
1106
1107 /* Take the next one from the arch state, or reset. */
1108 if (prev == NULL)
1109 /* Reset the index - the first two entries are bogus. */
1110 ar->module_index = 0;
252b5132
RH
1111
1112 p = ar->module + ar->module_index;
1113 ar->module_index++;
1114
1115 if (ar->module_index <= ar->module_count)
1116 {
116c20d2 1117 if (p->abfd == NULL)
252b5132
RH
1118 {
1119 p->abfd = _bfd_create_empty_archive_element_shell (arch);
1120 p->abfd->origin = p->pos;
1121 p->abfd->filename = p->name;
1122
116c20d2
NC
1123 /* Fixup a pointer to this element for the member. */
1124 p->abfd->arelt_data = (void *) p;
252b5132
RH
1125 }
1126 return p->abfd;
1127 }
116c20d2
NC
1128
1129 bfd_set_error (bfd_error_no_more_archived_files);
1130 return NULL;
252b5132
RH
1131}
1132
b34976b6 1133static bfd_boolean
116c20d2
NC
1134oasys_find_nearest_line (bfd *abfd ATTRIBUTE_UNUSED,
1135 asection *section ATTRIBUTE_UNUSED,
1136 asymbol **symbols ATTRIBUTE_UNUSED,
1137 bfd_vma offset ATTRIBUTE_UNUSED,
1138 const char **filename_ptr ATTRIBUTE_UNUSED,
1139 const char **functionname_ptr ATTRIBUTE_UNUSED,
1140 unsigned int *line_ptr ATTRIBUTE_UNUSED)
252b5132 1141{
b34976b6 1142 return FALSE;
252b5132
RH
1143}
1144
4ab527b0
FF
1145static bfd_boolean
1146oasys_find_inliner_info (bfd *abfd ATTRIBUTE_UNUSED,
1147 const char **filename_ptr ATTRIBUTE_UNUSED,
1148 const char **functionname_ptr ATTRIBUTE_UNUSED,
1149 unsigned int *line_ptr ATTRIBUTE_UNUSED)
1150{
1151 return FALSE;
1152}
1153
252b5132 1154static int
116c20d2 1155oasys_generic_stat_arch_elt (bfd *abfd, struct stat *buf)
252b5132
RH
1156{
1157 oasys_module_info_type *mod = (oasys_module_info_type *) abfd->arelt_data;
116c20d2
NC
1158
1159 if (mod == NULL)
252b5132
RH
1160 {
1161 bfd_set_error (bfd_error_invalid_operation);
1162 return -1;
1163 }
116c20d2
NC
1164
1165 buf->st_size = mod->size;
1166 buf->st_mode = 0666;
1167 return 0;
252b5132
RH
1168}
1169
1170static int
a6b96beb
AM
1171oasys_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
1172 struct bfd_link_info *info ATTRIBUTE_UNUSED)
252b5132
RH
1173{
1174 return 0;
1175}
1176
116c20d2
NC
1177#define oasys_close_and_cleanup _bfd_generic_close_and_cleanup
1178#define oasys_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
1179#define oasys_slurp_armap bfd_true
1180#define oasys_slurp_extended_name_table bfd_true
1181#define oasys_construct_extended_name_table ((bfd_boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_true)
1182#define oasys_truncate_arname bfd_dont_truncate_arname
1183#define oasys_write_armap ((bfd_boolean (*) (bfd *, unsigned int, struct orl *, unsigned int, int)) bfd_true)
1184#define oasys_read_ar_hdr bfd_nullvoidptr
8f95b6e4 1185#define oasys_write_ar_hdr ((bfd_boolean (*) (bfd *, bfd *)) bfd_false)
116c20d2
NC
1186#define oasys_get_elt_at_index _bfd_generic_get_elt_at_index
1187#define oasys_update_armap_timestamp bfd_true
1188#define oasys_bfd_is_local_label_name bfd_generic_is_local_label_name
1189#define oasys_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
1190#define oasys_get_lineno _bfd_nosymbols_get_lineno
1191#define oasys_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
1192#define oasys_read_minisymbols _bfd_generic_read_minisymbols
1193#define oasys_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
1194#define oasys_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
157090f7 1195#define oasys_bfd_reloc_name_lookup _bfd_norelocs_bfd_reloc_name_lookup
116c20d2
NC
1196#define oasys_set_arch_mach bfd_default_set_arch_mach
1197#define oasys_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
1198#define oasys_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
1199#define oasys_bfd_relax_section bfd_generic_relax_section
1200#define oasys_bfd_gc_sections bfd_generic_gc_sections
ae17ab41 1201#define oasys_bfd_lookup_section_flags bfd_generic_lookup_section_flags
116c20d2
NC
1202#define oasys_bfd_merge_sections bfd_generic_merge_sections
1203#define oasys_bfd_is_group_section bfd_generic_is_group_section
1204#define oasys_bfd_discard_group bfd_generic_discard_group
1205#define oasys_section_already_linked _bfd_generic_section_already_linked
3023e3f6 1206#define oasys_bfd_define_common_symbol bfd_generic_define_common_symbol
116c20d2
NC
1207#define oasys_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
1208#define oasys_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
1209#define oasys_bfd_link_add_symbols _bfd_generic_link_add_symbols
1210#define oasys_bfd_link_just_syms _bfd_generic_link_just_syms
1338dd10
PB
1211#define oasys_bfd_copy_link_hash_symbol_type \
1212 _bfd_generic_copy_link_hash_symbol_type
116c20d2
NC
1213#define oasys_bfd_final_link _bfd_generic_final_link
1214#define oasys_bfd_link_split_section _bfd_generic_link_split_section
1215
252b5132
RH
1216const bfd_target oasys_vec =
1217{
116c20d2 1218 "oasys", /* Name. */
252b5132 1219 bfd_target_oasys_flavour,
116c20d2
NC
1220 BFD_ENDIAN_BIG, /* Target byte order. */
1221 BFD_ENDIAN_BIG, /* Target headers byte order. */
1222 (HAS_RELOC | EXEC_P | /* Object flags. */
252b5132
RH
1223 HAS_LINENO | HAS_DEBUG |
1224 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
1225 (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
116c20d2
NC
1226 | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* Section flags. */
1227 0, /* Leading underscore. */
1228 ' ', /* AR_pad_char. */
1229 16, /* AR_max_namelen. */
0aabe54e 1230 0, /* match priority. */
252b5132
RH
1231 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1232 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
116c20d2 1233 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */
252b5132
RH
1234 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1235 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
116c20d2 1236 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Headers. */
252b5132
RH
1237
1238 {_bfd_dummy_target,
116c20d2 1239 oasys_object_p, /* bfd_check_format. */
252b5132
RH
1240 oasys_archive_p,
1241 _bfd_dummy_target,
1242 },
116c20d2 1243 { /* bfd_set_format. */
252b5132
RH
1244 bfd_false,
1245 oasys_mkobject,
1246 _bfd_generic_mkarchive,
1247 bfd_false
1248 },
116c20d2 1249 { /* bfd_write_contents. */
252b5132
RH
1250 bfd_false,
1251 oasys_write_object_contents,
1252 _bfd_write_archive_contents,
1253 bfd_false,
1254 },
1255
1256 BFD_JUMP_TABLE_GENERIC (oasys),
1257 BFD_JUMP_TABLE_COPY (_bfd_generic),
1258 BFD_JUMP_TABLE_CORE (_bfd_nocore),
1259 BFD_JUMP_TABLE_ARCHIVE (oasys),
1260 BFD_JUMP_TABLE_SYMBOLS (oasys),
1261 BFD_JUMP_TABLE_RELOCS (oasys),
1262 BFD_JUMP_TABLE_WRITE (oasys),
1263 BFD_JUMP_TABLE_LINK (oasys),
1264 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
1265
c3c89269 1266 NULL,
dc810e39 1267
116c20d2 1268 NULL
252b5132 1269};
This page took 0.736557 seconds and 4 git commands to generate.