1 #define UNDERSCORE_HACK 1
2 #define offsetof(type, identifier) (size_t) &(((type *) 0)->identifier)
5 bfd backend for oasys objects.
8 Written by Steve Chamberlain
31 DEFUN(oasys_read_record,(abfd, record),
33 oasys_record_union_type *record)
36 bfd_read(record, 1, sizeof(record->header), abfd);
38 bfd_read(((char *)record )+ sizeof(record->header),
39 1, record->header.length - sizeof(record->header),
43 DEFUN(oasys_string_length,(record),
44 oasys_record_union_type *record)
46 return record->header.length
47 - ((char *)record->symbol.name - (char *)record);
50 /*****************************************************************************/
54 Slurp the symbol table by reading in all the records at the start file
55 till we get to the first section record.
57 We'll sort the symbolss into two lists, defined and undefined. The
58 undefined symbols will be placed into the table according to their
61 We do this by placing all undefined symbols at the front of the table
62 moving in, and the defined symbols at the end of the table moving back.
67 DEFUN(oasys_slurp_symbol_table,(abfd),
70 oasys_record_union_type record;
71 oasys_data_type *data = oasys_data(abfd);
73 asymbol *dest_undefined;
74 asymbol *dest_defined;
79 if (data->symbols != (asymbol *)NULL) {
82 /* Buy enough memory for all the symbols and all the names */
84 (asymbol *)bfd_alloc(abfd, sizeof(asymbol) * abfd->symcount);
85 #ifdef UNDERSCORE_HACK
86 /* buy 1 more char for each symbol to keep the underscore in*/
87 data->strings = bfd_alloc(abfd, data->symbol_string_length +
90 data->strings = bfd_alloc(abfd, data->symbol_string_length);
93 dest_undefined = data->symbols;
94 dest_defined = data->symbols + abfd->symcount -1;
96 string_ptr = data->strings;
97 bfd_seek(abfd, (file_ptr)0, SEEK_SET);
100 oasys_read_record(abfd, &record);
101 switch (record.header.type) {
102 case oasys_record_is_header_enum:
104 case oasys_record_is_local_enum:
105 case oasys_record_is_symbol_enum:
107 int flag = record.header.type == oasys_record_is_local_enum ?
108 (BSF_LOCAL) : (BSF_GLOBAL | BSF_EXPORT);
111 size_t length = oasys_string_length(&record);
112 switch (record.symbol.relb & RELOCATION_TYPE_BITS) {
113 case RELOCATION_TYPE_ABS:
114 dest = dest_defined--;
116 dest->flags = BSF_ABSOLUTE | flag;
118 case RELOCATION_TYPE_REL:
119 dest = dest_defined--;
121 oasys_data(abfd)->sections[record.symbol.relb &
122 RELOCATION_SECT_BITS];
123 if (record.header.type == oasys_record_is_local_enum)
125 dest->flags = BSF_LOCAL;
132 case RELOCATION_TYPE_UND:
133 dest = data->symbols + bfd_h_getshort(abfd, &record.symbol.refno[0]);
134 dest->section = (asection *)NULL;
135 dest->flags = BSF_UNDEFINED;
137 case RELOCATION_TYPE_COM:
138 dest = dest_defined--;
139 dest->name = string_ptr;
140 dest->the_bfd = abfd;
142 dest->section = (asection *)NULL;
143 dest->flags = BSF_FORT_COMM;
146 dest->name = string_ptr;
147 dest->the_bfd = abfd;
148 dest->udata = (PTR)NULL;
149 dest->value = bfd_h_getlong(abfd, &record.symbol.value[0]);
151 #ifdef UNDERSCORE_HACK
152 if (record.symbol.name[0] != '_') {
157 memcpy(string_ptr, record.symbol.name, length);
160 string_ptr[length] =0;
161 string_ptr += length +1;
173 DEFUN(oasys_get_symtab_upper_bound,(abfd),
176 oasys_slurp_symbol_table (abfd);
178 return (abfd->symcount+1) * (sizeof (oasys_symbol_type *));
184 extern bfd_target oasys_vec;
187 DEFUN(oasys_get_symtab,(abfd, location),
192 unsigned int counter ;
193 if (oasys_slurp_symbol_table(abfd) == false) {
196 symbase = oasys_data(abfd)->symbols;
197 for (counter = 0; counter < abfd->symcount; counter++) {
198 *(location++) = symbase++;
201 return abfd->symcount;
204 /***********************************************************************
207 #define swap(x) x = bfd_h_get_x(abfd, &x);
209 DEFUN(oasys_archive_p,(abfd),
212 oasys_archive_header_type header;
215 bfd_seek(abfd, (file_ptr) 0, false);
218 bfd_read(&header, 1, sizeof(header), abfd);
221 swap(header.version);
222 swap(header.mod_count);
223 swap(header.mod_tbl_offset);
224 swap(header.sym_tbl_size);
225 swap(header.sym_count);
226 swap(header.sym_tbl_offset);
227 swap(header.xref_count);
228 swap(header.xref_lst_offset);
231 There isn't a magic number in an Oasys archive, so the best we
232 can do to verify reasnableness is to make sure that the values in
233 the header are too weird
236 if (header.version>10000 ||
237 header.mod_count>10000 ||
238 header.sym_count>100000 ||
239 header.xref_count > 100000) return (bfd_target *)NULL;
242 That all worked, lets buy the space for the header and read in
246 oasys_ar_data_type *ar =
247 (oasys_ar_data_type*) bfd_alloc(abfd, sizeof(oasys_ar_data_type));
250 oasys_module_info_type *module =
251 (oasys_module_info_type*)
252 bfd_alloc(abfd, sizeof(oasys_module_info_type) * header.mod_count);
254 oasys_module_table_type record;
256 oasys_ar_data(abfd) =ar;
258 ar->module_count = header.mod_count;
260 bfd_seek(abfd , header.mod_tbl_offset, SEEK_SET);
261 for (i = 0; i < header.mod_count; i++) {
263 bfd_read(&record, 1, sizeof(record), abfd);
264 swap(record.mod_size);
265 swap(record.file_offset);
266 swap(record.mod_name_length);
267 module[i].name = bfd_alloc(abfd,record.mod_name_length+1);
269 bfd_read(module[i].name, 1, record.mod_name_length +1, abfd);
270 /* SKip some stuff */
271 bfd_seek(abfd, record.dep_count * sizeof(int32_type),
274 module[i].size = record.mod_size;
275 module[i].pos = record.file_offset;
283 DEFUN(oasys_mkobject,(abfd),
286 oasys_data_type *oasys;
289 (oasys_data_type*)bfd_alloc(abfd, sizeof(oasys_data_type));
290 oasys = oasys_data(abfd);
296 DEFUN(oasys_object_p,(abfd),
299 oasys_data_type *oasys;
301 boolean had_usefull = false;
302 oasys_data(abfd) = 0;
303 oasys_mkobject(abfd);
304 oasys = oasys_data(abfd);
305 memset((PTR)oasys->sections, 0xff, sizeof(oasys->sections));
307 /* Point to the start of the file */
308 bfd_seek(abfd, (file_ptr)0, SEEK_SET);
309 oasys->symbol_string_length = 0;
310 /* Inspect the records, but only keep the section info -
311 remember the size of the symbols
313 oasys->first_data_record = 0;
315 oasys_record_union_type record;
316 oasys_read_record(abfd, &record);
317 if ((size_t)record.header.length < (size_t)sizeof(record.header))
321 switch ((oasys_record_enum_type)(record.header.type)) {
322 case oasys_record_is_header_enum:
325 case oasys_record_is_symbol_enum:
326 case oasys_record_is_local_enum:
327 /* Count symbols and remember their size for a future malloc */
329 oasys->symbol_string_length += 1 + oasys_string_length(&record);
332 case oasys_record_is_section_enum:
336 unsigned int section_number;
337 if (record.section.header.length != sizeof(record.section))
341 buffer = bfd_alloc(abfd, 3);
342 section_number= record.section.relb & RELOCATION_SECT_BITS;
343 sprintf(buffer,"%u", section_number);
344 s = bfd_make_section(abfd,buffer);
345 oasys->sections[section_number] = s;
346 switch (record.section.relb & RELOCATION_TYPE_BITS) {
347 case RELOCATION_TYPE_ABS:
348 case RELOCATION_TYPE_REL:
350 case RELOCATION_TYPE_UND:
351 case RELOCATION_TYPE_COM:
355 s->size = bfd_h_getlong(abfd, & record.section.value[0]) ;
356 s->vma = bfd_h_getlong(abfd, &record.section.vma[0]);
357 s->flags |= SEC_LOAD | SEC_HAS_CONTENTS;
361 case oasys_record_is_data_enum:
362 oasys->first_data_record = bfd_tell(abfd) - record.header.length;
363 case oasys_record_is_debug_enum:
364 case oasys_record_is_module_enum:
365 case oasys_record_is_named_section_enum:
366 case oasys_record_is_end_enum:
367 if (had_usefull == false) goto fail;
374 oasys->symbols = (asymbol *)NULL;
376 Oasys support several architectures, but I can't see a simple way
377 to discover which one is in a particular file - we'll guess
379 abfd->obj_arch = bfd_arch_m68k;
380 abfd->obj_machine =0;
381 if (abfd->symcount != 0) {
382 abfd->flags |= HAS_SYMS;
387 (void) bfd_release(abfd, oasys);
388 return (bfd_target *)NULL;
393 DEFUN(oasys_print_symbol,(ignore_abfd, file, symbol, how),
397 bfd_print_symbol_enum_type how)
400 case bfd_print_symbol_name_enum:
401 case bfd_print_symbol_type_enum:
402 fprintf(file,"%s", symbol->name);
404 case bfd_print_symbol_all_enum:
406 CONST char *section_name = symbol->section == (asection *)NULL ?
407 "*abs" : symbol->section->name;
409 bfd_print_symbol_vandf((PTR)file,symbol);
411 fprintf(file," %-5s %s",
419 The howto table is build using the top two bits of a reloc byte to
420 index into it. The bits are PCREL,WORD/LONG
422 static reloc_howto_type howto_table[]=
425 HOWTO( 0, 0, 1, 16, false,0, true,true,0,"abs16",true,0x0000ffff, 0x0000ffff,false),
426 HOWTO( 0, 0, 2, 32, false,0, true,true,0,"abs32",true,0xffffffff, 0xffffffff,false),
427 HOWTO( 0, 0, 1, 16, true,0, true,true,0,"pcrel16",true,0x0000ffff, 0x0000ffff,false),
428 HOWTO( 0, 0, 2, 32, true,0, true,true,0,"pcrel32",true,0xffffffff, 0xffffffff,false)
431 /* Read in all the section data and relocation stuff too */
433 DEFUN(oasys_slurp_section_data,(abfd),
436 oasys_record_union_type record;
437 oasys_data_type *data = oasys_data(abfd);
440 oasys_per_section_type *per ;
444 /* Buy enough memory for all the section data and relocations */
445 for (s = abfd->sections; s != (asection *)NULL; s= s->next) {
446 per = oasys_per_section(s);
447 if (per->data != (bfd_byte*)NULL) return true;
448 per->data = (bfd_byte *) bfd_alloc(abfd, s->size);
449 per->reloc_tail_ptr = (oasys_reloc_type **)&(s->relocation);
450 per->had_vma = false;
454 if (data->first_data_record == 0) return true;
455 bfd_seek(abfd, data->first_data_record, SEEK_SET);
457 oasys_read_record(abfd, &record);
458 switch (record.header.type) {
459 case oasys_record_is_header_enum:
461 case oasys_record_is_data_enum:
464 uint8e_type *src = record.data.data;
465 uint8e_type *end_src = ((uint8e_type *)&record) +
466 record.header.length;
469 bfd_byte *dst_base_ptr ;
472 data->sections[record.data.relb & RELOCATION_SECT_BITS];
474 per = oasys_per_section(section);
475 dst_offset = bfd_h_getlong(abfd, record.data.addr) ;
476 if (per->had_vma == false) {
477 /* Take the first vma we see as the base */
479 section->vma = dst_offset;
484 dst_offset -= section->vma;
487 dst_base_ptr = oasys_per_section(section)->data;
488 dst_ptr = oasys_per_section(section)->data +
491 while (src < end_src) {
492 uint32_type gap = end_src - src -1;
493 uint8e_type mod_byte = *src++;
495 if (mod_byte == 0 && gap >= 8) {
508 for (relbit = 1; count-- != 0 && gap != 0; gap --, relbit <<=1)
510 if (relbit & mod_byte)
512 uint8e_type reloc = *src;
513 /* This item needs to be relocated */
514 switch (reloc & RELOCATION_TYPE_BITS) {
515 case RELOCATION_TYPE_ABS:
519 case RELOCATION_TYPE_REL:
521 /* Relocate the item relative to the section */
522 oasys_reloc_type *r =
525 sizeof(oasys_reloc_type));
526 *(per->reloc_tail_ptr) = r;
527 per->reloc_tail_ptr = &r->next;
528 r->next= (oasys_reloc_type *)NULL;
529 /* Reference to undefined symbol */
531 /* There is no symbol */
533 /* Work out the howto */
535 data->sections[reloc & RELOCATION_SECT_BITS];
536 r->relent.addend = - r->relent.section->vma;
537 r->relent.address = dst_ptr - dst_base_ptr;
538 r->relent.howto = &howto_table[reloc>>6];
539 r->relent.sym_ptr_ptr = (asymbol **)NULL;
540 section->reloc_count++;
545 case RELOCATION_TYPE_UND:
547 oasys_reloc_type *r =
550 sizeof(oasys_reloc_type));
551 *(per->reloc_tail_ptr) = r;
552 per->reloc_tail_ptr = &r->next;
553 r->next= (oasys_reloc_type *)NULL;
554 /* Reference to undefined symbol */
556 /* Get symbol number */
557 r->symbol = (src[0]<<8) | src[1];
558 /* Work out the howto */
559 r->relent.section = (asection *)NULL;
560 r->relent.addend = 0;
561 r->relent.address = dst_ptr - dst_base_ptr;
562 r->relent.howto = &howto_table[reloc>>6];
563 r->relent.sym_ptr_ptr = (asymbol **)NULL;
564 section->reloc_count++;
569 case RELOCATION_TYPE_COM:
579 case oasys_record_is_local_enum:
580 case oasys_record_is_symbol_enum:
581 case oasys_record_is_section_enum:
593 bfd_error_vector_type bfd_error_vector;
596 DEFUN(oasys_new_section_hook,(abfd, newsect),
600 newsect->used_by_bfd = (PTR)
601 bfd_alloc(abfd, sizeof(oasys_per_section_type));
602 oasys_per_section( newsect)->data = (bfd_byte *)NULL;
603 oasys_per_section(newsect)->section = newsect;
604 oasys_per_section(newsect)->offset = 0;
605 newsect->alignment_power = 3;
606 /* Turn the section string into an index */
608 sscanf(newsect->name,"%u", &newsect->target_index);
615 DEFUN(oasys_get_reloc_upper_bound, (abfd, asect),
619 oasys_slurp_section_data(abfd);
620 return (asect->reloc_count+1) * sizeof(arelent *);
624 DEFUN(oasys_get_section_contents,(abfd, section, location, offset, count),
631 oasys_per_section_type *p = (oasys_per_section_type *) section->used_by_bfd;
632 oasys_slurp_section_data(abfd);
633 (void) memcpy(location, p->data + offset, count);
639 DEFUN(oasys_canonicalize_reloc,(abfd, section, relptr, symbols),
645 unsigned int reloc_count = 0;
646 oasys_reloc_type *src = (oasys_reloc_type *)(section->relocation);
647 while (src != (oasys_reloc_type *)NULL) {
648 if (src->relent.section == (asection *)NULL)
650 src->relent.sym_ptr_ptr = symbols + src->symbol;
652 *relptr ++ = &src->relent;
656 *relptr = (arelent *)NULL;
657 return section->reloc_count = reloc_count;
662 DEFUN(oasys_set_arch_mach, (abfd, arch, machine),
664 enum bfd_architecture arch AND
665 unsigned long machine)
667 abfd->obj_arch = arch;
668 abfd->obj_machine = machine;
677 /* Calculate the checksum and write one record */
679 DEFUN(oasys_write_record,(abfd, type, record, size),
681 CONST oasys_record_enum_type type AND
682 oasys_record_union_type *record AND
688 record->header.length = size;
689 record->header.type = type;
690 record->header.check_sum = 0;
691 record->header.fill = 0;
692 ptr = &record->pad[0];
694 for (i = 0; i < size; i++) {
697 record->header.check_sum = 0xff & (- checksum);
698 bfd_write((PTR)record, 1, size, abfd);
702 /* Write out all the symbols */
704 DEFUN(oasys_write_syms, (abfd),
708 asymbol **generic = bfd_get_outsymbols(abfd);
709 unsigned int index = 0;
710 for (count = 0; count < bfd_get_symcount(abfd); count++) {
712 oasys_symbol_record_type symbol;
713 asymbol * CONST g = generic[count];
715 CONST char *src = g->name;
716 char *dst = symbol.name;
719 if (g->flags & BSF_FORT_COMM) {
720 symbol.relb = RELOCATION_TYPE_COM;
721 bfd_h_putshort(abfd, index, (uint8e_type *)(&symbol.refno[0]));
724 else if (g->flags & BSF_ABSOLUTE) {
725 symbol.relb = RELOCATION_TYPE_ABS;
726 bfd_h_putshort(abfd, 0, (uint8e_type *)(&symbol.refno[0]));
729 else if (g->flags & BSF_UNDEFINED) {
730 symbol.relb = RELOCATION_TYPE_UND ;
731 bfd_h_putshort(abfd, index, (uint8e_type *)(&symbol.refno[0]));
732 /* Overload the value field with the output index number */
735 else if (g->flags & BSF_DEBUGGING) {
740 symbol.relb = RELOCATION_TYPE_REL | g->section->output_section->target_index;
741 bfd_h_putshort(abfd, 0, (uint8e_type *)(&symbol.refno[0]));
748 bfd_h_putlong(abfd, g->value, symbol.value);
751 if (g->flags & BSF_LOCAL) {
752 oasys_write_record(abfd,
753 oasys_record_is_local_enum,
754 (oasys_record_union_type *) &symbol,
755 offsetof(oasys_symbol_record_type, name[0]) + l);
758 oasys_write_record(abfd,
759 oasys_record_is_symbol_enum,
760 (oasys_record_union_type *) &symbol,
761 offsetof(oasys_symbol_record_type, name[0]) + l);
768 /* Write a section header for each section */
770 DEFUN(oasys_write_sections, (abfd),
774 static oasys_section_record_type out = {0};
776 for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
777 if (!isdigit(s->name[0]))
779 bfd_error_vector.nonrepresentable_section(abfd,
782 out.relb = RELOCATION_TYPE_REL | s->target_index;
783 bfd_h_putlong(abfd, s->size, out.value);
784 bfd_h_putlong(abfd, s->vma, out.vma);
786 oasys_write_record(abfd,
787 oasys_record_is_section_enum,
788 (oasys_record_union_type *) &out,
794 DEFUN(oasys_write_header, (abfd),
797 /* Create and write the header */
798 oasys_header_record_type r;
799 size_t length = strlen(abfd->filename);
800 if (length > (size_t)sizeof(r.module_name)) {
801 length = sizeof(r.module_name);
804 (void)memcpy(r.module_name,
807 (void)memset(r.module_name + length,
809 sizeof(r.module_name) - length);
811 r.version_number = OASYS_VERSION_NUMBER;
812 r.rev_number = OASYS_REV_NUMBER;
813 oasys_write_record(abfd,
814 oasys_record_is_header_enum,
815 (oasys_record_union_type *)&r,
816 offsetof(oasys_header_record_type, description[0]));
823 DEFUN(oasys_write_end,(abfd),
826 oasys_end_record_type end;
827 end.relb = RELOCATION_TYPE_ABS;
828 bfd_h_putlong(abfd, abfd->start_address, end.entry);
829 bfd_h_putshort(abfd, 0, end.fill);
831 oasys_write_record(abfd,
832 oasys_record_is_end_enum,
833 (oasys_record_union_type *)&end,
842 arelent *a = *((arelent **)ap);
843 arelent *b = *((arelent **)bp);
844 return a->address - b->address;
852 DEFUN(oasys_write_data, (abfd),
856 for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
857 uint8e_type *raw_data = oasys_per_section(s)->data;
858 oasys_data_record_type processed_data;
859 unsigned int current_byte_index = 0;
860 unsigned int relocs_to_go = s->reloc_count;
861 arelent **p = s->orelocation;
862 if (s->reloc_count != 0) {
863 /* Sort the reloc records so it's easy to insert the relocs into the
866 qsort(s->orelocation,
871 current_byte_index = 0;
872 processed_data.relb = s->target_index | RELOCATION_TYPE_REL;
874 while ((size_t)current_byte_index < s->size)
876 /* Scan forwards by eight bytes or however much is left and see if
877 there are any relocations going on */
878 uint8e_type *mod = &processed_data.data[0];
879 uint8e_type *dst = &processed_data.data[1];
882 unsigned int long_length = 128;
885 bfd_h_putlong(abfd, s->vma + current_byte_index, processed_data.addr);
886 if ((size_t)(long_length + current_byte_index) > (size_t)(s->size)) {
887 long_length = s->size - current_byte_index;
889 while (long_length > 0 && (dst - (uint8e_type*)&processed_data < 128)) {
891 unsigned int length = long_length;
896 for (i = 0; i < length; i++) {
897 if (relocs_to_go != 0) {
899 reloc_howto_type *CONST how=r->howto;
900 /* There is a relocation, is it for this byte ? */
901 if (r->address == current_byte_index) {
902 uint8e_type rel_byte;
907 if(how->pc_relative) {
917 /* Is this a section relative relocation, or a symbol
918 relative relocation ? */
919 if (r->section != (asection*)NULL)
921 /* The relent has a section attatched, so it must be section
923 rel_byte |= RELOCATION_TYPE_REL;
924 rel_byte |= r->section->output_section->target_index;
929 asymbol *p = *(r->sym_ptr_ptr);
931 /* If this symbol has a section attatched, then it
932 has already been resolved. Change from a symbol
933 ref to a section ref */
934 if(p->section != (asection *)NULL) {
935 rel_byte |= RELOCATION_TYPE_REL;
937 p->section->output_section->target_index;
941 rel_byte |= RELOCATION_TYPE_UND;
945 /* Next two bytes are a symbol index - we can get
946 this from the symbol value which has been zapped
947 into the symbol index in the table when the
948 symbol table was written
950 *dst++ = p->value >> 8;
957 /* If this is coming from an unloadable section then copy
959 if (raw_data == (uint8e_type *)NULL) {
963 *dst++ = *raw_data++;
965 current_byte_index++;
968 long_length -= length;
971 oasys_write_record(abfd,
972 oasys_record_is_data_enum,
973 (oasys_record_union_type *)&processed_data,
974 dst - (uint8e_type*)&processed_data);
980 DEFUN(oasys_write_object_contents, (abfd),
983 oasys_write_header(abfd);
984 oasys_write_syms(abfd);
985 oasys_write_sections(abfd);
986 oasys_write_data(abfd);
987 oasys_write_end(abfd);
994 /** exec and core file sections */
996 /* set section contents is complicated with OASYS since the format is
997 * not a byte image, but a record stream.
1000 DEFUN(oasys_set_section_contents,(abfd, section, location, offset, count),
1003 unsigned char *location AND
1008 if (oasys_per_section(section)->data == (bfd_byte *)NULL )
1010 oasys_per_section(section)->data =
1011 (bfd_byte *)(bfd_alloc(abfd,section->size));
1013 (void) memcpy(oasys_per_section(section)->data + offset,
1022 /* Native-level interface to symbols. */
1024 /* We read the symbols into a buffer, which is discarded when this
1025 function exits. We read the strings into a buffer large enough to
1026 hold them all plus all the cached symbol entries. */
1029 DEFUN(oasys_make_empty_symbol,(abfd),
1033 oasys_symbol_type *new =
1034 (oasys_symbol_type *)bfd_zalloc (abfd, sizeof (oasys_symbol_type));
1035 new->symbol.the_bfd = abfd;
1036 return &new->symbol;
1042 /* Obsbolete procedural interface; better to look at the cache directly */
1044 /* User should have checked the file flags; perhaps we should return
1045 BFD_NO_MORE_SYMBOLS if there are none? */
1050 oasys_close_and_cleanup (abfd)
1053 if (bfd_read_p (abfd) == false)
1054 switch (abfd->format) {
1056 if (!_bfd_write_archive_contents (abfd)) {
1061 if (!oasys_write_object_contents (abfd)) {
1066 bfd_error = invalid_operation;
1076 oasys_openr_next_archived_file(arch, prev)
1080 oasys_ar_data_type *ar = oasys_ar_data(arch);
1081 oasys_module_info_type *p;
1082 /* take the next one from the arch state, or reset */
1083 if (prev == (bfd *)NULL) {
1084 /* Reset the index - the first two entries are bogus*/
1085 ar->module_index = 0;
1088 p = ar->module + ar->module_index;
1091 if (ar->module_index <= ar->module_count) {
1092 if (p->abfd == (bfd *)NULL) {
1093 p->abfd = _bfd_create_empty_archive_element_shell(arch);
1094 p->abfd->origin = p->pos;
1095 p->abfd->filename = p->name;
1097 /* Fixup a pointer to this element for the member */
1098 p->abfd->arelt_data = (PTR)p;
1103 bfd_error = no_more_archived_files;
1109 oasys_find_nearest_line(abfd,
1120 char **filename_ptr;
1121 char **functionname_ptr;
1122 unsigned int *line_ptr;
1129 oasys_generic_stat_arch_elt(abfd, buf)
1133 oasys_module_info_type *mod = (oasys_module_info_type *) abfd->arelt_data;
1134 if (mod == (oasys_module_info_type *)NULL) {
1135 bfd_error = invalid_operation;
1139 buf->st_size = mod->size;
1140 buf->st_mode = 0666;
1146 DEFUN(oasys_sizeof_headers,(abfd),
1152 #define oasys_core_file_failing_command bfd_false
1153 #define oasys_core_file_failing_signal bfd_false
1154 #define oasys_core_file_matches_executable_p bfd_false
1155 #define oasys_slurp_armap bfd_false
1156 #define oasys_slurp_extended_name_table bfd_false
1157 #define oasys_truncate_arname bfd_false
1158 #define oasys_write_armap bfd_false
1159 #define oasys_get_lineno bfd_false
1164 bfd_target oasys_vec =
1167 bfd_target_oasys_flavour_enum,
1168 true, /* target byte order */
1169 true, /* target headers byte order */
1170 (HAS_RELOC | EXEC_P | /* object flags */
1171 HAS_LINENO | HAS_DEBUG |
1172 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
1173 (SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
1174 |SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
1175 ' ', /* ar_pad_char */
1176 16, /* ar_max_namelen */
1178 _do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* data */
1179 _do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */
1182 oasys_object_p, /* bfd_check_format */
1189 _bfd_generic_mkarchive,