1 /* bfd backend for ieee-695 objects.
3 IEEE 695 format is a stream of records, which we parse using a simple one
4 token (which is one byte in this lexicon) lookahead recursive decent
7 /* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
9 This file is part of BFD, the Binary File Diddler.
11 BFD is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 1, or (at your option)
16 BFD is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with BFD; see the file COPYING. If not, write to
23 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
33 #define obstack_chunk_alloc malloc
34 #define obstack_chunk_free free
35 #define ieee_malloc(abfd,size) \
36 obstack_alloc(&( ieee_data(abfd)->ieee_obstack), (size))
38 typedef void generic_symbol_type
;
41 /***************************************************************************
42 Functions for writing to ieee files in the strange way that the
48 DEFUN(ieee_write_byte
,(abfd
, byte
),
52 bfd_write(&byte
, 1, 1, abfd
);
57 DEFUN(ieee_write_2bytes
,(abfd
, bytes
),
62 buffer
[0] = bytes
>> 8;
63 buffer
[1] = bytes
& 0xff;
65 bfd_write(buffer
, 1, 2, abfd
);
69 DEFUN(ieee_write_int
,(abfd
, value
),
73 if (value
>= 0 && value
<= 127) {
74 ieee_write_byte(abfd
, value
);
78 /* How many significant bytes ? */
79 /* FIXME FOR LONGER INTS */
80 if (value
& 0xff000000) {
83 else if (value
& 0x00ff0000) {
86 else if (value
& 0x0000ff00) {
91 ieee_write_byte(abfd
, ieee_number_repeat_start_enum
+ length
);
94 ieee_write_byte(abfd
, value
>> 24);
96 ieee_write_byte(abfd
, value
>> 16);
98 ieee_write_byte(abfd
, value
>> 8);
100 ieee_write_byte(abfd
, value
);
106 DEFUN(ieee_write_id
,(abfd
, id
),
110 size_t length
= strlen(id
);
111 if (length
>= 0 && length
<= 127) {
112 ieee_write_byte(abfd
, length
);
114 else if (length
< 255) {
115 ieee_write_byte(abfd
, ieee_extension_length_1_enum
);
116 ieee_write_byte(abfd
, length
);
118 else if (length
< 65535) {
119 ieee_write_byte(abfd
, ieee_extension_length_2_enum
);
120 ieee_write_byte(abfd
, length
>> 8);
121 ieee_write_byte(abfd
, length
& 0xff);
126 bfd_write((bfd_byte
*)id
, 1, length
, abfd
);
128 /***************************************************************************
129 Functions for reading from ieee files in the strange way that the
133 #define this_byte(abfd) *(ptr(abfd))
134 #define next_byte(abfd) (ptr(abfd)++)
135 #define this_byte_and_next(abfd) *(ptr(abfd)++)
138 static unsigned short
139 DEFUN(read_2bytes
,(abfd
),
142 unsigned char c1
= this_byte_and_next(abfd
);
143 unsigned char c2
= this_byte_and_next(abfd
);
144 return (c1
<<8 ) | c2
;
149 DEFUN(bfd_get_string
,(abfd
, string
, length
),
155 for (i
= 0; i
< length
; i
++) {
156 string
[i
] = this_byte_and_next(abfd
);
161 DEFUN(read_id
,(abfd
),
166 length
= this_byte_and_next(abfd
);
167 if (length
>= 0x00 && length
<= 0x7f) {
168 /* Simple string of length 0 to 127 */
170 else if (length
== 0xde) {
171 /* Length is next byte, allowing 0..255 */
172 length
= this_byte_and_next(abfd
);
174 else if (length
== 0xdf) {
175 /* Length is next two bytes, allowing 0..65535 */
176 length
= this_byte_and_next(abfd
) ;
177 length
= (length
* 256) + this_byte_and_next(abfd
);
179 /* Buy memory and read string */
180 string
= ieee_malloc(abfd
, length
+1);
181 bfd_get_string(abfd
, string
, length
);
187 DEFUN(ieee_write_expression
,(abfd
, value
, section
, symbol
),
190 asection
*section AND
193 unsigned int plus_count
= 0;
194 ieee_write_int(abfd
, value
);
195 if (section
!= (asection
*)NULL
) {
197 ieee_write_byte(abfd
, ieee_variable_L_enum
);
198 ieee_write_byte(abfd
, section
->index
+IEEE_SECTION_NUMBER_BASE
);
201 if (symbol
!= (asymbol
*)NULL
) {
203 if ((symbol
->flags
& BSF_UNDEFINED
) ||
204 (symbol
->flags
& BSF_FORT_COMM
)) {
205 ieee_write_byte(abfd
, ieee_variable_X_enum
);
206 ieee_write_int(abfd
, symbol
->value
);
208 else if (symbol
->flags
& BSF_GLOBAL
) {
209 ieee_write_byte(abfd
, ieee_variable_I_enum
);
210 ieee_write_int(abfd
, symbol
->value
);
212 else if (symbol
->flags
& BSF_LOCAL
) {
213 /* This is a reference to a defined local symbol,
214 We can easily do a local as a section+offset */
215 if (symbol
->section
!= (asection
*)NULL
) {
216 /* If this symbol is not absolute, add the base of it */
217 ieee_write_byte(abfd
, ieee_variable_L_enum
);
218 ieee_write_byte(abfd
, symbol
->section
->index
+
219 IEEE_SECTION_NUMBER_BASE
);
223 ieee_write_int(abfd
, symbol
->value
);
231 while (plus_count
!= 0) {
232 ieee_write_byte(abfd
, ieee_function_plus_enum
);
246 /*****************************************************************************/
249 writes any integer into the buffer supplied and always takes 5 bytes
252 DEFUN(ieee_write_int5
,(buffer
, value
),
256 buffer
[0] = ieee_number_repeat_4_enum
;
257 buffer
[1] = (value
>> 24 ) & 0xff;
258 buffer
[2] = (value
>> 16 ) & 0xff;
259 buffer
[3] = (value
>> 8 ) & 0xff;
260 buffer
[4] = (value
>> 0 ) & 0xff;
263 DEFUN(ieee_write_int5_out
, (abfd
, value
),
268 ieee_write_int5(b
, value
);
269 bfd_write(b
,1,5,abfd
);
274 DEFUN(parse_int
,(abfd
, value_ptr
),
278 int value
= this_byte(abfd
);
280 if (value
>= 0 && value
<= 127) {
285 else if (value
>= 0x80 && value
<= 0x88) {
286 unsigned int count
= value
& 0xf;
290 result
=(result
<< 8) | this_byte_and_next(abfd
);
299 DEFUN(parse_i
,(abfd
, ok
),
304 *ok
= parse_int(abfd
, &x
);
309 DEFUN(must_parse_int
,(abfd
),
313 BFD_ASSERT(parse_int(abfd
, &result
) == true);
321 ieee_symbol_index_type symbol
;
326 reloc_howto_type abs32_howto
327 = HOWTO(1,0,2,32,0,0,0,true,0,"abs32",false,0xffffffff, 0xffffffff,false);
329 reloc_howto_type abs16_howto
330 = HOWTO(1,0,1,16,0,0,0,true,0,"abs16",false,0x0000ffff, 0x0000ffff,false);
332 static ieee_symbol_index_type NOSYMBOL
= { 0, 0};
336 DEFUN(parse_expression
,(abfd
, value
, section
, symbol
, pcrel
, extra
),
339 asection
**section AND
340 ieee_symbol_index_type
*symbol AND
351 ieee_value_type stack
[10];
353 /* The stack pointer always points to the next unused location */
354 #define PUSH(x,y,z) TOS.symbol=x;TOS.section=y;TOS.value=z;INC;
355 #define POP(x,y,z) DEC;x=TOS.symbol;y=TOS.section;z=TOS.value;
356 ieee_value_type
*sp
= stack
;
359 switch (this_byte(abfd
))
361 case ieee_variable_P_enum
:
362 /* P variable, current program counter for section n */
366 section_n
= must_parse_int(abfd
);
368 TOS
.value
= ieee_data(abfd
)->section_table
[section_n
]->vma
+
369 ieee_per_section(ieee_data(abfd
)->section_table
[section_n
])->pc
);
372 case ieee_variable_L_enum
:
373 /* L variable address of section N */
375 PUSH(NOSYMBOL
,ieee_data(abfd
)->section_table
[must_parse_int(abfd
)],0);
377 case ieee_variable_R_enum
:
378 /* R variable, logical address of section module */
379 /* FIXME, this should be different to L */
381 PUSH(NOSYMBOL
,ieee_data(abfd
)->section_table
[must_parse_int(abfd
)],0);
383 case ieee_variable_S_enum
:
384 /* S variable, size in MAUS of section module */
388 ieee_data(abfd
)->section_table
[must_parse_int(abfd
)]->size
);
391 case ieee_variable_X_enum
:
392 /* Push the address of external variable n */
394 ieee_symbol_index_type sy
;
396 sy
.index
= (int)(must_parse_int(abfd
)) ;
402 case ieee_function_minus_enum
:
404 bfd_vma value1
, value2
;
406 ieee_symbol_index_type sy
;
409 POP(sy
, section
, value1
);
410 POP(sy
, section
, value2
);
411 PUSH(NOSYMBOL
, 0, value1
-value2
);
414 case ieee_function_plus_enum
:
416 bfd_vma value1
, value2
;
419 ieee_symbol_index_type sy1
;
420 ieee_symbol_index_type sy2
;
423 POP(sy1
, section1
, value1
);
424 POP(sy2
, section2
, value2
);
425 PUSH(sy1
.letter
? sy1
: sy2
, section1
? section1
: section2
, value1
+value2
);
431 BFD_ASSERT(this_byte(abfd
) < ieee_variable_A_enum
432 || this_byte(abfd
) > ieee_variable_Z_enum
);
433 if (parse_int(abfd
, &va
))
435 PUSH(NOSYMBOL
,0, va
);
439 Thats all that we can understand. As far as I can see
440 there is a bug in the Microtec IEEE output which I'm
441 using to scan, whereby the comma operator is ommited
442 sometimes in an expression, giving expressions with too
443 many terms. We can tell if that's the case by ensuring
444 that sp == stack here. If not, then we've pushed
448 POP(*symbol
, *section
, *value
);
450 BFD_ASSERT(*section
== 0);
452 /* Get what should be returned */
453 POP(*symbol
, *section
, *value
);
468 #define ieee_seek(abfd, offset) \
469 ieee_data(abfd)->input_p = ieee_data(abfd)->first_byte + offset
472 DEFUN(ieee_slurp_external_symbols
,(abfd
),
475 ieee_data_type
*ieee
= ieee_data(abfd
);
476 file_ptr offset
= ieee
->w
.r
.external_part
;
478 ieee_symbol_type
**prev_symbols_ptr
= &ieee
->external_symbols
;
479 ieee_symbol_type
**prev_reference_ptr
= &ieee
->external_reference
;
480 ieee_symbol_type
*symbol
;
481 unsigned int symbol_count
= 0;
484 ieee
->symbol_table_full
= true;
486 ieee_seek(abfd
, offset
);
489 switch (this_byte(abfd
)) {
490 case ieee_external_symbol_enum
:
492 symbol
= (ieee_symbol_type
*)ieee_malloc(abfd
, sizeof(ieee_symbol_type
));
494 *prev_symbols_ptr
= symbol
;
495 prev_symbols_ptr
= &symbol
->next
;
496 symbol
->index
= must_parse_int(abfd
);
497 if (symbol
->index
> ieee
->external_symbol_max_index
) {
498 ieee
->external_symbol_max_index
= symbol
->index
;
500 BFD_ASSERT (symbol
->index
>= ieee
->external_symbol_min_index
);
502 symbol
->symbol
.the_bfd
= abfd
;
503 symbol
->symbol
.name
= read_id(abfd
);
504 symbol
->symbol
.udata
= (void *)NULL
;
505 symbol
->symbol
.flags
= BSF_NO_FLAGS
;
507 case ieee_attribute_record_enum
>> 8:
509 unsigned int symbol_name_index
;
510 unsigned int symbol_type_index
;
511 unsigned int symbol_attribute_def
;
513 next_byte(abfd
); /* Skip prefix */
515 symbol_name_index
= must_parse_int(abfd
);
516 symbol_type_index
= must_parse_int(abfd
);
517 symbol_attribute_def
= must_parse_int(abfd
);
519 parse_int(abfd
,&value
);
523 case ieee_value_record_enum
>> 8:
525 unsigned int symbol_name_index
;
526 ieee_symbol_index_type symbol_ignore
;
527 boolean pcrel_ignore
;
528 unsigned int extra_ignore
;
532 symbol_name_index
= must_parse_int(abfd
);
533 parse_expression(abfd
,
534 &symbol
->symbol
.value
,
535 &symbol
->symbol
.section
,
539 if (symbol
->symbol
.section
!= (asection
*)NULL
) {
540 symbol
->symbol
.flags
= BSF_GLOBAL
| BSF_EXPORT
;
543 symbol
->symbol
.flags
= BSF_GLOBAL
| BSF_EXPORT
| BSF_ABSOLUTE
;
547 case ieee_weak_external_reference_enum
:
551 /* Throw away the external reference index */
552 (void)must_parse_int(abfd
);
553 /* Fetch the default size if not resolved */
554 size
= must_parse_int(abfd
);
555 /* Fetch the defautlt value if available */
556 if ( parse_int(abfd
, &value
) == false) {
559 /* This turns into a common */
560 symbol
->symbol
.flags
= BSF_FORT_COMM
;
561 symbol
->symbol
.value
= size
;
565 case ieee_external_reference_enum
:
567 symbol
= (ieee_symbol_type
*)ieee_malloc(abfd
, sizeof(ieee_symbol_type
));
569 *prev_reference_ptr
= symbol
;
570 prev_reference_ptr
= &symbol
->next
;
571 symbol
->index
= must_parse_int(abfd
);
572 symbol
->symbol
.the_bfd
= abfd
;
573 symbol
->symbol
.name
= read_id(abfd
);
574 symbol
->symbol
.udata
= (void *)NULL
;
575 symbol
->symbol
.section
= (asection
*)NULL
;
576 symbol
->symbol
.value
= (bfd_vma
)0;
577 symbol
->symbol
.flags
= BSF_UNDEFINED
;
578 if (symbol
->index
> ieee
->external_reference_max_index
) {
579 ieee
->external_reference_max_index
= symbol
->index
;
581 BFD_ASSERT (symbol
->index
>= ieee
->external_reference_min_index
);
589 if (ieee
->external_symbol_max_index
!= 0) {
590 ieee
->external_symbol_count
=
591 ieee
->external_symbol_max_index
-
592 ieee
->external_symbol_min_index
+ 1 ;
595 ieee
->external_symbol_count
= 0;
599 if(ieee
->external_reference_max_index
!= 0) {
600 ieee
->external_reference_count
=
601 ieee
->external_reference_max_index
-
602 ieee
->external_reference_min_index
+ 1;
605 ieee
->external_reference_count
= 0;
609 ieee
->external_reference_count
+ ieee
->external_symbol_count
;
611 if (symbol_count
!= abfd
->symcount
) {
612 /* There are gaps in the table -- */
613 ieee
->symbol_table_full
= false;
615 *prev_symbols_ptr
= (ieee_symbol_type
*)NULL
;
616 *prev_reference_ptr
= (ieee_symbol_type
*)NULL
;
620 DEFUN(ieee_slurp_symbol_table
,(abfd
),
623 if (ieee_data(abfd
)->read_symbols
== false) {
624 ieee_slurp_external_symbols(abfd
);
625 ieee_data(abfd
)->read_symbols
= true;
630 DEFUN(ieee_get_symtab_upper_bound
,(abfd
),
633 ieee_slurp_symbol_table (abfd
);
635 return (abfd
->symcount
!= 0) ?
636 (abfd
->symcount
+1) * (sizeof (ieee_symbol_type
*)) : 0;
640 Move from our internal lists to the canon table, and insert in
644 extern bfd_target ieee_vec
;
647 DEFUN(ieee_get_symtab
,(abfd
, location
),
651 ieee_symbol_type
*symp
;
652 static bfd dummy_bfd
;
653 static asymbol empty_symbol
=
654 { &dummy_bfd
," ieee empty",(symvalue
)0,BSF_DEBUGGING
| BSF_FAKE
};
656 ieee_data_type
*ieee
= ieee_data(abfd
);
657 dummy_bfd
.xvec
= &ieee_vec
;
658 ieee_slurp_symbol_table(abfd
);
660 if (ieee
->symbol_table_full
== false) {
661 /* Arrgh - there are gaps in the table, run through and fill them */
662 /* up with pointers to a null place */
664 for (i
= 0; i
< abfd
->symcount
; i
++) {
665 location
[i
] = &empty_symbol
;
670 ieee
->external_symbol_base_offset
= - ieee
->external_symbol_min_index
;
671 for (symp
= ieee_data(abfd
)->external_symbols
;
672 symp
!= (ieee_symbol_type
*)NULL
;
674 /* Place into table at correct index locations */
675 location
[symp
->index
+ ieee
->external_symbol_base_offset
] = &symp
->symbol
;
679 /* The external refs are indexed in a bit */
680 ieee
->external_reference_base_offset
=
681 - ieee
->external_reference_min_index
+ieee
->external_symbol_count
;
683 for (symp
= ieee_data(abfd
)->external_reference
;
684 symp
!= (ieee_symbol_type
*)NULL
;
686 location
[symp
->index
+ ieee
->external_reference_base_offset
] =
693 location
[abfd
->symcount
] = (asymbol
*)NULL
;
695 return abfd
->symcount
;
700 DEFUN(ieee_slurp_sections
,(abfd
),
703 ieee_data_type
*ieee
= ieee_data(abfd
);
704 file_ptr offset
= ieee
->w
.r
.section_part
;
706 asection
*section
= (asection
*)NULL
;
709 bfd_byte section_type
[3];
710 ieee_seek(abfd
, offset
);
712 switch (this_byte(abfd
)) {
713 case ieee_section_type_enum
:
715 unsigned int section_index
;
717 section_index
= must_parse_int(abfd
);
718 /* Fixme to be nice about a silly number of sections */
719 BFD_ASSERT(section_index
< NSECTIONS
);
721 section
= bfd_make_section(abfd
, " tempname");
722 ieee
->section_table
[section_index
] = section
;
723 section
->flags
= SEC_NO_FLAGS
;
724 section
->target_index
= section_index
;
725 section_type
[0] = this_byte_and_next(abfd
);
726 switch (section_type
[0]) {
728 section_type
[1] = this_byte(abfd
);
729 section
->flags
= SEC_LOAD
;
730 switch (section_type
[1]) {
734 section
->flags
|= SEC_LOAD
| SEC_CODE
;
738 section
->flags
|= SEC_LOAD
| SEC_DATA
;
743 /* Normal rom data */
744 section
->flags
|= SEC_LOAD
| SEC_ROM
| SEC_DATA
;
750 section
->name
= read_id(abfd
);
751 { bfd_vma parent
, brother
, context
;
752 parse_int(abfd
, &parent
);
753 parse_int(abfd
, &brother
);
754 parse_int(abfd
, &context
);
760 case ieee_section_alignment_enum
:
762 unsigned int section_index
;
765 section_index
= must_parse_int(abfd
);
766 if (section_index
> ieee
->section_count
) {
767 ieee
->section_count
= section_index
;
769 ieee
->section_table
[section_index
]->alignment_power
=
770 bfd_log2(must_parse_int(abfd
));
771 (void)parse_int(abfd
, & value
);
774 case ieee_e2_first_byte_enum
:
776 ieee_record_enum_type t
= read_2bytes(abfd
);
778 case ieee_section_size_enum
:
779 section
= ieee
->section_table
[must_parse_int(abfd
)];
780 section
->size
= must_parse_int(abfd
);
782 case ieee_physical_region_size_enum
:
783 section
= ieee
->section_table
[must_parse_int(abfd
)];
784 section
->size
= must_parse_int(abfd
);
786 case ieee_region_base_address_enum
:
787 section
= ieee
->section_table
[must_parse_int(abfd
)];
788 section
->vma
= must_parse_int(abfd
);
790 case ieee_mau_size_enum
:
791 must_parse_int(abfd
);
792 must_parse_int(abfd
);
794 case ieee_m_value_enum
:
795 must_parse_int(abfd
);
796 must_parse_int(abfd
);
798 case ieee_section_base_address_enum
:
799 section
= ieee
->section_table
[must_parse_int(abfd
)];
800 section
->vma
= must_parse_int(abfd
);
802 case ieee_section_offset_enum
:
803 (void) must_parse_int(abfd
);
804 (void) must_parse_int(abfd
);
818 /***********************************************************************
822 DEFUN(ieee_archive_p
,(abfd
),
827 ieee_ar_data_type
*ar
;
829 return 0; /* FIXME */
830 ieee_seek(abfd
, (file_ptr
) 0);
831 if (this_byte(abfd
) != Module_Beginning
) return (bfd_target
*)NULL
;
833 library
= read_id(abfd
);
834 if (strcmp(library
, "LIBRARY") != 0) {
836 return (bfd_target
*)NULL
;
838 /* Throw away the filename */
839 free( read_id(abfd
));
840 /* This must be an IEEE archive, so we'll buy some space to do
842 ar
= (ieee_ar_data_type
*) malloc(sizeof(ieee_ar_data_type
));
843 set_tdata (abfd
, ar
);
844 ar
->element_count
= 0;
845 ar
->element_index
= 0;
846 obstack_init(&ar
->element_obstack
);
848 next_byte(abfd
); /* Drop the ad part */
849 must_parse_int(abfd
); /* And the two dummy numbers */
850 must_parse_int(abfd
);
853 /* Read the index of the BB table */
855 ieee_ar_obstack_type t
;
856 int rec
=read_2bytes(abfd
);
857 if (rec
==ieee_assign_value_to_variable_enum
) {
858 int record_number
= must_parse_int(abfd
);
859 t
.file_offset
= must_parse_int(abfd
);
860 t
.abfd
= (bfd
*)NULL
;
862 obstack_grow(&ar
->element_obstack
, (PTR
)&t
, sizeof(t
));
866 ar
->elements
= (ieee_ar_obstack_type
*)obstack_base(&ar
->element_obstack
);
868 /* Now scan the area again, and replace BB offsets with file */
872 for (i
= 2; i
< ar
->element_count
; i
++) {
873 ieee_seek(abfd
, ar
->elements
[i
].file_offset
);
874 next_byte(abfd
); /* Drop F8 */
875 next_byte(abfd
); /* Drop 14 */
876 must_parse_int(abfd
); /* Drop size of block */
877 if (must_parse_int(abfd
) != 0) {
878 /* This object has been deleted */
879 ar
->elements
[i
].file_offset
= 0;
882 ar
->elements
[i
].file_offset
= must_parse_int(abfd
);
886 obstack_finish(&ar
->element_obstack
);
891 DEFUN(ieee_mkobject
,(abfd
),
894 struct obstack tmp_obstack
;
895 ieee_data_type
*ieee
;
897 obstack_init(&tmp_obstack
);
898 BFD_ASSERT(ieee_data(abfd
) == 0);
899 set_tdata (abfd
, obstack_alloc(&tmp_obstack
,sizeof(ieee_data_type
)));
900 ieee
= ieee_data(abfd
);
901 ieee
->ieee_obstack
= tmp_obstack
;
906 DEFUN(ieee_object_p
,(abfd
),
911 ieee_data_type
*ieee
;
916 ieee
= ieee_data(abfd
);
918 /* Read the first few bytes in to see if it makes sense */
919 bfd_read(buffer
, 1, sizeof(buffer
), abfd
);
922 if (*(ptr(abfd
)++) != Module_Beginning
) goto fail
;
924 ieee
->read_symbols
= false;
925 ieee
->read_data
= false;
926 ieee
->section_count
= 0;
927 ieee
->external_symbol_max_index
= 0;
928 ieee
->external_symbol_min_index
= IEEE_PUBLIC_BASE
;
929 ieee
->external_reference_min_index
=IEEE_REFERENCE_BASE
;
930 ieee
->external_reference_max_index
= 0;
931 memset((PTR
)ieee
->section_table
, 0, sizeof(ieee
->section_table
));
933 processor
= ieee
->mb
.processor
= read_id(abfd
);
934 if (strcmp(processor
,"LIBRARY") == 0) goto fail
;
935 ieee
->mb
.module_name
= read_id(abfd
);
936 if (abfd
->filename
== (char *)NULL
) {
937 abfd
->filename
= ieee
->mb
.module_name
;
939 /* Determine the architecture and machine type of the object file. */
940 bfd_scan_arch_mach(processor
, &abfd
->obj_arch
, &abfd
->obj_machine
);
942 if (this_byte(abfd
) != ieee_address_descriptor_enum
) {
947 if (parse_int(abfd
, &ieee
->ad
.number_of_bits_mau
) == false) {
950 if(parse_int(abfd
, &ieee
->ad
.number_of_maus_in_address
) == false) {
954 /* If there is a byte order info, take it */
955 if (this_byte(abfd
) == ieee_variable_L_enum
||
956 this_byte(abfd
) == ieee_variable_M_enum
)
960 for (part
= 0; part
< N_W_VARIABLES
; part
++) {
962 if (read_2bytes(abfd
) != ieee_assign_value_to_variable_enum
) {
965 if (this_byte_and_next(abfd
) != part
) {
969 ieee
->w
.offset
[part
] = parse_i(abfd
, &ok
);
975 abfd
->flags
= HAS_SYMS
;
977 /* By now we know that this is a real IEEE file, we're going to read
978 the whole thing into memory so that we can run up and down it
979 quickly. We can work out how big the file is from the trailer
982 ieee_data(abfd
)->first_byte
= ieee_malloc(abfd
, ieee
->w
.r
.me_record
984 bfd_seek(abfd
, 0, 0);
985 bfd_read(ieee_data(abfd
)->first_byte
, 1, ieee
->w
.r
.me_record
+50, abfd
);
987 ieee_slurp_sections(abfd
);
990 obstack_finish(&ieee
->ieee_obstack
);
991 return (bfd_target
*)NULL
;
996 DEFUN(ieee_print_symbol
,(ignore_abfd
, file
, symbol
, how
),
1000 bfd_print_symbol_enum_type how
)
1003 case bfd_print_symbol_name_enum
:
1004 fprintf(file
,"%s", symbol
->name
);
1006 case bfd_print_symbol_type_enum
:
1008 fprintf(file
,"%4x %2x",aout_symbol(symbol
)->desc
& 0xffff,
1009 aout_symbol(symbol
)->other
& 0xff);
1013 case bfd_print_symbol_all_enum
:
1015 CONST
char *section_name
= symbol
->section
== (asection
*)NULL
?
1016 "*abs" : symbol
->section
->name
;
1018 bfd_print_symbol_vandf((void *)file
,symbol
);
1020 fprintf(file
," %-5s %04x %02x %s",
1022 (unsigned) ieee_symbol(symbol
)->index
,
1024 aout_symbol(symbol)->desc & 0xffff,
1025 aout_symbol(symbol)->other & 0xff,*/
1034 /* Read in all the section data and relocation stuff too */
1036 DEFUN(ieee_slurp_section_data
,(abfd
),
1039 bfd_byte
*location_ptr
;
1040 ieee_data_type
*ieee
= ieee_data(abfd
);
1041 unsigned int section_number
;
1043 ieee_per_section_type
*current_map
;
1045 /* Seek to the start of the data area */
1046 if (ieee
->read_data
== true) return true;
1047 ieee
->read_data
= true;
1048 ieee_seek(abfd
, ieee
->w
.r
.data_part
);
1050 /* Allocate enough space for all the section contents */
1053 for (s
= abfd
->sections
; s
!= (asection
*)NULL
; s
= s
->next
) {
1054 ieee_per_section_type
*per
= (ieee_per_section_type
*) s
->used_by_bfd
;
1055 per
->data
= (bfd_byte
*) ieee_malloc(abfd
, s
->size
);
1057 per
->reloc_tail_ptr
=
1058 (ieee_reloc_type
**)&(s
->relocation
);
1064 switch (this_byte(abfd
))
1066 /* IF we see anything strange then quit */
1070 case ieee_set_current_section_enum
:
1072 section_number
= must_parse_int(abfd
);
1073 s
= ieee
->section_table
[section_number
];
1074 current_map
= (ieee_per_section_type
*) s
->used_by_bfd
;
1075 location_ptr
= current_map
->data
- s
->vma
;
1076 /* The document I have says that Microtec's compilers reset */
1077 /* this after a sec section, even though the standard says not */
1079 current_map
->pc
=s
->vma
;
1082 case ieee_load_constant_bytes_enum
:
1084 unsigned int number_of_maus
;
1087 number_of_maus
= must_parse_int(abfd
);
1089 for (i
= 0; i
< number_of_maus
; i
++) {
1090 location_ptr
[current_map
->pc
++]= this_byte(abfd
);
1096 case ieee_e2_first_byte_enum
:
1098 switch (this_byte(abfd
))
1100 case ieee_set_current_pc_enum
& 0xff:
1104 ieee_symbol_index_type symbol
;
1108 must_parse_int(abfd
); /* Thow away section #*/
1109 parse_expression(abfd
, &value
, &dsection
, &symbol
, &pcrel
, &extra
);
1110 current_map
->pc
= value
;
1111 BFD_ASSERT((unsigned)(value
- s
->vma
) <= s
->size
);
1115 case ieee_value_starting_address_enum
& 0xff:
1116 /* We've got to the end of the data now - */
1124 case ieee_load_with_relocation_enum
:
1126 boolean loop
= true;
1130 switch (this_byte(abfd
))
1132 case ieee_variable_R_enum
:
1134 case ieee_function_signed_open_b_enum
:
1135 case ieee_function_unsigned_open_b_enum
:
1136 case ieee_function_either_open_b_enum
:
1141 ieee_reloc_type
*r
=
1142 (ieee_reloc_type
*) ieee_malloc(abfd
,
1143 sizeof(ieee_reloc_type
));
1145 *(current_map
->reloc_tail_ptr
) = r
;
1146 current_map
->reloc_tail_ptr
= &r
->next
;
1147 r
->next
= (ieee_reloc_type
*)NULL
;
1149 parse_expression(abfd
,
1155 r
->relent
.address
= current_map
->pc
;
1157 switch (this_byte(abfd
)) {
1158 case ieee_function_signed_close_b_enum
:
1161 case ieee_function_unsigned_close_b_enum
:
1164 case ieee_function_either_close_b_enum
:
1170 /* Build a relocation entry for this type */
1171 if (this_byte(abfd
) == ieee_comma
) {
1174 /* Fetch number of bytes to pad */
1175 extra
= must_parse_int(abfd
);
1181 location_ptr
[current_map
->pc
++] = 0;
1182 location_ptr
[current_map
->pc
++] = 0;
1183 location_ptr
[current_map
->pc
++] = 0;
1184 location_ptr
[current_map
->pc
++] = 0;
1185 r
->relent
.howto
= &abs32_howto
;
1188 location_ptr
[current_map
->pc
++] = 0;
1189 location_ptr
[current_map
->pc
++] = 0;
1190 r
->relent
.howto
= &abs16_howto
;
1202 if (parse_int(abfd
, &this_size
) == true) {
1204 for (i
= 0; i
< this_size
; i
++) {
1205 location_ptr
[current_map
->pc
++] = this_byte(abfd
);
1223 DEFUN(ieee_new_section_hook
,(abfd
, newsect
),
1227 newsect
->used_by_bfd
= (PTR
)
1228 ieee_malloc(abfd
, sizeof(ieee_per_section_type
));
1229 ieee_per_section( newsect
)->data
= (bfd_byte
*)NULL
;
1230 ieee_per_section(newsect
)->section
= newsect
;
1236 DEFUN(ieee_get_reloc_upper_bound
,(abfd
, asect
),
1240 ieee_slurp_section_data(abfd
);
1241 return (asect
->reloc_count
+1) * sizeof(arelent
*);
1245 DEFUN(ieee_get_section_contents
,(abfd
, section
, location
, offset
, count
),
1252 ieee_per_section_type
*p
= (ieee_per_section_type
*) section
->used_by_bfd
;
1253 ieee_slurp_section_data(abfd
);
1254 (void) memcpy(location
, p
->data
+ offset
, count
);
1260 DEFUN(ieee_canonicalize_reloc
,(abfd
, section
, relptr
, symbols
),
1263 arelent
**relptr AND
1266 ieee_per_section_type
*p
= (ieee_per_section_type
*) section
->used_by_bfd
;
1267 ieee_reloc_type
*src
= (ieee_reloc_type
*)(section
->relocation
);
1268 ieee_data_type
*ieee
= ieee_data(abfd
);
1270 while (src
!= (ieee_reloc_type
*)NULL
) {
1271 /* Work out which symbol to attatch it this reloc to */
1272 switch (src
->symbol
.letter
) {
1274 src
->relent
.sym_ptr_ptr
=
1275 symbols
+ src
->symbol
.index
+ ieee
->external_reference_base_offset
;
1278 src
->relent
.sym_ptr_ptr
= (asymbol
**)NULL
;
1284 *relptr
++ = &src
->relent
;
1287 *relptr
= (arelent
*)NULL
;
1288 return section
->reloc_count
;
1292 DEFUN(ieee_set_arch_mach
,(abfd
, arch
, machine
),
1294 enum bfd_architecture arch AND
1295 unsigned long machine
)
1297 abfd
->obj_arch
= arch
;
1298 abfd
->obj_machine
= machine
;
1304 DEFUN(comp
,(ap
, bp
),
1308 arelent
*a
= *((arelent
**)ap
);
1309 arelent
*b
= *((arelent
**)bp
);
1310 return a
->address
- b
->address
;
1314 Write the section headers
1318 DEFUN(ieee_write_section_part
,(abfd
),
1321 ieee_data_type
*ieee
= ieee_data(abfd
);
1323 ieee
->w
.r
.section_part
= bfd_tell(abfd
);
1324 for (s
= abfd
->sections
; s
!= (asection
*)NULL
; s
=s
->next
) {
1325 ieee_write_byte(abfd
, ieee_section_type_enum
);
1326 ieee_write_byte(abfd
, s
->index
+ IEEE_SECTION_NUMBER_BASE
);
1328 switch (s
->flags
& (SEC_LOAD
| SEC_CODE
| SEC_DATA
| SEC_ROM
)) {
1329 case SEC_LOAD
| SEC_CODE
:
1330 /* Normal named section, code */
1331 ieee_write_byte(abfd
, ieee_variable_C_enum
);
1332 ieee_write_byte(abfd
, ieee_variable_P_enum
);
1334 case SEC_LOAD
| SEC_DATA
:
1335 /* Normal named section, data */
1336 ieee_write_byte(abfd
, ieee_variable_C_enum
);
1337 ieee_write_byte(abfd
, ieee_variable_D_enum
);
1339 case SEC_LOAD
| SEC_DATA
| SEC_ROM
:
1340 /* Normal named section, data rom */
1341 ieee_write_byte(abfd
, ieee_variable_C_enum
);
1342 ieee_write_byte(abfd
, ieee_variable_R_enum
);
1345 ieee_write_byte(abfd
, ieee_variable_C_enum
);
1349 ieee_write_id(abfd
, s
->name
);
1350 ieee_write_int(abfd
, 0); /* Parent */
1351 ieee_write_int(abfd
, 0); /* Brother */
1352 ieee_write_int(abfd
, 0); /* Context */
1355 ieee_write_byte(abfd
, ieee_section_alignment_enum
);
1356 ieee_write_byte(abfd
, s
->index
+ IEEE_SECTION_NUMBER_BASE
);
1357 ieee_write_int(abfd
, 1 << s
->alignment_power
);
1360 ieee_write_2bytes(abfd
, ieee_section_size_enum
);
1361 ieee_write_byte(abfd
, s
->index
+ IEEE_SECTION_NUMBER_BASE
);
1362 ieee_write_int(abfd
, s
->size
);
1365 ieee_write_2bytes(abfd
, ieee_region_base_address_enum
);
1366 ieee_write_byte(abfd
, s
->index
+ IEEE_SECTION_NUMBER_BASE
);
1367 ieee_write_int(abfd
, s
->vma
);
1374 /* write the data in an ieee way */
1376 DEFUN(ieee_write_data_part
,(abfd
),
1380 ieee_data_type
*ieee
= ieee_data(abfd
);
1381 ieee
->w
.r
.data_part
= bfd_tell(abfd
);
1382 for (s
= abfd
->sections
; s
!= (asection
*)NULL
; s
= s
->next
)
1384 bfd_byte header
[11];
1385 bfd_byte
*stream
= ieee_per_section(s
)->data
;
1386 arelent
**p
= s
->orelocation
;
1387 unsigned int relocs_to_go
= s
->reloc_count
;
1388 size_t current_byte_index
= 0;
1391 /* Sort the reloc records so we can insert them in the correct
1393 if (s
->reloc_count
!= 0) {
1394 qsort(s
->orelocation
,
1401 /* Output the section preheader */
1402 header
[0] =ieee_set_current_section_enum
;
1403 header
[1] = s
->index
+ IEEE_SECTION_NUMBER_BASE
;
1405 header
[2] = ieee_set_current_pc_enum
>> 8;
1406 header
[3]= ieee_set_current_pc_enum
& 0xff;
1407 header
[4] = s
->index
+ IEEE_SECTION_NUMBER_BASE
;
1408 ieee_write_int5(header
+5, s
->vma
);
1409 header
[10] = ieee_load_with_relocation_enum
;
1410 bfd_write(header
, 1, sizeof(header
), abfd
);
1412 /* Output the data stream as the longest sequence of bytes
1413 possible, allowing for the a reasonable packet size and
1414 relocation stuffs */
1416 if (stream
== (void *)NULL
) {
1417 /* Outputting a section without data, fill it up */
1418 stream
= ieee_malloc(abfd
, s
->size
);
1419 memset(stream
, 0, s
->size
);
1421 while (current_byte_index
< s
->size
) {
1423 unsigned int MAXRUN
= 32;
1425 run
= (*p
)->address
- current_byte_index
;
1430 if (run
> s
->size
- current_byte_index
) {
1431 run
= s
->size
- current_byte_index
;
1435 /* Output a stream of bytes */
1436 ieee_write_int(abfd
, run
);
1437 bfd_write(stream
+ current_byte_index
,
1441 current_byte_index
+= run
;
1443 /* Output any relocations here */
1444 if (relocs_to_go
&& (*p
) && (*p
)->address
== current_byte_index
) {
1445 while (relocs_to_go
&& (*p
) && (*p
)->address
== current_byte_index
) {
1448 ieee_write_byte(abfd
, ieee_function_either_open_b_enum
);
1449 if (r
->sym_ptr_ptr
!= (asymbol
**)NULL
) {
1450 ieee_write_expression(abfd
, r
->addend
,
1455 ieee_write_expression(abfd
, r
->addend
,
1459 ieee_write_byte(abfd
,
1460 ieee_function_either_close_b_enum
);
1464 /* FIXME !! Are all relocations 4 bytes ? */
1465 current_byte_index
+= 4;
1475 DEFUN(init_for_output
,(abfd
),
1479 for (s
= abfd
->sections
; s
!= (asection
*)NULL
; s
= s
->next
) {
1481 ieee_per_section(s
)->data
= (bfd_byte
*)(ieee_malloc(abfd
, s
->size
));
1486 /** exec and core file sections */
1488 /* set section contents is complicated with IEEE since the format is
1489 * not a byte image, but a record stream.
1492 DEFUN(ieee_set_section_contents
,(abfd
, section
, location
, offset
, count
),
1495 unsigned char *location AND
1499 if (ieee_per_section(section
)->data
== (bfd_byte
*)NULL
) {
1500 init_for_output(abfd
);
1502 (void) memcpy(ieee_per_section(section
)->data
+ offset
, location
, count
);
1507 write the external symbols of a file, IEEE considers two sorts of
1508 external symbols, public, and referenced. It uses to internal forms
1509 to index them as well. When we write them out we turn their symbol
1510 values into indexes from the right base.
1513 DEFUN(ieee_write_external_part
,(abfd
),
1517 ieee_data_type
*ieee
= ieee_data(abfd
);
1519 unsigned int reference_index
= IEEE_REFERENCE_BASE
;
1520 unsigned int public_index
= IEEE_PUBLIC_BASE
;
1521 ieee
->w
.r
.external_part
= bfd_tell(abfd
);
1522 if (abfd
->outsymbols
!= (asymbol
**)NULL
) {
1523 for (q
= abfd
->outsymbols
; *q
!= (asymbol
*)NULL
; q
++) {
1525 if (p
->flags
& BSF_UNDEFINED
) {
1526 /* This must be a symbol reference .. */
1527 ieee_write_byte(abfd
, ieee_external_reference_enum
);
1528 ieee_write_int(abfd
, reference_index
);
1529 ieee_write_id(abfd
, p
->name
);
1530 p
->value
= reference_index
;
1533 else if(p
->flags
& BSF_FORT_COMM
) {
1534 /* This is a weak reference */
1535 ieee_write_byte(abfd
, ieee_external_reference_enum
);
1536 ieee_write_int(abfd
, reference_index
);
1537 ieee_write_id(abfd
, p
->name
);
1538 ieee_write_byte(abfd
, ieee_weak_external_reference_enum
);
1539 ieee_write_int(abfd
, reference_index
);
1540 ieee_write_int(abfd
, p
->value
);
1541 ieee_write_int(abfd
, BFD_FORT_COMM_DEFAULT_VALUE
);
1542 p
->value
= reference_index
;
1545 else if(p
->flags
& BSF_GLOBAL
) {
1546 /* This must be a symbol definition */
1548 ieee_write_byte(abfd
, ieee_external_symbol_enum
);
1549 ieee_write_int(abfd
, public_index
);
1550 ieee_write_id(abfd
, p
->name
);
1552 /* Write out the value */
1553 ieee_write_2bytes(abfd
, ieee_value_record_enum
);
1554 ieee_write_int(abfd
, public_index
);
1555 if (p
->section
!= (asection
*)NULL
)
1557 ieee_write_expression(abfd
,
1558 p
->value
+ p
->section
->output_offset
,
1559 p
->section
->output_section
,
1564 ieee_write_expression(abfd
,
1569 p
->value
= public_index
;
1573 /* This can happen - when there are gaps in the symbols read */
1574 /* from an input ieee file */
1583 DEFUN(ieee_write_me_part
,(abfd
),
1586 ieee_data_type
*ieee
= ieee_data(abfd
);
1587 ieee
->w
.r
.me_record
= bfd_tell(abfd
);
1589 ieee_write_2bytes(abfd
, ieee_value_starting_address_enum
);
1590 ieee_write_int(abfd
, abfd
->start_address
);
1591 ieee_write_byte(abfd
, ieee_module_end_enum
);
1595 DEFUN(ieee_write_object_contents
,(abfd
),
1598 ieee_data_type
*ieee
= ieee_data(abfd
);
1601 /* Fast forward over the header area */
1602 bfd_seek(abfd
, 0, 0);
1603 ieee_write_byte(abfd
, ieee_module_beginning_enum
);
1605 ieee_write_id(abfd
, bfd_printable_arch_mach(abfd
->obj_arch
,
1606 abfd
->obj_machine
));
1607 ieee_write_id(abfd
, abfd
->filename
);
1608 ieee_write_byte(abfd
, ieee_address_descriptor_enum
);
1609 ieee_write_byte(abfd
, 8); /* Bits per MAU */
1610 ieee_write_byte(abfd
, 4); /* MAU's per address */
1612 /* Fast forward over the variable bits */
1613 old
= bfd_tell(abfd
);
1614 bfd_seek(abfd
, 8 * N_W_VARIABLES
, 1);
1617 First write the symbols, this changes their values into table
1618 indeces so we cant use it after this point
1620 ieee_write_external_part(abfd
);
1621 ieee_write_byte(abfd
, ieee_record_seperator_enum
);
1623 ieee_write_section_part(abfd
);
1624 ieee_write_byte(abfd
, ieee_record_seperator_enum
);
1626 Can only write the data once the symbols have been written since
1627 the data contains relocation information which points to the
1630 ieee_write_data_part(abfd
);
1631 ieee_write_byte(abfd
, ieee_record_seperator_enum
);
1634 At the end we put the end !
1636 ieee_write_me_part(abfd
);
1639 /* Generate the header */
1640 bfd_seek(abfd
, old
, false);
1642 for (i
= 0; i
< N_W_VARIABLES
; i
++) {
1643 ieee_write_2bytes(abfd
,ieee_assign_value_to_variable_enum
);
1644 ieee_write_byte(abfd
, i
);
1645 ieee_write_int5_out(abfd
, ieee
->w
.offset
[i
]);
1653 /* Native-level interface to symbols. */
1655 /* We read the symbols into a buffer, which is discarded when this
1656 function exits. We read the strings into a buffer large enough to
1657 hold them all plus all the cached symbol entries. */
1660 DEFUN(ieee_make_empty_symbol
,(abfd
),
1664 ieee_symbol_type
*new =
1665 (ieee_symbol_type
*)zalloc (sizeof (ieee_symbol_type
));
1666 new->symbol
.the_bfd
= abfd
;
1667 return &new->symbol
;
1672 DEFUN(ieee_reclaim_symbol_table
, (abfd
),
1678 if (!bfd_get_symcount (abfd
)) return;
1680 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
1681 if (section
->relocation
) {
1682 free ((void *)section
->relocation
);
1683 section
->relocation
= NULL
;
1684 section
->reloc_count
= 0;
1687 bfd_get_symcount (abfd
) = 0;
1688 free ((void *)obj_aout_symbols (abfd
));
1689 obj_aout_symbols (abfd
) = (aout_symbol_type
*)NULL
;
1696 /* Obsolete procedural interface; better to look at the cache directly */
1698 /* User should have checked the file flags; perhaps we should return
1699 BFD_NO_MORE_SYMBOLS if there are none? */
1702 DEFUN(ieee_get_symcount_upper_bound
,(abfd
),
1706 /* In case we're doing an output file or something...? */
1707 if (bfd_get_symcount (abfd
)) return bfd_get_symcount (abfd
);
1709 return (exec_hdr (abfd
)->a_syms
) / (sizeof (struct nlist
));
1715 DEFUN(ieee_get_first_symbol
,(ignore_abfd
),
1722 DEFUN(ieee_get_next_symbol
,(abfd
, oidx
),
1727 if (oidx
== BFD_NO_MORE_SYMBOLS
) return BFD_NO_MORE_SYMBOLS
;
1728 return ++oidx
>= bfd_get_symcount (abfd
) ? BFD_NO_MORE_SYMBOLS
:
1735 ieee_symbol_name (abfd
, idx
)
1740 return (obj_aout_symbols (abfd
) + idx
)->symbol
.name
;
1746 ieee_symbol_value (abfd
, idx
)
1751 return (obj_aout_symbols (abfd
) + idx
)->symbol
.value
;
1757 ieee_classify_symbol (abfd
, idx
)
1762 aout_symbol_type
*sym
= obj_aout_symbols (abfd
) + idx
;
1764 if ((sym
->symbol
.flags
& BSF_FORT_COMM
) != 0) return bfd_symclass_fcommon
;
1765 if ((sym
->symbol
.flags
& BSF_GLOBAL
) != 0) return bfd_symclass_global
;
1766 if ((sym
->symbol
.flags
& BSF_DEBUGGING
) != 0) return bfd_symclass_debugger
;
1767 if ((sym
->symbol
.flags
& BSF_UNDEFINED
) != 0) return bfd_symclass_undefined
;
1769 return bfd_symclass_unknown
;
1773 ieee_symbol_hasclass (abfd
, idx
, class)
1779 aout_symbol_type
*sym
= obj_aout_symbols (abfd
) + idx
;
1781 case bfd_symclass_fcommon
:
1782 return (sym
->symbol
.flags
& BSF_FORT_COMM
) ? true :false;
1783 case bfd_symclass_global
:
1784 return (sym
->symbol
.flags
& BSF_GLOBAL
) ? true:false;
1785 case bfd_symclass_debugger
:
1786 return (sym
->symbol
.flags
& BSF_DEBUGGING
) ? true:false;;
1787 case bfd_symclass_undefined
:
1788 return (sym
->symbol
.flags
& BSF_UNDEFINED
) ? true:false;;
1789 default: return false;
1797 ieee_reclaim_reloc (ignore_abfd
, section
)
1802 if (section
->relocation
) {
1803 free (section
->relocation
);
1804 section
->relocation
= NULL
;
1805 section
->reloc_count
= 0;
1811 ieee_close_and_cleanup (abfd
)
1814 if (bfd_read_p (abfd
) == false)
1815 switch (abfd
->format
) {
1817 if (!_bfd_write_archive_contents (abfd
)) {
1822 if (!ieee_write_object_contents (abfd
)) {
1827 bfd_error
= invalid_operation
;
1832 if (ieee_data(abfd
) != (ieee_data_type
*)NULL
) {
1833 /* FIXME MORE LEAKS */
1841 ieee_openr_next_archived_file(arch
, prev
)
1845 ieee_ar_data_type
*ar
= ieee_ar_data(arch
);
1846 /* take the next one from the arch state, or reset */
1847 if (prev
== (bfd
*)NULL
) {
1848 /* Reset the index - the first two entries are bogus*/
1849 ar
->element_index
= 2;
1852 ieee_ar_obstack_type
*p
= ar
->elements
+ ar
->element_index
;
1853 ar
->element_index
++;
1854 if (ar
->element_index
<= ar
->element_count
) {
1855 if (p
->file_offset
!= (file_ptr
)0) {
1856 if (p
->abfd
== (bfd
*)NULL
) {
1857 p
->abfd
= _bfd_create_empty_archive_element_shell(arch
);
1858 p
->abfd
->origin
= p
->file_offset
;
1871 ieee_find_nearest_line(abfd
,
1882 char **filename_ptr
;
1883 char **functionname_ptr
;
1884 unsigned int *line_ptr
;
1892 ieee_generic_stat_arch_elt(abfd
, buf
)
1896 ieee_ar_data_type
*ar
= ieee_ar_data(abfd
);
1897 if (ar
== (ieee_ar_data_type
*)NULL
) {
1898 bfd_error
= invalid_operation
;
1903 buf
->st_mode
= 0666;
1908 DEFUN(ieee_sizeof_headers
,(abfd
),
1914 #define ieee_core_file_failing_command bfd_false
1915 #define ieee_core_file_failing_signal bfd_false
1916 #define ieee_core_file_matches_executable_p bfd_false
1917 #define ieee_slurp_armap bfd_true
1918 #define ieee_slurp_extended_name_table bfd_true
1919 #define ieee_truncate_arname bfd_false
1920 #define ieee_write_armap bfd_false
1921 #define ieee_get_lineno bfd_false
1925 bfd_target ieee_vec
=
1928 bfd_target_ieee_flavour_enum
,
1929 true, /* target byte order */
1930 true, /* target headers byte order */
1931 (HAS_RELOC
| EXEC_P
| /* object flags */
1932 HAS_LINENO
| HAS_DEBUG
|
1933 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
| D_PAGED
),
1934 (SEC_CODE
|SEC_DATA
|SEC_ROM
|SEC_HAS_CONTENTS
1935 |SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
1936 ' ', /* ar_pad_char */
1937 16, /* ar_max_namelen */
1939 _do_getblong
, _do_putblong
, _do_getbshort
, _do_putbshort
, /* data */
1940 _do_getblong
, _do_putblong
, _do_getbshort
, _do_putbshort
, /* hdrs */
1943 ieee_object_p
, /* bfd_check_format */
1950 _bfd_generic_mkarchive
,