1 /* bfd back-end for ieee-695 objects.
2 Copyright (C) 1990-1991 Free Software Foundation, Inc.
3 Written by Steve Chamberlain of Cygnus Support.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* IEEE 695 format is a stream of records, which we parse using a simple one-
22 token (which is one byte in this lexicon) lookahead recursive decent
31 /* Functions for writing to ieee files in the strange way that the
35 DEFUN(ieee_write_byte
,(abfd
, byte
),
39 bfd_write((PTR
)&byte
, 1, 1, abfd
);
44 DEFUN(ieee_write_twobyte
,(abfd
, twobyte
),
49 b
[1] = twobyte
& 0xff;
51 bfd_write((PTR
)&b
[0], 1, 2, abfd
);
57 DEFUN(ieee_write_2bytes
,(abfd
, bytes
),
62 buffer
[0] = bytes
>> 8;
63 buffer
[1] = bytes
& 0xff;
65 bfd_write((PTR
)buffer
, 1, 2, abfd
);
69 DEFUN(ieee_write_int
,(abfd
, value
),
73 if (((unsigned)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
, (int)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((PTR
)id
, 1, length
, abfd
);
128 /***************************************************************************
129 Functions for reading from ieee files in the strange way that the
134 #define this_byte(ieee) *((ieee)->input_p)
135 #define next_byte(ieee) ((ieee)->input_p++)
136 #define this_byte_and_next(ieee) (*((ieee)->input_p++))
139 static unsigned short
140 DEFUN(read_2bytes
,(ieee
),
141 common_header_type
*ieee
)
143 unsigned char c1
= this_byte_and_next(ieee
);
144 unsigned char c2
= this_byte_and_next(ieee
);
145 return (c1
<<8 ) | c2
;
150 DEFUN(bfd_get_string
,(ieee
, string
, length
),
151 common_header_type
*ieee AND
156 for (i
= 0; i
< length
; i
++) {
157 string
[i
] = this_byte_and_next(ieee
);
162 DEFUN(read_id
,(ieee
),
163 common_header_type
*ieee
)
167 length
= this_byte_and_next(ieee
);
168 if (length
>= 0x00 && length
<= 0x7f) {
169 /* Simple string of length 0 to 127 */
171 else if (length
== 0xde) {
172 /* Length is next byte, allowing 0..255 */
173 length
= this_byte_and_next(ieee
);
175 else if (length
== 0xdf) {
176 /* Length is next two bytes, allowing 0..65535 */
177 length
= this_byte_and_next(ieee
) ;
178 length
= (length
* 256) + this_byte_and_next(ieee
);
180 /* Buy memory and read string */
181 string
= bfd_alloc(ieee
->abfd
, length
+1);
182 bfd_get_string(ieee
, string
, length
);
188 DEFUN(ieee_write_expression
,(abfd
, value
, section
, symbol
, pcrel
, index
),
191 asection
*section AND
196 unsigned int plus_count
= 0;
198 ieee_write_int(abfd
, value
);
200 if (section
!= (asection
*)NULL
) {
202 ieee_write_byte(abfd
, ieee_variable_R_enum
);
203 ieee_write_byte(abfd
, section
->index
+IEEE_SECTION_NUMBER_BASE
);
208 if (symbol
!= (asymbol
*)NULL
) {
210 if ((symbol
->flags
& BSF_UNDEFINED
) ||
211 (symbol
->flags
& BSF_FORT_COMM
)) {
212 ieee_write_byte(abfd
, ieee_variable_X_enum
);
213 ieee_write_int(abfd
, symbol
->value
);
215 else if (symbol
->flags
& BSF_GLOBAL
) {
216 ieee_write_byte(abfd
, ieee_variable_I_enum
);
217 ieee_write_int(abfd
, symbol
->value
);
219 else if (symbol
->flags
& BSF_LOCAL
) {
220 /* This is a reference to a defined local symbol,
221 We can easily do a local as a section+offset */
222 if (symbol
->section
!= (asection
*)NULL
) {
223 /* If this symbol is not absolute, add the base of it */
224 ieee_write_byte(abfd
, ieee_variable_R_enum
); /* or L */
225 ieee_write_byte(abfd
, symbol
->section
->index
+
226 IEEE_SECTION_NUMBER_BASE
);
230 ieee_write_int(abfd
, symbol
->value
);
239 /* subtract the pc from here by asking for PC of this section*/
240 ieee_write_byte(abfd
, ieee_variable_P_enum
);
241 ieee_write_byte(abfd
, index
+IEEE_SECTION_NUMBER_BASE
);
242 ieee_write_byte(abfd
, ieee_function_minus_enum
);
246 while (plus_count
> 0) {
247 ieee_write_byte(abfd
, ieee_function_plus_enum
);
253 ieee_write_byte(abfd
,0);
266 /*****************************************************************************/
269 writes any integer into the buffer supplied and always takes 5 bytes
272 DEFUN(ieee_write_int5
,(buffer
, value
),
276 buffer
[0] = (bfd_byte
)ieee_number_repeat_4_enum
;
277 buffer
[1] = (value
>> 24 ) & 0xff;
278 buffer
[2] = (value
>> 16 ) & 0xff;
279 buffer
[3] = (value
>> 8 ) & 0xff;
280 buffer
[4] = (value
>> 0 ) & 0xff;
283 DEFUN(ieee_write_int5_out
, (abfd
, value
),
288 ieee_write_int5(b
, value
);
289 bfd_write((PTR
)b
,1,5,abfd
);
294 DEFUN(parse_int
,(ieee
, value_ptr
),
295 common_header_type
*ieee AND
298 int value
= this_byte(ieee
);
300 if (value
>= 0 && value
<= 127) {
305 else if (value
>= 0x80 && value
<= 0x88) {
306 unsigned int count
= value
& 0xf;
310 result
=(result
<< 8) | this_byte_and_next(ieee
);
319 DEFUN(parse_i
,(ieee
, ok
),
320 common_header_type
*ieee AND
324 *ok
= parse_int(ieee
, &x
);
329 DEFUN(must_parse_int
,(ieee
),
330 common_header_type
*ieee
)
333 BFD_ASSERT(parse_int(ieee
, &result
) == true);
341 ieee_symbol_index_type symbol
;
346 reloc_howto_type abs32_howto
347 = HOWTO(1,0,2,32,false,0,false,true,0,"abs32",true,0xffffffff, 0xffffffff,false);
349 reloc_howto_type abs16_howto
350 = HOWTO(1,0,1,16,false,0,false,true,0,"abs16",true,0x0000ffff, 0x0000ffff,false);
353 reloc_howto_type abs8_howto
354 = HOWTO(1,0,0,8,false,0,false,true,0,"abs8",true,0x000000ff, 0x000000ff,false);
357 reloc_howto_type rel32_howto
358 = HOWTO(1,0,2,32,true,0,false,true,0,"rel32",true,0xffffffff, 0xffffffff,true);
360 reloc_howto_type rel16_howto
361 = HOWTO(1,0,1,16,true,0,false,true,0,"rel16",true,0x0000ffff, 0x0000ffff,true);
364 reloc_howto_type rel8_howto
365 = HOWTO(1,0,0,8,true,0,false,true,0,"rel8",true,0x000000ff, 0x000000ff,true);
368 static ieee_symbol_index_type NOSYMBOL
= { 0, 0};
372 DEFUN(parse_expression
,(ieee
, value
, section
, symbol
, pcrel
, extra
),
373 ieee_data_type
*ieee AND
375 asection
**section AND
376 ieee_symbol_index_type
*symbol AND
388 ieee_value_type stack
[10];
390 /* The stack pointer always points to the next unused location */
391 #define PUSH(x,y,z) TOS.symbol=x;TOS.section=y;TOS.value=z;INC;
392 #define POP(x,y,z) DEC;x=TOS.symbol;y=TOS.section;z=TOS.value;
393 ieee_value_type
*sp
= stack
;
396 switch (this_byte(&(ieee
->h
)))
398 case ieee_variable_P_enum
:
399 /* P variable, current program counter for section n */
402 next_byte(&(ieee
->h
));
404 section_n
= must_parse_int(&(ieee
->h
));
406 TOS
.value
= ieee
->section_table
[section_n
]->vma
+
407 ieee_per_section(ieee
->section_table
[section_n
])->pc
);
410 case ieee_variable_L_enum
:
411 /* L variable address of section N */
412 next_byte(&(ieee
->h
));
413 PUSH(NOSYMBOL
,ieee
->section_table
[must_parse_int(&(ieee
->h
))],0);
415 case ieee_variable_R_enum
:
416 /* R variable, logical address of section module */
417 /* FIXME, this should be different to L */
418 next_byte(&(ieee
->h
));
419 PUSH(NOSYMBOL
,ieee
->section_table
[must_parse_int(&(ieee
->h
))],0);
421 case ieee_variable_S_enum
:
422 /* S variable, size in MAUS of section module */
423 next_byte(&(ieee
->h
));
426 ieee
->section_table
[must_parse_int(&(ieee
->h
))]->size
);
428 case ieee_variable_I_enum
:
429 case ieee_variable_X_enum
:
430 /* Push the address of external variable n */
432 ieee_symbol_index_type sy
;
433 next_byte(&(ieee
->h
));
434 sy
.index
= (int)(must_parse_int(&(ieee
->h
))) ;
440 case ieee_function_minus_enum
:
442 bfd_vma value1
, value2
;
443 asection
*section1
, *section_dummy
;
444 ieee_symbol_index_type sy
;
445 next_byte(&(ieee
->h
));
447 POP(sy
, section1
, value1
);
448 POP(sy
, section_dummy
, value2
);
449 PUSH(sy
, section1
? section1
: section_dummy
, value1
-value2
);
452 case ieee_function_plus_enum
:
454 bfd_vma value1
, value2
;
457 ieee_symbol_index_type sy1
;
458 ieee_symbol_index_type sy2
;
459 next_byte(&(ieee
->h
));
461 POP(sy1
, section1
, value1
);
462 POP(sy2
, section2
, value2
);
463 PUSH(sy1
.letter
? sy1
: sy2
, section1
? section1
: section2
, value1
+value2
);
469 BFD_ASSERT(this_byte(&(ieee
->h
)) < (int)ieee_variable_A_enum
470 || this_byte(&(ieee
->h
)) > (int)ieee_variable_Z_enum
);
471 if (parse_int(&(ieee
->h
), &va
))
473 PUSH(NOSYMBOL
,0, va
);
477 Thats all that we can understand. As far as I can see
478 there is a bug in the Microtec IEEE output which I'm
479 using to scan, whereby the comma operator is ommited
480 sometimes in an expression, giving expressions with too
481 many terms. We can tell if that's the case by ensuring
482 that sp == stack here. If not, then we've pushed
483 something too far, so we keep adding
486 while (sp
!= stack
+1) {
488 ieee_symbol_index_type sy1
;
489 POP(sy1
, section1
, *extra
);
492 POP(*symbol
, *section
, *value
);
503 #define ieee_seek(abfd, offset) \
504 ieee_data(abfd)->h.input_p = ieee_data(abfd)->h.first_byte + offset
506 #define ieee_pos(abfd) ieee_data(abfd)->h.input_p -ieee_data(abfd)->h.first_byte
508 static unsigned int last_index
;
510 static ieee_symbol_type
*
511 DEFUN(get_symbol
,(abfd
,
519 ieee_data_type
*ieee AND
520 ieee_symbol_type
*last_symbol AND
521 unsigned int *symbol_count AND
522 ieee_symbol_type
*** pptr AND
523 unsigned int *max_index
526 /* Need a new symbol */
527 unsigned int new_index
= must_parse_int(&(ieee
->h
));
528 if (new_index
!= last_index
) {
529 ieee_symbol_type
* new_symbol
= (ieee_symbol_type
*)bfd_alloc(ieee
->h
.abfd
,
530 sizeof(ieee_symbol_type
));
532 new_symbol
->index
= new_index
;
533 last_index
= new_index
;
536 *pptr
= &new_symbol
->next
;
537 if (new_index
> *max_index
) {
538 *max_index
= new_index
;
545 DEFUN(ieee_slurp_external_symbols
,(abfd
),
548 ieee_data_type
*ieee
= ieee_data(abfd
);
549 file_ptr offset
= ieee
->w
.r
.external_part
;
552 ieee_symbol_type
**prev_symbols_ptr
= &ieee
->external_symbols
;
553 ieee_symbol_type
**prev_reference_ptr
= &ieee
->external_reference
;
554 ieee_symbol_type
*symbol
= (ieee_symbol_type
*)NULL
;
555 unsigned int symbol_count
= 0;
557 last_index
= 0xffffff;
558 ieee
->symbol_table_full
= true;
560 ieee_seek(abfd
, offset
);
563 switch (this_byte(&(ieee
->h
))) {
565 next_byte(&(ieee
->h
));
566 symbol
= get_symbol(abfd
, ieee
, symbol
, &symbol_count
,
568 &ieee
->external_symbol_max_index
);
570 symbol
->symbol
.the_bfd
= abfd
;
571 symbol
->symbol
.name
= read_id(&(ieee
->h
));
572 symbol
->symbol
.udata
= (PTR
)NULL
;
573 symbol
->symbol
.flags
= BSF_NO_FLAGS
;
577 case ieee_external_symbol_enum
:
578 next_byte(&(ieee
->h
));
580 symbol
= get_symbol(abfd
, ieee
, symbol
, &symbol_count
,
582 &ieee
->external_symbol_max_index
);
585 BFD_ASSERT (symbol
->index
>= ieee
->external_symbol_min_index
);
587 symbol
->symbol
.the_bfd
= abfd
;
588 symbol
->symbol
.name
= read_id(&(ieee
->h
));
589 symbol
->symbol
.udata
= (PTR
)NULL
;
590 symbol
->symbol
.flags
= BSF_NO_FLAGS
;
592 case ieee_attribute_record_enum
>> 8:
594 unsigned int symbol_name_index
;
595 unsigned int symbol_type_index
;
596 unsigned int symbol_attribute_def
;
598 next_byte(&(ieee
->h
)); /* Skip prefix */
599 next_byte(&(ieee
->h
));
600 symbol_name_index
= must_parse_int(&(ieee
->h
));
601 symbol_type_index
= must_parse_int(&(ieee
->h
));
602 symbol_attribute_def
= must_parse_int(&(ieee
->h
));
603 switch (symbol_attribute_def
) {
605 /* Module misc; followed by two fields which describe the
606 current module block. The first fired is the type id
607 number, the second is the number of asn records
608 associated with the directive */
609 parse_int(&(ieee
->h
),&value
);
610 parse_int(&(ieee
->h
),&value
);
614 parse_int(&(ieee
->h
),&value
);
619 case ieee_value_record_enum
>> 8:
621 unsigned int symbol_name_index
;
622 ieee_symbol_index_type symbol_ignore
;
623 boolean pcrel_ignore
;
625 next_byte(&(ieee
->h
));
626 next_byte(&(ieee
->h
));
628 symbol_name_index
= must_parse_int(&(ieee
->h
));
629 parse_expression(ieee
,
630 &symbol
->symbol
.value
,
631 &symbol
->symbol
.section
,
635 if (symbol
->symbol
.section
!= (asection
*)NULL
) {
636 symbol
->symbol
.flags
= BSF_GLOBAL
| BSF_EXPORT
;
639 symbol
->symbol
.flags
= BSF_GLOBAL
| BSF_EXPORT
| BSF_ABSOLUTE
;
643 case ieee_weak_external_reference_enum
:
646 next_byte(&(ieee
->h
));
647 /* Throw away the external reference index */
648 (void)must_parse_int(&(ieee
->h
));
649 /* Fetch the default size if not resolved */
650 size
= must_parse_int(&(ieee
->h
));
651 /* Fetch the defautlt value if available */
652 if ( parse_int(&(ieee
->h
), &value
) == false) {
655 /* This turns into a common */
656 symbol
->symbol
.flags
= BSF_FORT_COMM
;
657 symbol
->symbol
.value
= size
;
661 case ieee_external_reference_enum
:
662 next_byte(&(ieee
->h
));
664 symbol
= get_symbol(abfd
, ieee
, symbol
, &symbol_count
,
666 &ieee
->external_reference_max_index
);
669 symbol
->symbol
.the_bfd
= abfd
;
670 symbol
->symbol
.name
= read_id(&(ieee
->h
));
671 symbol
->symbol
.udata
= (PTR
)NULL
;
672 symbol
->symbol
.section
= (asection
*)NULL
;
673 symbol
->symbol
.value
= (bfd_vma
)0;
674 symbol
->symbol
.flags
= BSF_UNDEFINED
;
676 BFD_ASSERT (symbol
->index
>= ieee
->external_reference_min_index
);
684 if (ieee
->external_symbol_max_index
!= 0) {
685 ieee
->external_symbol_count
=
686 ieee
->external_symbol_max_index
-
687 ieee
->external_symbol_min_index
+ 1 ;
690 ieee
->external_symbol_count
= 0;
694 if(ieee
->external_reference_max_index
!= 0) {
695 ieee
->external_reference_count
=
696 ieee
->external_reference_max_index
-
697 ieee
->external_reference_min_index
+ 1;
700 ieee
->external_reference_count
= 0;
704 ieee
->external_reference_count
+ ieee
->external_symbol_count
;
706 if (symbol_count
!= abfd
->symcount
) {
707 /* There are gaps in the table -- */
708 ieee
->symbol_table_full
= false;
712 *prev_symbols_ptr
= (ieee_symbol_type
*)NULL
;
713 *prev_reference_ptr
= (ieee_symbol_type
*)NULL
;
717 DEFUN(ieee_slurp_symbol_table
,(abfd
),
720 if (ieee_data(abfd
)->read_symbols
== false) {
721 ieee_slurp_external_symbols(abfd
);
722 ieee_data(abfd
)->read_symbols
= true;
727 DEFUN(ieee_get_symtab_upper_bound
,(abfd
),
730 ieee_slurp_symbol_table (abfd
);
732 return (abfd
->symcount
!= 0) ?
733 (abfd
->symcount
+1) * (sizeof (ieee_symbol_type
*)) : 0;
737 Move from our internal lists to the canon table, and insert in
741 extern bfd_target ieee_vec
;
743 DEFUN(ieee_get_symtab
,(abfd
, location
),
747 ieee_symbol_type
*symp
;
748 static bfd dummy_bfd
;
749 static asymbol empty_symbol
=
750 { &dummy_bfd
," ieee empty",(symvalue
)0,BSF_DEBUGGING
| BSF_ABSOLUTE
};
752 if (abfd
->symcount
) {
757 ieee_data_type
*ieee
= ieee_data(abfd
);
758 dummy_bfd
.xvec
= &ieee_vec
;
759 ieee_slurp_symbol_table(abfd
);
761 if (ieee
->symbol_table_full
== false) {
762 /* Arrgh - there are gaps in the table, run through and fill them */
763 /* up with pointers to a null place */
765 for (i
= 0; i
< abfd
->symcount
; i
++) {
766 location
[i
] = &empty_symbol
;
771 ieee
->external_symbol_base_offset
= - ieee
->external_symbol_min_index
;
772 for (symp
= ieee_data(abfd
)->external_symbols
;
773 symp
!= (ieee_symbol_type
*)NULL
;
775 /* Place into table at correct index locations */
776 location
[symp
->index
+ ieee
->external_symbol_base_offset
] = &symp
->symbol
;
780 /* The external refs are indexed in a bit */
781 ieee
->external_reference_base_offset
=
782 - ieee
->external_reference_min_index
+ieee
->external_symbol_count
;
784 for (symp
= ieee_data(abfd
)->external_reference
;
785 symp
!= (ieee_symbol_type
*)NULL
;
787 location
[symp
->index
+ ieee
->external_reference_base_offset
] =
794 location
[abfd
->symcount
] = (asymbol
*)NULL
;
796 return abfd
->symcount
;
799 DEFUN(get_section_entry
,(abfd
, ieee
,index
),
801 ieee_data_type
*ieee AND
804 if (ieee
->section_table
[index
] == (asection
*)NULL
) {
805 asection
*section
= bfd_make_section(abfd
, " tempname");
806 ieee
->section_table
[index
] = section
;
807 section
->flags
= SEC_NO_FLAGS
;
808 section
->target_index
= index
;
809 ieee
->section_table
[index
] = section
;
811 return ieee
->section_table
[index
];
815 DEFUN(ieee_slurp_sections
,(abfd
),
818 ieee_data_type
*ieee
= ieee_data(abfd
);
819 file_ptr offset
= ieee
->w
.r
.section_part
;
821 asection
*section
= (asection
*)NULL
;
824 bfd_byte section_type
[3];
825 ieee_seek(abfd
, offset
);
827 switch (this_byte(&(ieee
->h
))) {
828 case ieee_section_type_enum
:
830 unsigned int section_index
;
831 next_byte(&(ieee
->h
));
832 section_index
= must_parse_int(&(ieee
->h
));
833 /* Fixme to be nice about a silly number of sections */
834 BFD_ASSERT(section_index
< NSECTIONS
);
836 section
=get_section_entry(abfd
, ieee
, section_index
);
838 section_type
[0] = this_byte_and_next(&(ieee
->h
));
839 switch (section_type
[0]) {
841 /* Normal attributes for absolute sections */
842 section_type
[1] = this_byte(&(ieee
->h
));
843 section
->flags
= SEC_LOAD
| SEC_ALLOC
| SEC_HAS_CONTENTS
;
844 switch(section_type
[1]) {
846 next_byte(&(ieee
->h
));
847 section_type
[2] = this_byte(&(ieee
->h
));
848 switch (section_type
[2])
852 next_byte(&(ieee
->h
));
853 section
->flags
|= SEC_LOAD
| SEC_CODE
;
856 next_byte(&(ieee
->h
));
857 section
->flags
|= SEC_LOAD
| SEC_DATA
;
861 next_byte(&(ieee
->h
));
862 /* Normal rom data */
863 section
->flags
|= SEC_LOAD
| SEC_ROM
| SEC_DATA
;
871 section_type
[1] = this_byte(&(ieee
->h
));
872 section
->flags
= SEC_LOAD
| SEC_ALLOC
| SEC_HAS_CONTENTS
;
873 switch (section_type
[1]) {
876 next_byte(&(ieee
->h
));
877 section
->flags
|= SEC_LOAD
| SEC_CODE
;
880 next_byte(&(ieee
->h
));
881 section
->flags
|= SEC_LOAD
| SEC_DATA
;
885 next_byte(&(ieee
->h
));
886 /* Normal rom data */
887 section
->flags
|= SEC_LOAD
| SEC_ROM
| SEC_DATA
;
893 section
->name
= read_id(&(ieee
->h
));
894 { bfd_vma parent
, brother
, context
;
895 parse_int(&(ieee
->h
), &parent
);
896 parse_int(&(ieee
->h
), &brother
);
897 parse_int(&(ieee
->h
), &context
);
903 case ieee_section_alignment_enum
:
905 unsigned int section_index
;
908 next_byte(&(ieee
->h
));
909 section_index
= must_parse_int(&ieee
->h
);
910 section
= get_section_entry(abfd
, ieee
, section_index
);
911 if (section_index
> ieee
->section_count
) {
912 ieee
->section_count
= section_index
;
914 section
->alignment_power
=
915 bfd_log2(must_parse_int(&ieee
->h
));
916 (void)parse_int(&(ieee
->h
), & value
);
919 case ieee_e2_first_byte_enum
:
921 ieee_record_enum_type t
= (ieee_record_enum_type
)(read_2bytes(&(ieee
->h
)));
924 case ieee_section_size_enum
:
925 section
= ieee
->section_table
[must_parse_int(&(ieee
->h
))];
926 section
->size
= must_parse_int(&(ieee
->h
));
928 case ieee_physical_region_size_enum
:
929 section
= ieee
->section_table
[must_parse_int(&(ieee
->h
))];
930 section
->size
= must_parse_int(&(ieee
->h
));
932 case ieee_region_base_address_enum
:
933 section
= ieee
->section_table
[must_parse_int(&(ieee
->h
))];
934 section
->vma
= must_parse_int(&(ieee
->h
));
936 case ieee_mau_size_enum
:
937 must_parse_int(&(ieee
->h
));
938 must_parse_int(&(ieee
->h
));
940 case ieee_m_value_enum
:
941 must_parse_int(&(ieee
->h
));
942 must_parse_int(&(ieee
->h
));
944 case ieee_section_base_address_enum
:
945 section
= ieee
->section_table
[must_parse_int(&(ieee
->h
))];
946 section
->vma
= must_parse_int(&(ieee
->h
));
948 case ieee_section_offset_enum
:
949 (void) must_parse_int(&(ieee
->h
));
950 (void) must_parse_int(&(ieee
->h
));
964 /***********************************************************************
968 DEFUN(ieee_archive_p
,(abfd
),
975 uint8e_type buffer
[512];
977 int buffer_offset
= 0;
978 ieee_ar_data_type
*save
= ieee_ar_data(abfd
);
979 ieee_ar_data_type
*ieee
;
980 set_tdata(abfd
, bfd_alloc(abfd
, sizeof(ieee_ar_data_type
)));
981 ieee
= ieee_ar_data(abfd
);
984 bfd_read((PTR
)buffer
, 1, sizeof(buffer
), abfd
);
986 ieee
->h
.first_byte
= buffer
;
987 ieee
->h
.input_p
= buffer
;
991 if (this_byte(&(ieee
->h
)) != Module_Beginning
) return (bfd_target
*)NULL
;
993 next_byte(&(ieee
->h
));
994 library
= read_id(&(ieee
->h
));
995 if (strcmp(library
, "LIBRARY") != 0) {
996 bfd_release(abfd
, ieee
);
997 set_tdata (abfd
, save
);
998 return (bfd_target
*)NULL
;
1000 /* Throw away the filename */
1001 free( read_id(&(ieee
->h
)));
1002 /* This must be an IEEE archive, so we'll buy some space to do
1004 ieee
->element_count
= 0;
1005 ieee
->element_index
= 0;
1007 next_byte(&(ieee
->h
)); /* Drop the ad part */
1008 must_parse_int(&(ieee
->h
)); /* And the two dummy numbers */
1009 must_parse_int(&(ieee
->h
));
1012 /* Read the index of the BB table */
1014 ieee_ar_obstack_type t
;
1015 int rec
=read_2bytes(&(ieee
->h
));
1016 if (rec
==(int)ieee_assign_value_to_variable_enum
) {
1017 int record_number
= must_parse_int(&(ieee
->h
));
1018 t
.file_offset
= must_parse_int(&(ieee
->h
));
1019 t
.abfd
= (bfd
*)NULL
;
1020 ieee
->element_count
++;
1021 bfd_alloc_grow(abfd
, (PTR
)&t
, sizeof(t
));
1023 /* Make sure that we don't go over the end of the buffer */
1025 if (ieee_pos(abfd
) > sizeof(buffer
)/2) {
1026 /* Past half way, reseek and reprime */
1027 buffer_offset
+= ieee_pos(abfd
);
1028 bfd_seek(abfd
, buffer_offset
, SEEK_SET
);
1029 bfd_read((PTR
)buffer
, 1, sizeof(buffer
), abfd
);
1030 ieee
->h
.first_byte
= buffer
;
1031 ieee
->h
.input_p
= buffer
;
1037 ieee
->elements
= (ieee_ar_obstack_type
*)bfd_alloc_finish(abfd
);
1039 /* Now scan the area again, and replace BB offsets with file */
1043 for (i
= 2; i
< ieee
->element_count
; i
++) {
1044 bfd_seek(abfd
, ieee
->elements
[i
].file_offset
, SEEK_SET
);
1045 bfd_read((PTR
)buffer
, 1, sizeof(buffer
), abfd
);
1046 ieee
->h
.first_byte
= buffer
;
1047 ieee
->h
.input_p
= buffer
;
1049 next_byte(&(ieee
->h
)); /* Drop F8 */
1050 next_byte(&(ieee
->h
)); /* Drop 14 */
1051 must_parse_int(&(ieee
->h
)); /* Drop size of block */
1052 if (must_parse_int(&(ieee
->h
)) != 0) {
1053 /* This object has been deleted */
1054 ieee
->elements
[i
].file_offset
= 0;
1057 ieee
->elements
[i
].file_offset
= must_parse_int(&(ieee
->h
));
1066 DEFUN(ieee_mkobject
,(abfd
),
1069 set_tdata (abfd
, bfd_zalloc(abfd
,sizeof(ieee_data_type
)));
1076 DEFUN(ieee_object_p
,(abfd
),
1081 ieee_data_type
*ieee
;
1082 uint8e_type buffer
[300];
1083 ieee_data_type
*save
= ieee_data(abfd
);
1084 set_tdata (abfd
, 0);
1085 ieee_mkobject(abfd
);
1086 ieee
= ieee_data(abfd
);
1088 /* Read the first few bytes in to see if it makes sense */
1089 bfd_read((PTR
)buffer
, 1, sizeof(buffer
), abfd
);
1091 ieee
->h
.input_p
= buffer
;
1092 if (this_byte_and_next(&(ieee
->h
)) != Module_Beginning
) goto fail
;
1094 ieee
->read_symbols
= false;
1095 ieee
->read_data
= false;
1096 ieee
->section_count
= 0;
1097 ieee
->external_symbol_max_index
= 0;
1098 ieee
->external_symbol_min_index
= IEEE_PUBLIC_BASE
;
1099 ieee
->external_reference_min_index
=IEEE_REFERENCE_BASE
;
1100 ieee
->external_reference_max_index
= 0;
1101 ieee
->h
.abfd
= abfd
;
1102 memset((PTR
)ieee
->section_table
, 0, sizeof(ieee
->section_table
));
1104 processor
= ieee
->mb
.processor
= read_id(&(ieee
->h
));
1105 if (strcmp(processor
,"LIBRARY") == 0) goto fail
;
1106 ieee
->mb
.module_name
= read_id(&(ieee
->h
));
1107 if (abfd
->filename
== (char *)NULL
) {
1108 abfd
->filename
= ieee
->mb
.module_name
;
1110 /* Determine the architecture and machine type of the object file.
1113 bfd_arch_info_type
*arch
= bfd_scan_arch(processor
);
1114 if (arch
== 0) goto fail
;
1115 abfd
->arch_info
= arch
;
1118 if (this_byte(&(ieee
->h
)) != (int)ieee_address_descriptor_enum
) {
1121 next_byte(&(ieee
->h
));
1123 if (parse_int(&(ieee
->h
), &ieee
->ad
.number_of_bits_mau
) == false) {
1126 if(parse_int(&(ieee
->h
), &ieee
->ad
.number_of_maus_in_address
) == false) {
1130 /* If there is a byte order info, take it */
1131 if (this_byte(&(ieee
->h
)) == (int)ieee_variable_L_enum
||
1132 this_byte(&(ieee
->h
)) == (int)ieee_variable_M_enum
)
1133 next_byte(&(ieee
->h
));
1136 for (part
= 0; part
< N_W_VARIABLES
; part
++) {
1138 if (read_2bytes(&(ieee
->h
)) != (int) ieee_assign_value_to_variable_enum
) {
1141 if (this_byte_and_next(&(ieee
->h
)) != part
) {
1145 ieee
->w
.offset
[part
] = parse_i(&(ieee
->h
), &ok
);
1151 abfd
->flags
= HAS_SYMS
;
1153 /* By now we know that this is a real IEEE file, we're going to read
1154 the whole thing into memory so that we can run up and down it
1155 quickly. We can work out how big the file is from the trailer
1158 ieee_data(abfd
)->h
.first_byte
= (uint8e_type
*) bfd_alloc(ieee
->h
.abfd
, ieee
->w
.r
.me_record
1160 bfd_seek(abfd
, 0, 0);
1161 bfd_read((PTR
)(ieee_data(abfd
)->h
.first_byte
), 1, ieee
->w
.r
.me_record
+50, abfd
);
1163 ieee_slurp_sections(abfd
);
1166 (void) bfd_release(abfd
, ieee
);
1167 set_tdata (abfd
, save
);
1168 return (bfd_target
*)NULL
;
1173 DEFUN(ieee_print_symbol
,(ignore_abfd
, afile
, symbol
, how
),
1174 bfd
*ignore_abfd AND
1177 bfd_print_symbol_type how
)
1179 FILE *file
= (FILE *)afile
;
1182 case bfd_print_symbol_name
:
1183 fprintf(file
,"%s", symbol
->name
);
1185 case bfd_print_symbol_more
:
1187 fprintf(file
,"%4x %2x",aout_symbol(symbol
)->desc
& 0xffff,
1188 aout_symbol(symbol
)->other
& 0xff);
1192 case bfd_print_symbol_all
:
1194 CONST
char *section_name
= symbol
->section
== (asection
*)NULL
?
1195 "*abs" : symbol
->section
->name
;
1196 if (symbol
->name
[0] == ' ') {
1197 fprintf(file
,"* empty table entry ");
1200 bfd_print_symbol_vandf((PTR
)file
,symbol
);
1202 fprintf(file
," %-5s %04x %02x %s",
1204 (unsigned) ieee_symbol(symbol
)->index
,
1206 aout_symbol(symbol)->desc & 0xffff,
1207 aout_symbol(symbol)->other & 0xff,*/
1217 DEFUN(do_one
,(ieee
, current_map
, location_ptr
,s
),
1218 ieee_data_type
*ieee AND
1219 ieee_per_section_type
*current_map AND
1220 uint8e_type
*location_ptr AND
1223 switch (this_byte(&(ieee
->h
)))
1225 case ieee_load_constant_bytes_enum
:
1227 unsigned int number_of_maus
;
1229 next_byte(&(ieee
->h
));
1230 number_of_maus
= must_parse_int(&(ieee
->h
));
1232 for (i
= 0; i
< number_of_maus
; i
++) {
1233 location_ptr
[current_map
->pc
++]= this_byte(&(ieee
->h
));
1234 next_byte(&(ieee
->h
));
1239 case ieee_load_with_relocation_enum
:
1241 boolean loop
= true;
1242 next_byte(&(ieee
->h
));
1245 switch (this_byte(&(ieee
->h
)))
1247 case ieee_variable_R_enum
:
1249 case ieee_function_signed_open_b_enum
:
1250 case ieee_function_unsigned_open_b_enum
:
1251 case ieee_function_either_open_b_enum
:
1253 unsigned int extra
= 4;
1254 boolean pcrel
= false;
1256 ieee_reloc_type
*r
=
1257 (ieee_reloc_type
*) bfd_alloc(ieee
->h
.abfd
,
1258 sizeof(ieee_reloc_type
));
1260 *(current_map
->reloc_tail_ptr
) = r
;
1261 current_map
->reloc_tail_ptr
= &r
->next
;
1262 r
->next
= (ieee_reloc_type
*)NULL
;
1263 next_byte(&(ieee
->h
));
1264 parse_expression(ieee
,
1269 r
->relent
.address
= current_map
->pc
;
1272 if (this_byte(&(ieee
->h
)) == (int)ieee_comma
) {
1273 next_byte(&(ieee
->h
));
1274 /* Fetch number of bytes to pad */
1275 extra
= must_parse_int(&(ieee
->h
));
1278 switch (this_byte(&(ieee
->h
))) {
1279 case ieee_function_signed_close_b_enum
:
1280 next_byte(&(ieee
->h
));
1282 case ieee_function_unsigned_close_b_enum
:
1283 next_byte(&(ieee
->h
));
1285 case ieee_function_either_close_b_enum
:
1286 next_byte(&(ieee
->h
));
1291 /* Build a relocation entry for this type */
1292 /* If pc rel then stick -ve pc into instruction
1293 and take out of reloc ..
1295 I've changed this. It's all too
1296 complicated. I keep 0 in the
1307 #if KEEPMINUSPCININST
1308 bfd_put_32(ieee
->h
.abfd
, -current_map
->pc
, location_ptr
+
1310 r
->relent
.howto
= &rel32_howto
;
1314 bfd_put_32(ieee
->h
.abfd
,0, location_ptr
+
1316 r
->relent
.howto
= &rel32_howto
;
1321 bfd_put_32(ieee
->h
.abfd
, 0, location_ptr
+
1323 r
->relent
.howto
= &abs32_howto
;
1325 current_map
->pc
+=4;
1328 if (pcrel
== true) {
1329 #if KEEPMINUSPCININST
1330 bfd_put_16(ieee
->h
.abfd
, (int)(-current_map
->pc
), location_ptr
+current_map
->pc
);
1331 r
->relent
.addend
-= current_map
->pc
;
1332 r
->relent
.howto
= &rel16_howto
;
1335 bfd_put_16(ieee
->h
.abfd
, 0, location_ptr
+current_map
->pc
);
1336 r
->relent
.howto
= &rel16_howto
;
1341 bfd_put_16(ieee
->h
.abfd
, 0, location_ptr
+current_map
->pc
);
1342 r
->relent
.howto
= &abs16_howto
;
1344 current_map
->pc
+=2;
1347 if (pcrel
== true) {
1348 #if KEEPMINUSPCININST
1349 bfd_put_8(ieee
->h
.abfd
, (int)(-current_map
->pc
), location_ptr
+current_map
->pc
);
1350 r
->relent
.addend
-= current_map
->pc
;
1351 r
->relent
.howto
= &rel8_howto
;
1353 bfd_put_8(ieee
->h
.abfd
,0, location_ptr
+current_map
->pc
);
1354 r
->relent
.howto
= &rel8_howto
;
1358 bfd_put_8(ieee
->h
.abfd
, 0, location_ptr
+current_map
->pc
);
1359 r
->relent
.howto
= &abs8_howto
;
1361 current_map
->pc
+=1;
1373 if (parse_int(&(ieee
->h
), &this_size
) == true) {
1375 for (i
= 0; i
< this_size
; i
++) {
1376 location_ptr
[current_map
->pc
++] = this_byte(&(ieee
->h
));
1377 next_byte(&(ieee
->h
));
1390 /* Read in all the section data and relocation stuff too */
1392 DEFUN(ieee_slurp_section_data
,(abfd
),
1395 bfd_byte
*location_ptr
= (bfd_byte
*)NULL
;
1396 ieee_data_type
*ieee
= ieee_data(abfd
);
1397 unsigned int section_number
;
1399 ieee_per_section_type
*current_map
= (ieee_per_section_type
*)NULL
;
1401 /* Seek to the start of the data area */
1402 if (ieee
->read_data
== true) return true;
1403 ieee
->read_data
= true;
1404 ieee_seek(abfd
, ieee
->w
.r
.data_part
);
1406 /* Allocate enough space for all the section contents */
1409 for (s
= abfd
->sections
; s
!= (asection
*)NULL
; s
= s
->next
) {
1410 ieee_per_section_type
*per
= (ieee_per_section_type
*) s
->used_by_bfd
;
1411 per
->data
= (bfd_byte
*) bfd_alloc(ieee
->h
.abfd
, s
->size
);
1413 per
->reloc_tail_ptr
=
1414 (ieee_reloc_type
**)&(s
->relocation
);
1420 switch (this_byte(&(ieee
->h
)))
1422 /* IF we see anything strange then quit */
1426 case ieee_set_current_section_enum
:
1427 next_byte(&(ieee
->h
));
1428 section_number
= must_parse_int(&(ieee
->h
));
1429 s
= ieee
->section_table
[section_number
];
1430 current_map
= (ieee_per_section_type
*) s
->used_by_bfd
;
1431 location_ptr
= current_map
->data
- s
->vma
;
1432 /* The document I have says that Microtec's compilers reset */
1433 /* this after a sec section, even though the standard says not */
1435 current_map
->pc
=s
->vma
;
1439 case ieee_e2_first_byte_enum
:
1440 next_byte(&(ieee
->h
));
1441 switch (this_byte(&(ieee
->h
)))
1443 case ieee_set_current_pc_enum
& 0xff:
1447 ieee_symbol_index_type symbol
;
1450 next_byte(&(ieee
->h
));
1451 must_parse_int(&(ieee
->h
)); /* Thow away section #*/
1452 parse_expression(ieee
, &value
, &dsection
, &symbol
,
1454 current_map
->pc
= value
;
1455 BFD_ASSERT((unsigned)(value
- s
->vma
) <= s
->size
);
1459 case ieee_value_starting_address_enum
& 0xff:
1460 /* We've got to the end of the data now - */
1467 case ieee_repeat_data_enum
:
1469 /* Repeat the following LD or LR n times - we do this by
1470 remembering the stream pointer before running it and
1471 resetting it and running it n times. We special case
1472 the repetition of a repeat_data/load_constant
1475 unsigned int iterations
;
1476 uint8e_type
*start
;
1477 next_byte(&(ieee
->h
));
1478 iterations
= must_parse_int(&(ieee
->h
));
1479 start
= ieee
->h
.input_p
;
1480 if (start
[0] == (int)ieee_load_constant_bytes_enum
&&
1482 while (iterations
!= 0) {
1483 location_ptr
[current_map
->pc
++] = start
[2];
1486 next_byte(&(ieee
->h
));
1487 next_byte(&(ieee
->h
));
1488 next_byte(&(ieee
->h
));
1491 while (iterations
!= 0) {
1492 ieee
->h
.input_p
= start
;
1493 do_one(ieee
, current_map
, location_ptr
,s
);
1499 case ieee_load_constant_bytes_enum
:
1500 case ieee_load_with_relocation_enum
:
1502 do_one(ieee
, current_map
, location_ptr
,s
);
1513 DEFUN(ieee_new_section_hook
,(abfd
, newsect
),
1517 newsect
->used_by_bfd
= (PTR
)
1518 bfd_alloc(abfd
, sizeof(ieee_per_section_type
));
1519 ieee_per_section( newsect
)->data
= (bfd_byte
*)NULL
;
1520 ieee_per_section(newsect
)->section
= newsect
;
1526 DEFUN(ieee_get_reloc_upper_bound
,(abfd
, asect
),
1530 ieee_slurp_section_data(abfd
);
1531 return (asect
->reloc_count
+1) * sizeof(arelent
*);
1535 DEFUN(ieee_get_section_contents
,(abfd
, section
, location
, offset
, count
),
1540 bfd_size_type count
)
1542 ieee_per_section_type
*p
= (ieee_per_section_type
*) section
->used_by_bfd
;
1543 ieee_slurp_section_data(abfd
);
1544 (void) memcpy((PTR
)location
, (PTR
)(p
->data
+ offset
), (unsigned)count
);
1550 DEFUN(ieee_canonicalize_reloc
,(abfd
, section
, relptr
, symbols
),
1553 arelent
**relptr AND
1556 /* ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/
1557 ieee_reloc_type
*src
= (ieee_reloc_type
*)(section
->relocation
);
1558 ieee_data_type
*ieee
= ieee_data(abfd
);
1560 while (src
!= (ieee_reloc_type
*)NULL
) {
1561 /* Work out which symbol to attach it this reloc to */
1562 switch (src
->symbol
.letter
) {
1564 src
->relent
.sym_ptr_ptr
=
1565 symbols
+ src
->symbol
.index
+ ieee
->external_reference_base_offset
;
1568 src
->relent
.sym_ptr_ptr
= (asymbol
**)NULL
;
1574 *relptr
++ = &src
->relent
;
1577 *relptr
= (arelent
*)NULL
;
1578 return section
->reloc_count
;
1584 DEFUN(comp
,(ap
, bp
),
1588 arelent
*a
= *((arelent
**)ap
);
1589 arelent
*b
= *((arelent
**)bp
);
1590 return a
->address
- b
->address
;
1594 Write the section headers
1598 DEFUN(ieee_write_section_part
,(abfd
),
1601 ieee_data_type
*ieee
= ieee_data(abfd
);
1603 ieee
->w
.r
.section_part
= bfd_tell(abfd
);
1604 for (s
= abfd
->sections
; s
!= (asection
*)NULL
; s
=s
->next
) {
1605 ieee_write_byte(abfd
, ieee_section_type_enum
);
1606 ieee_write_byte(abfd
, s
->index
+ IEEE_SECTION_NUMBER_BASE
);
1608 if (abfd
->flags
& EXEC_P
)
1610 /* This image is executable, so output absolute sections */
1611 ieee_write_byte(abfd
, ieee_variable_A_enum
);
1612 ieee_write_byte(abfd
, ieee_variable_S_enum
);
1616 ieee_write_byte(abfd
, ieee_variable_C_enum
);
1619 switch (s
->flags
&(SEC_CODE
| SEC_DATA
| SEC_ROM
))
1621 case SEC_CODE
| SEC_LOAD
:
1623 ieee_write_byte(abfd
, ieee_variable_P_enum
);
1627 ieee_write_byte(abfd
, ieee_variable_D_enum
);
1630 case SEC_ROM
| SEC_DATA
:
1631 case SEC_ROM
| SEC_LOAD
:
1632 case SEC_ROM
| SEC_DATA
| SEC_LOAD
:
1634 ieee_write_byte(abfd
, ieee_variable_R_enum
);
1638 ieee_write_id(abfd
, s
->name
);
1640 ieee_write_int(abfd
, 0); /* Parent */
1641 ieee_write_int(abfd
, 0); /* Brother */
1642 ieee_write_int(abfd
, 0); /* Context */
1645 ieee_write_byte(abfd
, ieee_section_alignment_enum
);
1646 ieee_write_byte(abfd
, s
->index
+ IEEE_SECTION_NUMBER_BASE
);
1647 ieee_write_int(abfd
, 1 << s
->alignment_power
);
1650 ieee_write_2bytes(abfd
, ieee_section_size_enum
);
1651 ieee_write_byte(abfd
, s
->index
+ IEEE_SECTION_NUMBER_BASE
);
1652 ieee_write_int(abfd
, s
->size
);
1653 if (abfd
->flags
& EXEC_P
) {
1654 /* Relocateable sections don't have asl records */
1656 ieee_write_2bytes(abfd
, ieee_section_base_address_enum
);
1657 ieee_write_byte(abfd
, s
->index
+ IEEE_SECTION_NUMBER_BASE
);
1658 ieee_write_int(abfd
, s
->vma
);
1667 DEFUN(do_with_relocs
,(abfd
, s
),
1671 unsigned int relocs_to_go
= s
->reloc_count
;
1674 bfd_byte
*stream
= ieee_per_section(s
)->data
;
1675 arelent
**p
= s
->orelocation
;
1677 bfd_size_type current_byte_index
= 0;
1679 qsort(s
->orelocation
,
1684 /* Output the section preheader */
1685 ieee_write_byte(abfd
, ieee_set_current_section_enum
);
1686 ieee_write_byte(abfd
, s
->index
+ IEEE_SECTION_NUMBER_BASE
);
1688 ieee_write_twobyte(abfd
, ieee_set_current_pc_enum
);
1689 ieee_write_byte(abfd
, s
->index
+ IEEE_SECTION_NUMBER_BASE
);
1690 ieee_write_expression(abfd
, 0, s
, 0, 0, 0);
1692 if (relocs_to_go
== 0)
1694 /* If there arn't any relocations then output the load constant byte
1695 opcode rather than the load with relocation opcode */
1697 while (current_byte_index
< s
->size
) {
1699 unsigned int MAXRUN
= 32;
1701 if (run
> s
->size
- current_byte_index
) {
1702 run
= s
->size
- current_byte_index
;
1706 ieee_write_byte(abfd
, ieee_load_constant_bytes_enum
);
1707 /* Output a stream of bytes */
1708 ieee_write_int(abfd
, run
);
1709 bfd_write((PTR
)(stream
+ current_byte_index
),
1713 current_byte_index
+= run
;
1719 ieee_write_byte(abfd
, ieee_load_with_relocation_enum
);
1722 /* Output the data stream as the longest sequence of bytes
1723 possible, allowing for the a reasonable packet size and
1724 relocation stuffs */
1726 if ((PTR
)stream
== (PTR
)NULL
) {
1727 /* Outputting a section without data, fill it up */
1728 stream
= (uint8e_type
*)(bfd_alloc(abfd
, s
->size
));
1729 memset((PTR
)stream
, 0, s
->size
);
1731 while (current_byte_index
< s
->size
) {
1733 unsigned int MAXRUN
= 32;
1735 run
= (*p
)->address
- current_byte_index
;
1740 if (run
> s
->size
- current_byte_index
) {
1741 run
= s
->size
- current_byte_index
;
1745 /* Output a stream of bytes */
1746 ieee_write_int(abfd
, run
);
1747 bfd_write((PTR
)(stream
+ current_byte_index
),
1751 current_byte_index
+= run
;
1753 /* Output any relocations here */
1754 if (relocs_to_go
&& (*p
) && (*p
)->address
== current_byte_index
) {
1755 while (relocs_to_go
&& (*p
) && (*p
)->address
== current_byte_index
) {
1761 if (r
->howto
->pc_relative
) {
1762 r
->addend
+= current_byte_index
;
1766 switch (r
->howto
->size
) {
1769 ov
= bfd_get_32(abfd
,
1770 stream
+current_byte_index
);
1771 current_byte_index
+=4;
1774 ov
= bfd_get_16(abfd
,
1775 stream
+current_byte_index
);
1776 current_byte_index
+=2;
1779 ov
= bfd_get_8(abfd
,
1780 stream
+current_byte_index
);
1781 current_byte_index
++;
1787 ieee_write_byte(abfd
, ieee_function_either_open_b_enum
);
1789 if (r
->sym_ptr_ptr
!= (asymbol
**)NULL
) {
1790 ieee_write_expression(abfd
, r
->addend
+ ov
,
1793 r
->howto
->pc_relative
, s
->index
);
1796 ieee_write_expression(abfd
, r
->addend
+ ov
,
1799 r
->howto
->pc_relative
, s
->index
);
1802 if (1 || r
->howto
->size
!= 2) {
1803 ieee_write_byte(abfd
, ieee_comma
);
1804 ieee_write_int(abfd
, 1<< r
->howto
->size
);
1806 ieee_write_byte(abfd
,
1807 ieee_function_either_close_b_enum
);
1818 /* If there are no relocations in the output section then we can
1819 be clever about how we write. We block items up into a max of 127
1823 DEFUN(do_as_repeat
, (abfd
, s
),
1827 ieee_write_byte(abfd
, ieee_set_current_section_enum
);
1828 ieee_write_byte(abfd
, s
->index
+ IEEE_SECTION_NUMBER_BASE
);
1829 ieee_write_byte(abfd
, ieee_set_current_pc_enum
>> 8);
1830 ieee_write_byte(abfd
, ieee_set_current_pc_enum
& 0xff);
1831 ieee_write_byte(abfd
, s
->index
+ IEEE_SECTION_NUMBER_BASE
);
1832 ieee_write_int(abfd
, s
->vma
);
1834 ieee_write_byte(abfd
,ieee_repeat_data_enum
);
1835 ieee_write_int(abfd
, s
->size
);
1836 ieee_write_byte(abfd
, ieee_load_constant_bytes_enum
);
1837 ieee_write_byte(abfd
, 1);
1838 ieee_write_byte(abfd
, 0);
1842 DEFUN(do_without_relocs
, (abfd
, s
),
1846 bfd_byte
*stream
= ieee_per_section(s
)->data
;
1848 if (stream
== 0 || ((s
->flags
& SEC_LOAD
) == 0))
1850 do_as_repeat(abfd
, s
);
1855 for (i
= 0; i
< s
->size
; i
++) {
1856 if (stream
[i
] != 0) {
1857 do_with_relocs(abfd
, s
);
1861 do_as_repeat(abfd
, s
);
1867 static unsigned char *output_ptr_start
;
1868 static unsigned char *output_ptr
;
1869 static unsigned char *output_ptr_end
;
1870 static unsigned char *input_ptr_start
;
1871 static unsigned char *input_ptr
;
1872 static unsigned char *input_ptr_end
;
1873 static bfd
*input_bfd
;
1874 static bfd
*output_bfd
;
1875 static int output_buffer
;
1879 bfd_read((PTR
)input_ptr_start
, 1, input_ptr_end
- input_ptr_start
, input_bfd
);
1880 input_ptr
= input_ptr_start
;
1884 bfd_write((PTR
)(output_ptr_start
),1,output_ptr
- output_ptr_start
, output_bfd
);
1885 output_ptr
= output_ptr_start
;
1889 #define THIS() ( *input_ptr )
1890 #define NEXT() { input_ptr++; if (input_ptr == input_ptr_end) fill(); }
1891 #define OUT(x) { *output_ptr++ = (x); if(output_ptr == output_ptr_end) flush(); }
1893 static void write_int(value
)
1896 if (value
>= 0 && value
<= 127) {
1900 unsigned int length
;
1901 /* How many significant bytes ? */
1902 /* FIXME FOR LONGER INTS */
1903 if (value
& 0xff000000) {
1906 else if (value
& 0x00ff0000) {
1909 else if (value
& 0x0000ff00) {
1914 OUT((int)ieee_number_repeat_start_enum
+ length
);
1928 static void copy_id()
1930 int length
= THIS();
1940 #define VAR(x) ((x | 0x80))
1941 static void copy_expression()
1950 value
= THIS(); NEXT();
1951 value
= (value
<< 8) | THIS(); NEXT();
1952 value
= (value
<< 8) | THIS(); NEXT();
1953 value
= (value
<< 8) | THIS(); NEXT();
1958 value
= THIS(); NEXT();
1959 value
= (value
<< 8) | THIS(); NEXT();
1960 value
= (value
<< 8) | THIS(); NEXT();
1965 value
= THIS(); NEXT();
1966 value
= (value
<< 8) | THIS(); NEXT();
1971 value
= THIS(); NEXT();
1980 /* Not a number, just bug out with the answer */
1981 write_int(*(--tos
));
1991 int value
= *(--tos
);
1999 int section_number
;
2000 ieee_data_type
*ieee
;
2003 section_number
= THIS();
2006 ieee
= ieee_data(input_bfd
);
2007 s
= ieee
->section_table
[section_number
];
2008 if (s
->output_section
) {
2009 value
= s
->output_section
->vma
;
2010 } else { value
= 0; }
2011 value
+= s
->output_offset
;
2019 write_int(*(--tos
));
2029 /* Drop the int in the buffer, and copy a null into the gap, which we
2030 will overwrite later */
2032 struct output_buffer_struct
{
2033 unsigned char *ptrp
;
2038 DEFUN(fill_int
,(buf
),
2039 struct output_buffer_struct
*buf
)
2041 if (buf
->buffer
== output_buffer
) {
2042 /* Still a chance to output the size */
2043 int value
= output_ptr
- buf
->ptrp
+ 3;
2044 buf
->ptrp
[0] = value
>> 24;
2045 buf
->ptrp
[1] = value
>> 16;
2046 buf
->ptrp
[2] = value
>> 8;
2047 buf
->ptrp
[3] = value
>> 0;
2052 DEFUN(drop_int
,(buf
),
2053 struct output_buffer_struct
*buf
)
2060 case 0x84: ch
= THIS(); NEXT();
2061 case 0x83: ch
= THIS(); NEXT();
2062 case 0x82: ch
= THIS(); NEXT();
2063 case 0x81: ch
= THIS(); NEXT();
2068 buf
->ptrp
= output_ptr
;
2069 buf
->buffer
= output_buffer
;
2070 OUT(0);OUT(0);OUT(0);OUT(0);
2073 static void copy_int()
2081 case 0x84: ch
= THIS(); NEXT(); OUT(ch
);
2082 case 0x83: ch
= THIS(); NEXT(); OUT(ch
);
2083 case 0x82: ch
= THIS(); NEXT(); OUT(ch
);
2084 case 0x81: ch
= THIS(); NEXT(); OUT(ch
);
2090 #define ID copy_id()
2091 #define INT copy_int()
2092 #define EXP copy_expression()
2093 static void copy_till_end();
2094 #define INTn(q) copy_int()
2095 #define EXPn(q) copy_expression()
2096 static void f1_record()
2109 OUT(0xf1); OUT(0xc9);
2110 INT
; INT
; ch
= THIS();
2113 case 0x16: NEXT();break;
2114 case 0x01: NEXT();break;
2115 case 0x00: NEXT(); INT
; break;
2116 case 0x03: NEXT(); INT
; break;
2117 case 0x13: EXPn(instruction address
); break;
2125 OUT(0xf1); OUT(0xd8);
2126 EXP
; EXP
; EXP
; EXP
;
2130 OUT(0xf1);OUT(0xce); INT
; INT
; ch
= THIS(); INT
;
2137 EXPn(external function
); break;
2140 case 0x07: INTn(line number
); INT
;
2142 case 0x0a: INTn(locked
register); INT
; break;
2143 case 0x3f: copy_till_end(); break;
2144 case 0x3e: copy_till_end(); break;
2145 case 0x40: copy_till_end(); break;
2146 case 0x41: ID
; break;
2151 static void f0_record()
2153 /* Attribute record */
2159 static void copy_till_end()
2194 static void f2_record()
2206 static void block();
2207 static void f8_record()
2217 /* Unique typedefs for module */
2218 /* GLobal typedefs */
2219 /* High level module scope beginning */
2221 struct output_buffer_struct ob
;
2234 /* Global function */
2236 struct output_buffer_struct ob
;
2238 OUT(0xf8); OUT(0x04);
2239 drop_int(&ob
); ID
; INTn(stack size
); INTn(ret val
);
2246 EXPn(size of block
);
2252 /* File name for source line numbers */
2254 struct output_buffer_struct ob
;
2256 OUT(0xf8); OUT(0x05);
2258 ID
; INTn(year
); INTn(month
); INTn(day
);
2259 INTn(hour
); INTn(monute
); INTn(second
);
2268 /* Local function */
2269 { struct output_buffer_struct ob
;
2270 NEXT(); OUT(0xf8); OUT(0x06);
2272 ID
; INTn(stack size
); INTn(type
return);
2283 /* Assembler module scope beginning -*/
2284 { struct output_buffer_struct ob
;
2287 OUT(0xf8); OUT(0x0a);
2289 ID
; ID
; INT
; ID
; INT
; INT
; INT
; INT
; INT
; INT
;
2300 struct output_buffer_struct ob
;
2302 OUT(0xf8); OUT(0x0b);
2303 drop_int(&ob
); ID
; INT
; INTn(section index
); EXPn(offset
); INTn(stuff
);
2316 static void e2_record()
2326 static void DEFUN_VOID(block
)
2360 moves all the debug information from the source bfd to the output
2361 bfd, and relocates any expressions it finds
2365 DEFUN(relocate_debug
,(output
, input
),
2371 unsigned char input_buffer
[IBS
];
2373 input_ptr_start
= input_ptr
= input_buffer
;
2374 input_ptr_end
= input_buffer
+ IBS
;
2376 bfd_read((PTR
)input_ptr_start
, 1, IBS
, input
);
2380 During linking, we we told about the bfds which made up our
2381 contents, we have a list of them. They will still be open, so go to
2382 the debug info in each, and copy it out, relocating it as we go.
2386 DEFUN(ieee_write_debug_part
, (abfd
),
2389 ieee_data_type
*ieee
= ieee_data(abfd
);
2390 bfd_chain_type
*chain
= ieee
->chain_root
;
2391 unsigned char output_buffer
[OBS
];
2392 boolean some_debug
= false;
2393 file_ptr here
= bfd_tell(abfd
);
2395 output_ptr_start
= output_ptr
= output_buffer
;
2396 output_ptr_end
= output_buffer
+ OBS
;
2397 output_ptr
= output_buffer
;
2400 if (chain
== (bfd_chain_type
*)NULL
) {
2401 /* There is no debug info, so we'll fake some up */
2402 CONST
static char fake
[] = {
2403 0xf8, 0xa, 0, 5, 't', 't', 't', 't', 't', 0, 2, 3,
2404 '1','.','1',0x82, 1991>>8, 1991 & 0xff, 9, 20, 11, 07,50 };
2405 ieee
->w
.r
.debug_information_part
= 0;
2411 /* bfd_write(fake, 1, sizeof(fake), abfd);*/
2412 /* Now write a header for each section */
2415 asection
*s
= abfd
->sections
;
2417 ieee_write_byte(abfd
, 0xf8);
2418 ieee_write_byte(abfd
, 0x0b);
2419 ieee_write_byte(abfd
, 0);
2420 ieee_write_byte(abfd
, 0);
2421 ieee_write_byte(abfd
, 1);
2422 ieee_write_byte(abfd
, i
+ IEEE_SECTION_NUMBER_BASE
);
2423 ieee_write_expression(abfd
, 0, s
, 0, 0, 0);
2424 ieee_write_byte(abfd
,0);
2425 ieee_write_byte(abfd
, 0xf9);
2426 ieee_write_expression(abfd
, s
->size
, 0, 0, 0, 0);
2430 /* Close the scope */
2431 ieee_write_byte(abfd
, 0xf9);
2436 while (chain
!= (bfd_chain_type
*)NULL
) {
2437 bfd
*entry
= chain
->this;
2438 ieee_data_type
*entry_ieee
= ieee_data(entry
);
2439 if (entry_ieee
->w
.r
.debug_information_part
) {
2440 bfd_seek(entry
, entry_ieee
->w
.r
.debug_information_part
, SEEK_SET
);
2441 relocate_debug(abfd
, entry
);
2444 chain
= chain
->next
;
2447 ieee
->w
.r
.debug_information_part
= here
;
2450 ieee
->w
.r
.debug_information_part
= 0;
2456 /* write the data in an ieee way */
2458 DEFUN(ieee_write_data_part
,(abfd
),
2462 ieee_data_type
*ieee
= ieee_data(abfd
);
2463 ieee
->w
.r
.data_part
= bfd_tell(abfd
);
2464 for (s
= abfd
->sections
; s
!= (asection
*)NULL
; s
= s
->next
)
2466 /* Sort the reloc records so we can insert them in the correct
2468 if (s
->reloc_count
!= 0)
2470 do_with_relocs(abfd
, s
);
2474 do_without_relocs(abfd
, s
);
2482 DEFUN(init_for_output
,(abfd
),
2486 for (s
= abfd
->sections
; s
!= (asection
*)NULL
; s
= s
->next
) {
2488 ieee_per_section(s
)->data
= (bfd_byte
*)(bfd_alloc(abfd
, s
->size
));
2493 /** exec and core file sections */
2495 /* set section contents is complicated with IEEE since the format is
2496 * not a byte image, but a record stream.
2499 DEFUN(ieee_set_section_contents
,(abfd
, section
, location
, offset
, count
),
2504 bfd_size_type count
)
2506 if (ieee_per_section(section
)->data
== (bfd_byte
*)NULL
) {
2507 init_for_output(abfd
);
2509 (void) memcpy((PTR
)(ieee_per_section(section
)->data
+ offset
),
2511 (unsigned int)count
);
2516 write the external symbols of a file, IEEE considers two sorts of
2517 external symbols, public, and referenced. It uses to internal forms
2518 to index them as well. When we write them out we turn their symbol
2519 values into indexes from the right base.
2522 DEFUN(ieee_write_external_part
,(abfd
),
2526 ieee_data_type
*ieee
= ieee_data(abfd
);
2528 unsigned int reference_index
= IEEE_REFERENCE_BASE
;
2529 unsigned int public_index
= IEEE_PUBLIC_BASE
+2;
2530 file_ptr here
= bfd_tell(abfd
);
2531 boolean hadone
= false;
2532 if (abfd
->outsymbols
!= (asymbol
**)NULL
) {
2534 for (q
= abfd
->outsymbols
; *q
!= (asymbol
*)NULL
; q
++) {
2537 if (p
->flags
& BSF_UNDEFINED
) {
2538 /* This must be a symbol reference .. */
2539 ieee_write_byte(abfd
, ieee_external_reference_enum
);
2540 ieee_write_int(abfd
, reference_index
);
2541 ieee_write_id(abfd
, p
->name
);
2542 p
->value
= reference_index
;
2545 else if(p
->flags
& BSF_FORT_COMM
) {
2546 /* This is a weak reference */
2547 ieee_write_byte(abfd
, ieee_external_reference_enum
);
2548 ieee_write_int(abfd
, reference_index
);
2549 ieee_write_id(abfd
, p
->name
);
2550 ieee_write_byte(abfd
, ieee_weak_external_reference_enum
);
2551 ieee_write_int(abfd
, reference_index
);
2552 ieee_write_int(abfd
, p
->value
);
2553 ieee_write_int(abfd
, BFD_FORT_COMM_DEFAULT_VALUE
);
2554 p
->value
= reference_index
;
2557 else if(p
->flags
& BSF_GLOBAL
) {
2558 /* This must be a symbol definition */
2561 ieee_write_byte(abfd
, ieee_external_symbol_enum
);
2562 ieee_write_int(abfd
, public_index
);
2563 ieee_write_id(abfd
, p
->name
);
2565 ieee_write_twobyte(abfd
, ieee_attribute_record_enum
);
2566 ieee_write_int(abfd
, public_index
);
2567 ieee_write_byte(abfd
, 15); /* instruction address */
2568 ieee_write_byte(abfd
, 19); /* static symbol */
2569 ieee_write_byte(abfd
, 1); /* one of them */
2572 /* Write out the value */
2573 ieee_write_2bytes(abfd
, ieee_value_record_enum
);
2574 ieee_write_int(abfd
, public_index
);
2575 if (p
->section
!= (asection
*)NULL
)
2577 if (abfd
->flags
& EXEC_P
)
2579 /* If fully linked, then output all symbols
2581 ieee_write_int(abfd
,
2582 p
->value
+ p
->section
->output_offset
+ p
->section
->output_section
->vma
);
2586 ieee_write_expression(abfd
,
2587 p
->value
+ p
->section
->output_offset
,
2588 p
->section
->output_section
,
2589 (asymbol
*)NULL
, false, 0);
2594 ieee_write_expression(abfd
,
2597 (asymbol
*)NULL
, false, 0);
2599 p
->value
= public_index
;
2603 /* This can happen - when there are gaps in the symbols read */
2604 /* from an input ieee file */
2609 ieee
->w
.r
.external_part
= here
;
2614 CONST
static char exten
[] =
2617 0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3 */
2618 0xf1, 0xce, 0x20, 0x00, 39, 2, /* keep symbol in original case */
2619 0xf1, 0xce, 0x20, 0x00, 38 /* set object type relocateable to x */
2622 CONST
static char environ
[] =
2626 /* 0xf1, 0xce, 0x21, 00, 50, 0x82, 0x07, 0xc7, 0x09, 0x11, 0x11,
2629 0xf1, 0xce, 0x21, 00, 52, 0x00, /* exec ok */
2631 0xf1, 0xce, 0x21, 0, 53, 0x03, /* host unix */
2632 /* 0xf1, 0xce, 0x21, 0, 54, 2,1,1 tool & version # */
2637 DEFUN(ieee_write_me_part
,(abfd
),
2640 ieee_data_type
*ieee
= ieee_data(abfd
);
2641 ieee
->w
.r
.trailer_part
= bfd_tell(abfd
);
2642 if (abfd
->start_address
) {
2643 ieee
->w
.r
.me_record
= bfd_tell(abfd
);
2644 ieee_write_2bytes(abfd
, ieee_value_starting_address_enum
);
2645 ieee_write_byte(abfd
, ieee_function_either_open_b_enum
);
2646 ieee_write_int(abfd
, abfd
->start_address
);
2647 ieee_write_byte(abfd
, ieee_function_either_close_b_enum
);
2650 ieee
->w
.r
.me_record
= bfd_tell(abfd
);
2652 ieee_write_byte(abfd
, ieee_module_end_enum
);
2656 DEFUN(ieee_write_object_contents
,(abfd
),
2659 ieee_data_type
*ieee
= ieee_data(abfd
);
2662 /* Fast forward over the header area */
2663 bfd_seek(abfd
, 0, 0);
2664 ieee_write_byte(abfd
, ieee_module_beginning_enum
);
2666 ieee_write_id(abfd
, bfd_printable_name(abfd
));
2667 ieee_write_id(abfd
, abfd
->filename
);
2672 /* Fast forward over the variable bits */
2676 ieee_write_byte(abfd
, ieee_address_descriptor_enum
);
2679 ieee_write_byte(abfd
, bfd_arch_bits_per_byte(abfd
));
2680 /* MAU's per address */
2681 ieee_write_byte(abfd
, bfd_arch_bits_per_address(abfd
) /
2682 bfd_arch_bits_per_byte(abfd
));
2685 old
= bfd_tell(abfd
);
2686 bfd_seek(abfd
, 8 * N_W_VARIABLES
, 1);
2689 ieee
->w
.r
.extension_record
= bfd_tell(abfd
);
2690 bfd_write(exten
, 1, sizeof(exten
), abfd
);
2691 if (abfd
->flags
& EXEC_P
)
2692 ieee_write_byte(abfd
, 0x1); /* Absolute */
2694 ieee_write_byte(abfd
, 0x2); /* Relocateable */
2696 ieee
->w
.r
.environmental_record
= bfd_tell(abfd
);
2697 bfd_write(environ
, 1, sizeof(environ
), abfd
);
2701 ieee_write_section_part(abfd
);
2703 First write the symbols, this changes their values into table
2704 indeces so we cant use it after this point
2706 ieee_write_external_part(abfd
);
2707 /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
2710 /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
2714 Write any debugs we have been told about
2716 ieee_write_debug_part(abfd
);
2719 Can only write the data once the symbols have been written since
2720 the data contains relocation information which points to the
2723 ieee_write_data_part(abfd
);
2727 At the end we put the end !
2729 ieee_write_me_part(abfd
);
2732 /* Generate the header */
2733 bfd_seek(abfd
, old
, false);
2735 for (i
= 0; i
< N_W_VARIABLES
; i
++) {
2736 ieee_write_2bytes(abfd
,ieee_assign_value_to_variable_enum
);
2737 ieee_write_byte(abfd
, i
);
2738 ieee_write_int5_out(abfd
, ieee
->w
.offset
[i
]);
2746 /* Native-level interface to symbols. */
2748 /* We read the symbols into a buffer, which is discarded when this
2749 function exits. We read the strings into a buffer large enough to
2750 hold them all plus all the cached symbol entries. */
2753 DEFUN(ieee_make_empty_symbol
,(abfd
),
2757 ieee_symbol_type
*new =
2758 (ieee_symbol_type
*)zalloc (sizeof (ieee_symbol_type
));
2759 new->symbol
.the_bfd
= abfd
;
2760 return &new->symbol
;
2765 DEFUN(ieee_openr_next_archived_file
,(arch
, prev
),
2769 ieee_ar_data_type
*ar
= ieee_ar_data(arch
);
2770 /* take the next one from the arch state, or reset */
2771 if (prev
== (bfd
*)NULL
) {
2772 /* Reset the index - the first two entries are bogus*/
2773 ar
->element_index
= 2;
2776 ieee_ar_obstack_type
*p
= ar
->elements
+ ar
->element_index
;
2777 ar
->element_index
++;
2778 if (ar
->element_index
<= ar
->element_count
) {
2779 if (p
->file_offset
!= (file_ptr
)0) {
2780 if (p
->abfd
== (bfd
*)NULL
) {
2781 p
->abfd
= _bfd_create_empty_archive_element_shell(arch
);
2782 p
->abfd
->origin
= p
->file_offset
;
2788 bfd_error
= no_more_archived_files
;
2796 ieee_find_nearest_line(abfd
,
2807 char **filename_ptr
;
2808 char **functionname_ptr
;
2816 ieee_generic_stat_arch_elt(abfd
, buf
)
2820 ieee_ar_data_type
*ar
= ieee_ar_data(abfd
);
2821 if (ar
== (ieee_ar_data_type
*)NULL
) {
2822 bfd_error
= invalid_operation
;
2827 buf
->st_mode
= 0666;
2832 DEFUN(ieee_sizeof_headers
,(abfd
, x
),
2842 DEFUN(ieee_bfd_debug_info_start
,(abfd
),
2849 DEFUN(ieee_bfd_debug_info_end
,(abfd
),
2856 /* Add this section to the list of sections we have debug info for, to
2857 be ready to output it at close time
2860 DEFUN(ieee_bfd_debug_info_accumulate
,(abfd
, section
),
2864 ieee_data_type
*ieee
= ieee_data(section
->owner
);
2865 ieee_data_type
*output_ieee
= ieee_data(abfd
);
2866 /* can only accumulate data from other ieee bfds */
2867 if (section
->owner
->xvec
!= abfd
->xvec
)
2869 /* Only bother once per bfd */
2870 if (ieee
->done_debug
== true)
2872 ieee
->done_debug
= true;
2874 /* Don't bother if there is no debug info */
2875 if (ieee
->w
.r
.debug_information_part
== 0)
2881 bfd_chain_type
*n
= (bfd_chain_type
*) bfd_alloc(abfd
, sizeof(bfd_chain_type
));
2882 n
->this = section
->owner
;
2883 n
->next
= (bfd_chain_type
*)NULL
;
2885 if (output_ieee
->chain_head
) {
2886 output_ieee
->chain_head
->next
= n
;
2889 output_ieee
->chain_root
= n
;
2892 output_ieee
->chain_head
= n
;
2902 #define ieee_core_file_failing_command (char *(*)())(bfd_nullvoidptr)
2903 #define ieee_core_file_failing_signal (int (*)())bfd_0
2904 #define ieee_core_file_matches_executable_p ( FOO(boolean, (*),(bfd *, bfd *)))bfd_false
2905 #define ieee_slurp_armap bfd_true
2906 #define ieee_slurp_extended_name_table bfd_true
2907 #define ieee_truncate_arname (void (*)())bfd_nullvoidptr
2908 #define ieee_write_armap (FOO( boolean, (*),(bfd *, unsigned int, struct orl *, unsigned int, int))) bfd_nullvoidptr
2909 #define ieee_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr
2910 #define ieee_close_and_cleanup bfd_generic_close_and_cleanup
2911 #define ieee_set_arch_mach bfd_default_set_arch_mach
2914 bfd_target ieee_vec
=
2917 bfd_target_ieee_flavour
,
2918 true, /* target byte order */
2919 true, /* target headers byte order */
2920 (HAS_RELOC
| EXEC_P
| /* object flags */
2921 HAS_LINENO
| HAS_DEBUG
|
2922 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
| D_PAGED
),
2923 (SEC_CODE
|SEC_DATA
|SEC_ROM
|SEC_HAS_CONTENTS
2924 |SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
2925 ' ', /* ar_pad_char */
2926 16, /* ar_max_namelen */
2927 1, /* minimum alignment */
2928 _do_getb64
, _do_putb64
, _do_getb32
, _do_putb32
, _do_getb16
, _do_putb16
, /* data */
2929 _do_getb64
, _do_putb64
, _do_getb32
, _do_putb32
, _do_getb16
, _do_putb16
, /* hdrs */
2931 { _bfd_dummy_target
,
2932 ieee_object_p
, /* bfd_check_format */
2939 _bfd_generic_mkarchive
,
2944 ieee_write_object_contents
,
2945 _bfd_write_archive_contents
,