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
27 #define obstack_chunk_alloc malloc
28 #define obstack_chunk_free free
30 #define oasys_malloc(abfd,size) \
31 obstack_alloc( &( oasys_data(abfd)->oasys_obstack), (size))
33 typedef void generic_symbol_type;
37 DEFUN(oasys_read_record,(abfd, record),
39 oasys_record_union_type *record)
42 bfd_read(record, 1, sizeof(record->header), abfd);
44 bfd_read(((char *)record )+ sizeof(record->header),
45 1, record->header.length - sizeof(record->header),
49 DEFUN(oasys_string_length,(record),
50 oasys_record_union_type *record)
52 return record->header.length
53 - ((char *)record->symbol.name - (char *)record);
56 /*****************************************************************************/
60 Slurp the symbol table by reading in all the records at the start file
61 till we get to the first section record.
63 We'll sort the symbolss into two lists, defined and undefined. The
64 undefined symbols will be placed into the table according to their
67 We do this by placing all undefined symbols at the front of the table
68 moving in, and the defined symbols at the end of the table moving back.
73 DEFUN(oasys_slurp_symbol_table,(abfd),
76 oasys_record_union_type record;
77 oasys_data_type *data = oasys_data(abfd);
79 asymbol *dest_undefined;
80 asymbol *dest_defined;
85 if (data->symbols != (asymbol *)NULL) {
88 /* Buy enough memory for all the symbols and all the names */
90 (asymbol *)oasys_malloc(abfd, sizeof(asymbol) * abfd->symcount);
91 #ifdef UNDERSCORE_HACK
92 /* buy 1 more char for each symbol to keep the underscore in*/
93 data->strings = oasys_malloc(abfd, data->symbol_string_length +
96 data->strings = oasys_malloc(abfd, data->symbol_string_length);
99 dest_undefined = data->symbols;
100 dest_defined = data->symbols + abfd->symcount -1;
102 string_ptr = data->strings;
103 bfd_seek(abfd, (file_ptr)0, SEEK_SET);
106 oasys_read_record(abfd, &record);
107 switch (record.header.type) {
108 case oasys_record_is_header_enum:
110 case oasys_record_is_local_enum:
111 case oasys_record_is_symbol_enum:
113 int flag = record.header.type == oasys_record_is_local_enum ?
114 (BSF_LOCAL) : (BSF_GLOBAL | BSF_EXPORT);
117 size_t length = oasys_string_length(&record);
118 switch (record.symbol.relb & RELOCATION_TYPE_BITS) {
119 case RELOCATION_TYPE_ABS:
120 dest = dest_defined--;
122 dest->flags = BSF_ABSOLUTE | flag;
124 case RELOCATION_TYPE_REL:
125 dest = dest_defined--;
127 oasys_data(abfd)->sections[record.symbol.relb &
128 RELOCATION_SECT_BITS];
129 if (record.header.type == oasys_record_is_local_enum)
131 dest->flags = BSF_LOCAL;
138 case RELOCATION_TYPE_UND:
139 dest = data->symbols + bfd_h_getshort(abfd, &record.symbol.refno[0]);
140 dest->section = (asection *)NULL;
141 dest->flags = BSF_UNDEFINED;
143 case RELOCATION_TYPE_COM:
144 dest = dest_defined--;
145 dest->name = string_ptr;
146 dest->the_bfd = abfd;
148 dest->section = (asection *)NULL;
149 dest->flags = BSF_FORT_COMM;
152 dest->name = string_ptr;
153 dest->the_bfd = abfd;
154 dest->udata = (PTR)NULL;
155 dest->value = bfd_h_getlong(abfd, &record.symbol.value[0]);
157 #ifdef UNDERSCORE_HACK
158 if (record.symbol.name[0] != '_') {
163 memcpy(string_ptr, record.symbol.name, length);
166 string_ptr[length] =0;
167 string_ptr += length +1;
179 DEFUN(oasys_get_symtab_upper_bound,(abfd),
182 oasys_slurp_symbol_table (abfd);
184 return (abfd->symcount+1) * (sizeof (oasys_symbol_type *));
190 extern bfd_target oasys_vec;
193 DEFUN(oasys_get_symtab,(abfd, location),
198 unsigned int counter ;
199 if (oasys_slurp_symbol_table(abfd) == false) {
202 symbase = oasys_data(abfd)->symbols;
203 for (counter = 0; counter < abfd->symcount; counter++) {
204 *(location++) = symbase++;
207 return abfd->symcount;
210 /***********************************************************************
213 #define swap(x) x = bfd_h_get_x(abfd, &x);
215 DEFUN(oasys_archive_p,(abfd),
218 oasys_archive_header_type header;
221 bfd_seek(abfd, (file_ptr) 0, false);
224 bfd_read(&header, 1, sizeof(header), abfd);
227 swap(header.version);
228 swap(header.mod_count);
229 swap(header.mod_tbl_offset);
230 swap(header.sym_tbl_size);
231 swap(header.sym_count);
232 swap(header.sym_tbl_offset);
233 swap(header.xref_count);
234 swap(header.xref_lst_offset);
237 There isn't a magic number in an Oasys archive, so the best we
238 can do to verify reasnableness is to make sure that the values in
239 the header are too weird
242 if (header.version>10000 ||
243 header.mod_count>10000 ||
244 header.sym_count>100000 ||
245 header.xref_count > 100000) return (bfd_target *)NULL;
248 That all worked, lets buy the space for the header and read in
252 oasys_ar_data_type *ar =
253 (oasys_ar_data_type*) oasys_malloc(abfd, sizeof(oasys_ar_data_type));
256 oasys_module_info_type *module =
257 (oasys_module_info_type*)
258 oasys_malloc(abfd, sizeof(oasys_module_info_type) * header.mod_count);
260 oasys_module_table_type record;
262 oasys_ar_data(abfd) =ar;
264 ar->module_count = header.mod_count;
266 bfd_seek(abfd , header.mod_tbl_offset, SEEK_SET);
267 for (i = 0; i < header.mod_count; i++) {
269 bfd_read(&record, 1, sizeof(record), abfd);
270 swap(record.mod_size);
271 swap(record.file_offset);
272 swap(record.mod_name_length);
273 module[i].name = oasys_malloc(abfd,record.mod_name_length+1);
275 bfd_read(module[i].name, 1, record.mod_name_length +1, abfd);
276 /* SKip some stuff */
277 bfd_seek(abfd, record.dep_count * sizeof(int32_type),
280 module[i].size = record.mod_size;
281 module[i].pos = record.file_offset;
289 DEFUN(oasys_mkobject,(abfd),
292 struct obstack tmp_obstack;
293 oasys_data_type *oasys;
294 obstack_init(&tmp_obstack);
295 BFD_ASSERT(oasys_data(abfd) == 0);
297 (oasys_data_type*)obstack_alloc(&tmp_obstack,sizeof(oasys_data_type));
298 oasys = oasys_data(abfd);
299 oasys->oasys_obstack = tmp_obstack;
305 DEFUN(oasys_object_p,(abfd),
308 oasys_data_type *oasys;
310 boolean had_usefull = false;
311 oasys_data(abfd) = 0;
312 oasys_mkobject(abfd);
313 oasys = oasys_data(abfd);
314 memset((PTR)oasys->sections, 0xff, sizeof(oasys->sections));
316 /* Point to the start of the file */
317 bfd_seek(abfd, (file_ptr)0, SEEK_SET);
318 oasys->symbol_string_length = 0;
319 /* Inspect the records, but only keep the section info -
320 remember the size of the symbols
322 oasys->first_data_record = 0;
324 oasys_record_union_type record;
325 oasys_read_record(abfd, &record);
326 if ((size_t)record.header.length < (size_t)sizeof(record.header))
330 switch ((oasys_record_enum_type)(record.header.type)) {
331 case oasys_record_is_header_enum:
334 case oasys_record_is_symbol_enum:
335 case oasys_record_is_local_enum:
336 /* Count symbols and remember their size for a future malloc */
338 oasys->symbol_string_length += 1 + oasys_string_length(&record);
341 case oasys_record_is_section_enum:
345 unsigned int section_number;
346 if (record.section.header.length != sizeof(record.section))
350 buffer = oasys_malloc(abfd, 3);
351 section_number= record.section.relb & RELOCATION_SECT_BITS;
352 sprintf(buffer,"%u", section_number);
353 s = bfd_make_section(abfd,buffer);
354 oasys->sections[section_number] = s;
355 switch (record.section.relb & RELOCATION_TYPE_BITS) {
356 case RELOCATION_TYPE_ABS:
357 case RELOCATION_TYPE_REL:
359 case RELOCATION_TYPE_UND:
360 case RELOCATION_TYPE_COM:
364 s->size = bfd_h_getlong(abfd, & record.section.value[0]) ;
365 s->vma = bfd_h_getlong(abfd, &record.section.vma[0]);
366 s->flags |= SEC_LOAD | SEC_HAS_CONTENTS;
370 case oasys_record_is_data_enum:
371 oasys->first_data_record = bfd_tell(abfd) - record.header.length;
372 case oasys_record_is_debug_enum:
373 case oasys_record_is_module_enum:
374 case oasys_record_is_named_section_enum:
375 case oasys_record_is_end_enum:
376 if (had_usefull == false) goto fail;
383 oasys->symbols = (asymbol *)NULL;
385 Oasys support several architectures, but I can't see a simple way
386 to discover which one is in a particular file - we'll guess
388 abfd->obj_arch = bfd_arch_m68k;
389 abfd->obj_machine =0;
390 if (abfd->symcount != 0) {
391 abfd->flags |= HAS_SYMS;
396 (void) obstack_finish(&oasys->oasys_obstack);
397 return (bfd_target *)NULL;
402 DEFUN(oasys_print_symbol,(ignore_abfd, file, symbol, how),
406 bfd_print_symbol_enum_type how)
409 case bfd_print_symbol_name_enum:
410 case bfd_print_symbol_type_enum:
411 fprintf(file,"%s", symbol->name);
413 case bfd_print_symbol_all_enum:
415 CONST char *section_name = symbol->section == (asection *)NULL ?
416 "*abs" : symbol->section->name;
418 bfd_print_symbol_vandf((PTR)file,symbol);
420 fprintf(file," %-5s %s",
428 The howto table is build using the top two bits of a reloc byte to
429 index into it. The bits are PCREL,WORD/LONG
431 static reloc_howto_type howto_table[]=
433 /* T rs size bsz pcrel bitpos abs ovr sf name partial inplace mask */
435 { 0, 0, 1, 16, false,0, true,true,0,"abs16",true,0x0000ffff, 0x0000ffff},
436 { 0, 0, 2, 32, false,0, true,true,0,"abs32",true,0xffffffff, 0xffffffff},
437 { 0, 0, 1, 16, true,0, true,true,0,"pcrel16",true,0x0000ffff, 0x0000ffff},
438 { 0, 0, 2, 32, true,0, true,true,0,"pcrel32",true,0xffffffff, 0xffffffff}
441 /* Read in all the section data and relocation stuff too */
443 DEFUN(oasys_slurp_section_data,(abfd),
446 oasys_record_union_type record;
447 oasys_data_type *data = oasys_data(abfd);
450 oasys_per_section_type *per ;
454 /* Buy enough memory for all the section data and relocations */
455 for (s = abfd->sections; s != (asection *)NULL; s= s->next) {
456 per = oasys_per_section(s);
457 if (per->data != (bfd_byte*)NULL) return true;
458 per->data = (bfd_byte *) oasys_malloc(abfd, s->size);
459 per->reloc_tail_ptr = (oasys_reloc_type **)&(s->relocation);
460 per->had_vma = false;
464 if (data->first_data_record == 0) return true;
465 bfd_seek(abfd, data->first_data_record, SEEK_SET);
467 oasys_read_record(abfd, &record);
468 switch (record.header.type) {
469 case oasys_record_is_header_enum:
471 case oasys_record_is_data_enum:
474 uint8e_type *src = record.data.data;
475 uint8e_type *end_src = ((uint8e_type *)&record) +
476 record.header.length;
479 bfd_byte *dst_base_ptr ;
482 data->sections[record.data.relb & RELOCATION_SECT_BITS];
484 per = oasys_per_section(section);
485 dst_offset = bfd_h_getlong(abfd, record.data.addr) ;
486 if (per->had_vma == false) {
487 /* Take the first vma we see as the base */
489 section->vma = dst_offset;
494 dst_offset -= section->vma;
497 dst_base_ptr = oasys_per_section(section)->data;
498 dst_ptr = oasys_per_section(section)->data +
501 while (src < end_src) {
502 uint32_type gap = end_src - src -1;
503 uint8e_type mod_byte = *src++;
505 if (mod_byte == 0 && gap >= 8) {
518 for (relbit = 1; count-- != 0 && gap != 0; gap --, relbit <<=1)
520 if (relbit & mod_byte)
522 uint8e_type reloc = *src;
523 /* This item needs to be relocated */
524 switch (reloc & RELOCATION_TYPE_BITS) {
525 case RELOCATION_TYPE_ABS:
529 case RELOCATION_TYPE_REL:
531 /* Relocate the item relative to the section */
532 oasys_reloc_type *r =
535 sizeof(oasys_reloc_type));
536 *(per->reloc_tail_ptr) = r;
537 per->reloc_tail_ptr = &r->next;
538 r->next= (oasys_reloc_type *)NULL;
539 /* Reference to undefined symbol */
541 /* There is no symbol */
543 /* Work out the howto */
545 data->sections[reloc & RELOCATION_SECT_BITS];
546 r->relent.addend = - r->relent.section->vma;
547 r->relent.address = dst_ptr - dst_base_ptr;
548 r->relent.howto = &howto_table[reloc>>6];
549 r->relent.sym_ptr_ptr = (asymbol **)NULL;
550 section->reloc_count++;
555 case RELOCATION_TYPE_UND:
557 oasys_reloc_type *r =
560 sizeof(oasys_reloc_type));
561 *(per->reloc_tail_ptr) = r;
562 per->reloc_tail_ptr = &r->next;
563 r->next= (oasys_reloc_type *)NULL;
564 /* Reference to undefined symbol */
566 /* Get symbol number */
567 r->symbol = (src[0]<<8) | src[1];
568 /* Work out the howto */
569 r->relent.section = (asection *)NULL;
570 r->relent.addend = 0;
571 r->relent.address = dst_ptr - dst_base_ptr;
572 r->relent.howto = &howto_table[reloc>>6];
573 r->relent.sym_ptr_ptr = (asymbol **)NULL;
574 section->reloc_count++;
579 case RELOCATION_TYPE_COM:
589 case oasys_record_is_local_enum:
590 case oasys_record_is_symbol_enum:
591 case oasys_record_is_section_enum:
603 bfd_error_vector_type bfd_error_vector;
606 DEFUN(oasys_new_section_hook,(abfd, newsect),
610 newsect->used_by_bfd = (PTR)
611 oasys_malloc(abfd, sizeof(oasys_per_section_type));
612 oasys_per_section( newsect)->data = (bfd_byte *)NULL;
613 oasys_per_section(newsect)->section = newsect;
614 oasys_per_section(newsect)->offset = 0;
615 newsect->alignment_power = 3;
616 /* Turn the section string into an index */
618 sscanf(newsect->name,"%u", &newsect->target_index);
625 DEFUN(oasys_get_reloc_upper_bound, (abfd, asect),
629 oasys_slurp_section_data(abfd);
630 return (asect->reloc_count+1) * sizeof(arelent *);
634 DEFUN(oasys_get_section_contents,(abfd, section, location, offset, count),
641 oasys_per_section_type *p = (oasys_per_section_type *) section->used_by_bfd;
642 oasys_slurp_section_data(abfd);
643 (void) memcpy(location, p->data + offset, count);
649 DEFUN(oasys_canonicalize_reloc,(abfd, section, relptr, symbols),
655 unsigned int reloc_count = 0;
656 oasys_reloc_type *src = (oasys_reloc_type *)(section->relocation);
657 while (src != (oasys_reloc_type *)NULL) {
658 if (src->relent.section == (asection *)NULL)
660 src->relent.sym_ptr_ptr = symbols + src->symbol;
662 *relptr ++ = &src->relent;
666 *relptr = (arelent *)NULL;
667 return section->reloc_count = reloc_count;
672 DEFUN(oasys_set_arch_mach, (abfd, arch, machine),
674 enum bfd_architecture arch AND
675 unsigned long machine)
677 abfd->obj_arch = arch;
678 abfd->obj_machine = machine;
687 /* Calculate the checksum and write one record */
689 DEFUN(oasys_write_record,(abfd, type, record, size),
691 CONST oasys_record_enum_type type AND
692 oasys_record_union_type *record AND
698 record->header.length = size;
699 record->header.type = type;
700 record->header.check_sum = 0;
701 record->header.fill = 0;
702 ptr = &record->pad[0];
704 for (i = 0; i < size; i++) {
707 record->header.check_sum = 0xff & (- checksum);
708 bfd_write((PTR)record, 1, size, abfd);
712 /* Write out all the symbols */
714 DEFUN(oasys_write_syms, (abfd),
718 asymbol **generic = bfd_get_outsymbols(abfd);
719 unsigned int index = 0;
720 for (count = 0; count < bfd_get_symcount(abfd); count++) {
722 oasys_symbol_record_type symbol;
723 asymbol * CONST g = generic[count];
725 CONST char *src = g->name;
726 char *dst = symbol.name;
729 if (g->flags & BSF_FORT_COMM) {
730 symbol.relb = RELOCATION_TYPE_COM;
731 bfd_h_putshort(abfd, index, (uint8e_type *)(&symbol.refno[0]));
734 else if (g->flags & BSF_ABSOLUTE) {
735 symbol.relb = RELOCATION_TYPE_ABS;
736 bfd_h_putshort(abfd, 0, (uint8e_type *)(&symbol.refno[0]));
739 else if (g->flags & BSF_UNDEFINED) {
740 symbol.relb = RELOCATION_TYPE_UND ;
741 bfd_h_putshort(abfd, index, (uint8e_type *)(&symbol.refno[0]));
742 /* Overload the value field with the output index number */
745 else if (g->flags & BSF_DEBUGGING) {
750 symbol.relb = RELOCATION_TYPE_REL | g->section->output_section->target_index;
751 bfd_h_putshort(abfd, 0, (uint8e_type *)(&symbol.refno[0]));
758 bfd_h_putlong(abfd, g->value, symbol.value);
761 if (g->flags & BSF_LOCAL) {
762 oasys_write_record(abfd,
763 oasys_record_is_local_enum,
764 (oasys_record_union_type *) &symbol,
765 offsetof(oasys_symbol_record_type, name[0]) + l);
768 oasys_write_record(abfd,
769 oasys_record_is_symbol_enum,
770 (oasys_record_union_type *) &symbol,
771 offsetof(oasys_symbol_record_type, name[0]) + l);
778 /* Write a section header for each section */
780 DEFUN(oasys_write_sections, (abfd),
784 static oasys_section_record_type out = {0};
786 for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
787 if (!isdigit(s->name[0]))
789 bfd_error_vector.nonrepresentable_section(abfd,
792 out.relb = RELOCATION_TYPE_REL | s->target_index;
793 bfd_h_putlong(abfd, s->size, out.value);
794 bfd_h_putlong(abfd, s->vma, out.vma);
796 oasys_write_record(abfd,
797 oasys_record_is_section_enum,
798 (oasys_record_union_type *) &out,
804 DEFUN(oasys_write_header, (abfd),
807 /* Create and write the header */
808 oasys_header_record_type r;
809 size_t length = strlen(abfd->filename);
810 if (length > (size_t)sizeof(r.module_name)) {
811 length = sizeof(r.module_name);
814 (void)memcpy(r.module_name,
817 (void)memset(r.module_name + length,
819 sizeof(r.module_name) - length);
821 r.version_number = OASYS_VERSION_NUMBER;
822 r.rev_number = OASYS_REV_NUMBER;
823 oasys_write_record(abfd,
824 oasys_record_is_header_enum,
825 (oasys_record_union_type *)&r,
826 offsetof(oasys_header_record_type, description[0]));
833 DEFUN(oasys_write_end,(abfd),
836 oasys_end_record_type end;
837 end.relb = RELOCATION_TYPE_ABS;
838 bfd_h_putlong(abfd, abfd->start_address, end.entry);
839 bfd_h_putshort(abfd, 0, end.fill);
841 oasys_write_record(abfd,
842 oasys_record_is_end_enum,
843 (oasys_record_union_type *)&end,
854 return a->address - b->address;
862 DEFUN(oasys_write_data, (abfd),
866 for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
867 uint8e_type *raw_data = oasys_per_section(s)->data;
868 oasys_data_record_type processed_data;
869 unsigned int current_byte_index = 0;
870 unsigned int relocs_to_go = s->reloc_count;
871 arelent **p = s->orelocation;
872 if (s->reloc_count != 0) {
873 /* Sort the reloc records so it's easy to insert the relocs into the
876 qsort(s->orelocation,
881 current_byte_index = 0;
882 processed_data.relb = s->target_index | RELOCATION_TYPE_REL;
884 while ((size_t)current_byte_index < s->size)
886 /* Scan forwards by eight bytes or however much is left and see if
887 there are any relocations going on */
888 uint8e_type *mod = &processed_data.data[0];
889 uint8e_type *dst = &processed_data.data[1];
892 unsigned int long_length = 128;
895 bfd_h_putlong(abfd, s->vma + current_byte_index, processed_data.addr);
896 if (long_length + current_byte_index > s->size) {
897 long_length = s->size - current_byte_index;
899 while (long_length > 0 && (dst - (uint8e_type*)&processed_data < 128)) {
901 unsigned int length = long_length;
906 for (i = 0; i < length; i++) {
907 if (relocs_to_go != 0) {
909 reloc_howto_type *CONST how=r->howto;
910 /* There is a relocation, is it for this byte ? */
911 if (r->address == current_byte_index) {
912 uint8e_type rel_byte;
917 if(how->pc_relative) {
927 /* Is this a section relative relocation, or a symbol
928 relative relocation ? */
929 if (r->section != (asection*)NULL)
931 /* The relent has a section attatched, so it must be section
933 rel_byte |= RELOCATION_TYPE_REL;
934 rel_byte |= r->section->output_section->target_index;
939 asymbol *p = *(r->sym_ptr_ptr);
941 /* If this symbol has a section attatched, then it
942 has already been resolved. Change from a symbol
943 ref to a section ref */
944 if(p->section != (asection *)NULL) {
945 rel_byte |= RELOCATION_TYPE_REL;
947 p->section->output_section->target_index;
951 rel_byte |= RELOCATION_TYPE_UND;
955 /* Next two bytes are a symbol index - we can get
956 this from the symbol value which has been zapped
957 into the symbol index in the table when the
958 symbol table was written
960 *dst++ = p->value >> 8;
967 /* If this is coming from an unloadable section then copy
969 if (raw_data == (uint8e_type *)NULL) {
973 *dst++ = *raw_data++;
975 current_byte_index++;
978 long_length -= length;
981 oasys_write_record(abfd,
982 oasys_record_is_data_enum,
983 (oasys_record_union_type *)&processed_data,
984 dst - (uint8e_type*)&processed_data);
990 DEFUN(oasys_write_object_contents, (abfd),
993 oasys_write_header(abfd);
994 oasys_write_syms(abfd);
995 oasys_write_sections(abfd);
996 oasys_write_data(abfd);
997 oasys_write_end(abfd);
1004 /** exec and core file sections */
1006 /* set section contents is complicated with OASYS since the format is
1007 * not a byte image, but a record stream.
1010 DEFUN(oasys_set_section_contents,(abfd, section, location, offset, count),
1013 unsigned char *location AND
1018 if (oasys_per_section(section)->data == (bfd_byte *)NULL )
1020 oasys_per_section(section)->data =
1021 (bfd_byte *)(oasys_malloc(abfd,section->size));
1023 (void) memcpy(oasys_per_section(section)->data + offset,
1032 /* Native-level interface to symbols. */
1034 /* We read the symbols into a buffer, which is discarded when this
1035 function exits. We read the strings into a buffer large enough to
1036 hold them all plus all the cached symbol entries. */
1039 DEFUN(oasys_make_empty_symbol,(abfd),
1043 oasys_symbol_type *new =
1044 (oasys_symbol_type *)zalloc (sizeof (oasys_symbol_type));
1045 new->symbol.the_bfd = abfd;
1046 return &new->symbol;
1052 /* Obsbolete procedural interface; better to look at the cache directly */
1054 /* User should have checked the file flags; perhaps we should return
1055 BFD_NO_MORE_SYMBOLS if there are none? */
1060 oasys_close_and_cleanup (abfd)
1063 if (bfd_read_p (abfd) == false)
1064 switch (abfd->format) {
1066 if (!_bfd_write_archive_contents (abfd)) {
1071 if (!oasys_write_object_contents (abfd)) {
1076 bfd_error = invalid_operation;
1081 if (oasys_data(abfd) != (oasys_data_type *)NULL) {
1082 /* It's so easy to throw everything away */
1083 (void) obstack_finish(&(oasys_data(abfd)->oasys_obstack));
1090 oasys_openr_next_archived_file(arch, prev)
1094 oasys_ar_data_type *ar = oasys_ar_data(arch);
1095 oasys_module_info_type *p;
1096 /* take the next one from the arch state, or reset */
1097 if (prev == (bfd *)NULL) {
1098 /* Reset the index - the first two entries are bogus*/
1099 ar->module_index = 0;
1102 p = ar->module + ar->module_index;
1105 if (ar->module_index <= ar->module_count) {
1106 if (p->abfd == (bfd *)NULL) {
1107 p->abfd = _bfd_create_empty_archive_element_shell(arch);
1108 p->abfd->origin = p->pos;
1109 p->abfd->filename = p->name;
1111 /* Fixup a pointer to this element for the member */
1112 p->abfd->arelt_data = (PTR)p;
1117 bfd_error = no_more_archived_files;
1123 oasys_find_nearest_line(abfd,
1134 char **filename_ptr;
1135 char **functionname_ptr;
1136 unsigned int *line_ptr;
1143 oasys_stat_arch_elt(abfd, buf)
1147 oasys_module_info_type *mod = (oasys_module_info_type *) abfd->arelt_data;
1148 if (mod == (oasys_module_info_type *)NULL) {
1149 bfd_error = invalid_operation;
1153 buf->st_size = mod->size;
1154 buf->st_mode = 0666;
1163 bfd_target oasys_vec =
1166 bfd_target_oasys_flavour_enum,
1167 true, /* target byte order */
1168 true, /* target headers byte order */
1169 (HAS_RELOC | EXEC_P | /* object flags */
1170 HAS_LINENO | HAS_DEBUG |
1171 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
1172 (SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
1173 |SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
1174 0, /* valid reloc types */
1175 ' ', /* ar_pad_char */
1176 16, /* ar_max_namelen */
1177 oasys_close_and_cleanup, /* _close_and_cleanup */
1178 oasys_set_section_contents, /* bfd_set_section_contents */
1179 oasys_get_section_contents,
1180 oasys_new_section_hook, /* new_section_hook */
1181 0, /* _core_file_failing_command */
1182 0, /* _core_file_failing_signal */
1183 0, /* _core_file_matches_ex...p */
1185 0, /* bfd_slurp_bsd_armap, bfd_slurp_armap */
1186 bfd_true, /* bfd_slurp_extended_name_table */
1187 bfd_bsd_truncate_arname, /* bfd_truncate_arname */
1189 oasys_get_symtab_upper_bound, /* get_symtab_upper_bound */
1190 oasys_get_symtab, /* canonicalize_symtab */
1191 0, /* oasys_reclaim_symbol_table, bfd_reclaim_symbol_table */
1192 oasys_get_reloc_upper_bound, /* get_reloc_upper_bound */
1193 oasys_canonicalize_reloc, /* bfd_canonicalize_reloc */
1194 0, /* oasys_reclaim_reloc, bfd_reclaim_reloc */
1195 0, /* oasys_get_symcount_upper_bound, bfd_get_symcount_upper_bound */
1196 0, /* oasys_get_first_symbol, bfd_get_first_symbol */
1197 0, /* oasys_get_next_symbol, bfd_get_next_symbol */
1198 0, /* oasys_classify_symbol, bfd_classify_symbol */
1199 0, /* oasys_symbol_hasclass, bfd_symbol_hasclass */
1200 0, /* oasys_symbol_name, bfd_symbol_name */
1201 0, /* oasys_symbol_value, bfd_symbol_value */
1203 _do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* data */
1204 _do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */
1207 oasys_object_p, /* bfd_check_format */
1214 _bfd_generic_mkarchive,
1217 oasys_make_empty_symbol,
1219 bfd_false, /* oasys_get_lineno,*/
1220 oasys_set_arch_mach, /* bfd_set_arch_mach,*/
1222 oasys_openr_next_archived_file,
1223 oasys_find_nearest_line, /* bfd_find_nearest_line */
1224 oasys_stat_arch_elt, /* bfd_stat_arch_elt */