1 /* BFD back-end for ieee-695 objects.
2 Copyright (C) 1990, 91, 92, 93, 94 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 #define KEEPMINUSPCININST 0
23 /* IEEE 695 format is a stream of records, which we parse using a simple one-
24 token (which is one byte in this lexicon) lookahead recursive decent
33 #define obstack_chunk_alloc malloc
34 #define obstack_chunk_free free
36 /* Functions for writing to ieee files in the strange way that the
40 DEFUN (ieee_write_byte
, (abfd
, byte
),
44 bfd_write ((PTR
) & byte
, 1, 1, abfd
);
48 DEFUN (ieee_write_twobyte
, (abfd
, twobyte
),
53 b
[1] = twobyte
& 0xff;
55 bfd_write ((PTR
) & b
[0], 1, 2, abfd
);
59 DEFUN (ieee_write_2bytes
, (abfd
, bytes
),
64 buffer
[0] = bytes
>> 8;
65 buffer
[1] = bytes
& 0xff;
67 bfd_write ((PTR
) buffer
, 1, 2, abfd
);
71 DEFUN (ieee_write_int
, (abfd
, value
),
75 if (((unsigned) value
) <= 127)
77 ieee_write_byte (abfd
, (bfd_byte
) value
);
82 /* How many significant bytes ? */
83 /* FIXME FOR LONGER INTS */
84 if (value
& 0xff000000)
88 else if (value
& 0x00ff0000)
92 else if (value
& 0x0000ff00)
99 ieee_write_byte (abfd
,
100 (bfd_byte
) ((int) ieee_number_repeat_start_enum
+ length
));
104 ieee_write_byte (abfd
, (bfd_byte
) (value
>> 24));
106 ieee_write_byte (abfd
, (bfd_byte
) (value
>> 16));
108 ieee_write_byte (abfd
, (bfd_byte
) (value
>> 8));
110 ieee_write_byte (abfd
, (bfd_byte
) (value
));
116 DEFUN (ieee_write_id
, (abfd
, id
),
120 size_t length
= strlen (id
);
123 ieee_write_byte (abfd
, (bfd_byte
) length
);
125 else if (length
< 255)
127 ieee_write_byte (abfd
, ieee_extension_length_1_enum
);
128 ieee_write_byte (abfd
, (bfd_byte
) length
);
130 else if (length
< 65535)
132 ieee_write_byte (abfd
, ieee_extension_length_2_enum
);
133 ieee_write_byte (abfd
, (bfd_byte
) (length
>> 8));
134 ieee_write_byte (abfd
, (bfd_byte
) (length
& 0xff));
140 bfd_write ((PTR
) id
, 1, length
, abfd
);
144 /***************************************************************************
145 Functions for reading from ieee files in the strange way that the
149 #define this_byte(ieee) *((ieee)->input_p)
150 #define next_byte(ieee) ((ieee)->input_p++)
151 #define this_byte_and_next(ieee) (*((ieee)->input_p++))
153 static unsigned short
154 DEFUN (read_2bytes
, (ieee
),
155 common_header_type
* ieee
)
157 unsigned char c1
= this_byte_and_next (ieee
);
158 unsigned char c2
= this_byte_and_next (ieee
);
159 return (c1
<< 8) | c2
;
163 DEFUN (bfd_get_string
, (ieee
, string
, length
),
164 common_header_type
* ieee AND
169 for (i
= 0; i
< length
; i
++)
171 string
[i
] = this_byte_and_next (ieee
);
176 DEFUN (read_id
, (ieee
),
177 common_header_type
* ieee
)
181 length
= this_byte_and_next (ieee
);
184 /* Simple string of length 0 to 127 */
186 else if (length
== 0xde)
188 /* Length is next byte, allowing 0..255 */
189 length
= this_byte_and_next (ieee
);
191 else if (length
== 0xdf)
193 /* Length is next two bytes, allowing 0..65535 */
194 length
= this_byte_and_next (ieee
);
195 length
= (length
* 256) + this_byte_and_next (ieee
);
197 /* Buy memory and read string */
198 string
= bfd_alloc (ieee
->abfd
, length
+ 1);
201 bfd_error
= no_memory
;
204 bfd_get_string (ieee
, string
, length
);
210 DEFUN (ieee_write_expression
, (abfd
, value
, symbol
, pcrel
, index
),
217 unsigned int term_count
= 0;
221 ieee_write_int (abfd
, value
);
225 if (bfd_is_com_section (symbol
->section
)
226 || symbol
->section
== &bfd_und_section
)
228 /* Def of a common symbol */
229 ieee_write_byte (abfd
, ieee_variable_X_enum
);
230 ieee_write_int (abfd
, symbol
->value
);
233 else if (symbol
->section
!= &bfd_abs_section
)
235 /* Ref to defined symbol - */
237 ieee_write_byte (abfd
, ieee_variable_R_enum
);
238 ieee_write_byte (abfd
,
239 (bfd_byte
) (symbol
->section
->index
+ IEEE_SECTION_NUMBER_BASE
));
241 if (symbol
->flags
& BSF_GLOBAL
)
243 ieee_write_byte (abfd
, ieee_variable_I_enum
);
244 ieee_write_int (abfd
, symbol
->value
);
247 else if (symbol
->flags
& (BSF_LOCAL
| BSF_SECTION_SYM
))
249 /* This is a reference to a defined local symbol,
250 We can easily do a local as a section+offset */
251 ieee_write_byte (abfd
, ieee_variable_R_enum
); /* or L */
252 ieee_write_byte (abfd
,
253 (bfd_byte
) (symbol
->section
->index
+ IEEE_SECTION_NUMBER_BASE
));
254 ieee_write_int (abfd
, symbol
->value
);
265 /* subtract the pc from here by asking for PC of this section*/
266 ieee_write_byte (abfd
, ieee_variable_P_enum
);
267 ieee_write_byte (abfd
, (bfd_byte
) (index
+ IEEE_SECTION_NUMBER_BASE
));
268 ieee_write_byte (abfd
, ieee_function_minus_enum
);
273 ieee_write_byte (abfd
, 0);
277 while (term_count
> 1)
279 ieee_write_byte (abfd
, ieee_function_plus_enum
);
286 /*****************************************************************************/
289 writes any integer into the buffer supplied and always takes 5 bytes
292 DEFUN (ieee_write_int5
, (buffer
, value
),
293 bfd_byte
* buffer AND
296 buffer
[0] = (bfd_byte
) ieee_number_repeat_4_enum
;
297 buffer
[1] = (value
>> 24) & 0xff;
298 buffer
[2] = (value
>> 16) & 0xff;
299 buffer
[3] = (value
>> 8) & 0xff;
300 buffer
[4] = (value
>> 0) & 0xff;
304 DEFUN (ieee_write_int5_out
, (abfd
, value
),
309 ieee_write_int5 (b
, value
);
310 bfd_write ((PTR
) b
, 1, 5, abfd
);
314 DEFUN (parse_int
, (ieee
, value_ptr
),
315 common_header_type
* ieee AND
318 int value
= this_byte (ieee
);
320 if (value
>= 0 && value
<= 127)
326 else if (value
>= 0x80 && value
<= 0x88)
328 unsigned int count
= value
& 0xf;
333 result
= (result
<< 8) | this_byte_and_next (ieee
);
343 DEFUN (parse_i
, (ieee
, ok
),
344 common_header_type
* ieee AND
348 *ok
= parse_int (ieee
, &x
);
353 DEFUN (must_parse_int
, (ieee
),
354 common_header_type
* ieee
)
357 BFD_ASSERT (parse_int (ieee
, &result
) == true);
365 ieee_symbol_index_type symbol
;
370 reloc_howto_type abs32_howto
371 = HOWTO (1, 0, 2, 32, false, 0, complain_overflow_bitfield
, 0, "abs32", true, 0xffffffff, 0xffffffff, false);
373 reloc_howto_type abs16_howto
374 = HOWTO (1, 0, 1, 16, false, 0, complain_overflow_bitfield
, 0, "abs16", true, 0x0000ffff, 0x0000ffff, false);
377 reloc_howto_type abs8_howto
378 = HOWTO (1, 0, 0, 8, false, 0, complain_overflow_bitfield
, 0, "abs8", true, 0x000000ff, 0x000000ff, false);
381 reloc_howto_type rel32_howto
382 = HOWTO (1, 0, 2, 32, true, 0, complain_overflow_signed
, 0, "rel32", true, 0xffffffff,
386 reloc_howto_type rel16_howto
387 = HOWTO (1, 0, 1, 16, true, 0, complain_overflow_signed
, 0, "rel16", true, 0x0000ffff, 0x0000ffff, false);
390 reloc_howto_type rel8_howto
391 = HOWTO (1, 0, 0, 8, true, 0, complain_overflow_signed
, 0, "rel8", true, 0x000000ff, 0x000000ff, false);
394 static ieee_symbol_index_type NOSYMBOL
=
399 DEFUN (parse_expression
, (ieee
, value
, symbol
, pcrel
, extra
, section
),
400 ieee_data_type
* ieee AND
402 ieee_symbol_index_type
* symbol AND
404 unsigned int *extra AND
415 ieee_value_type stack
[10];
417 /* The stack pointer always points to the next unused location */
418 #define PUSH(x,y,z) TOS.symbol=x;TOS.section=y;TOS.value=z;INC;
419 #define POP(x,y,z) DEC;x=TOS.symbol;y=TOS.section;z=TOS.value;
420 ieee_value_type
*sp
= stack
;
424 switch (this_byte (&(ieee
->h
)))
426 case ieee_variable_P_enum
:
427 /* P variable, current program counter for section n */
430 next_byte (&(ieee
->h
));
432 section_n
= must_parse_int (&(ieee
->h
));
433 PUSH (NOSYMBOL
, &bfd_abs_section
,
434 TOS
.value
= ieee
->section_table
[section_n
]->vma
+
435 ieee_per_section (ieee
->section_table
[section_n
])->pc
);
438 case ieee_variable_L_enum
:
439 /* L variable address of section N */
440 next_byte (&(ieee
->h
));
441 PUSH (NOSYMBOL
, ieee
->section_table
[must_parse_int (&(ieee
->h
))], 0);
443 case ieee_variable_R_enum
:
444 /* R variable, logical address of section module */
445 /* FIXME, this should be different to L */
446 next_byte (&(ieee
->h
));
447 PUSH (NOSYMBOL
, ieee
->section_table
[must_parse_int (&(ieee
->h
))], 0);
449 case ieee_variable_S_enum
:
450 /* S variable, size in MAUS of section module */
451 next_byte (&(ieee
->h
));
454 ieee
->section_table
[must_parse_int (&(ieee
->h
))]->_raw_size
);
456 case ieee_variable_I_enum
:
457 case ieee_variable_X_enum
:
458 /* Push the address of external variable n */
460 ieee_symbol_index_type sy
;
461 next_byte (&(ieee
->h
));
462 sy
.index
= (int) (must_parse_int (&(ieee
->h
)));
465 PUSH (sy
, &bfd_und_section
, 0);
468 case ieee_function_minus_enum
:
470 bfd_vma value1
, value2
;
471 asection
*section1
, *section_dummy
;
472 ieee_symbol_index_type sy
;
473 next_byte (&(ieee
->h
));
475 POP (sy
, section1
, value1
);
476 POP (sy
, section_dummy
, value2
);
477 PUSH (sy
, section1
? section1
: section_dummy
, value1
- value2
);
480 case ieee_function_plus_enum
:
482 bfd_vma value1
, value2
;
485 ieee_symbol_index_type sy1
;
486 ieee_symbol_index_type sy2
;
487 next_byte (&(ieee
->h
));
489 POP (sy1
, section1
, value1
);
490 POP (sy2
, section2
, value2
);
491 PUSH (sy1
.letter
? sy1
: sy2
, section1
!= &bfd_abs_section
? section1
: section2
, value1
+ value2
);
497 BFD_ASSERT (this_byte (&(ieee
->h
)) < (int) ieee_variable_A_enum
498 || this_byte (&(ieee
->h
)) > (int) ieee_variable_Z_enum
);
499 if (parse_int (&(ieee
->h
), &va
))
501 PUSH (NOSYMBOL
, &bfd_abs_section
, va
);
506 Thats all that we can understand. As far as I can see
507 there is a bug in the Microtec IEEE output which I'm
508 using to scan, whereby the comma operator is omitted
509 sometimes in an expression, giving expressions with too
510 many terms. We can tell if that's the case by ensuring
511 that sp == stack here. If not, then we've pushed
512 something too far, so we keep adding. */
514 while (sp
!= stack
+ 1)
517 ieee_symbol_index_type sy1
;
518 POP (sy1
, section1
, *extra
);
523 POP (*symbol
, dummy
, *value
);
536 #define ieee_seek(abfd, offset) \
537 IEEE_DATA(abfd)->h.input_p = IEEE_DATA(abfd)->h.first_byte + offset
539 #define ieee_pos(abfd) IEEE_DATA(abfd)->h.input_p -IEEE_DATA(abfd)->h.first_byte
541 static unsigned int last_index
;
542 static char last_type
; /* is the index for an X or a D */
544 static ieee_symbol_type
*
545 DEFUN (get_symbol
, (abfd
,
554 ieee_data_type
* ieee AND
555 ieee_symbol_type
* last_symbol AND
556 unsigned int *symbol_count AND
557 ieee_symbol_type
*** pptr AND
558 unsigned int *max_index AND
562 /* Need a new symbol */
563 unsigned int new_index
= must_parse_int (&(ieee
->h
));
564 if (new_index
!= last_index
|| this_type
!= last_type
)
566 ieee_symbol_type
*new_symbol
= (ieee_symbol_type
*) bfd_alloc (ieee
->h
.abfd
,
567 sizeof (ieee_symbol_type
));
570 bfd_error
= no_memory
;
574 new_symbol
->index
= new_index
;
575 last_index
= new_index
;
578 *pptr
= &new_symbol
->next
;
579 if (new_index
> *max_index
)
581 *max_index
= new_index
;
583 last_type
= this_type
;
590 DEFUN (ieee_slurp_external_symbols
, (abfd
),
593 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
594 file_ptr offset
= ieee
->w
.r
.external_part
;
596 ieee_symbol_type
**prev_symbols_ptr
= &ieee
->external_symbols
;
597 ieee_symbol_type
**prev_reference_ptr
= &ieee
->external_reference
;
598 ieee_symbol_type
*symbol
= (ieee_symbol_type
*) NULL
;
599 unsigned int symbol_count
= 0;
601 last_index
= 0xffffff;
602 ieee
->symbol_table_full
= true;
604 ieee_seek (abfd
, offset
);
608 switch (this_byte (&(ieee
->h
)))
611 next_byte (&(ieee
->h
));
613 symbol
= get_symbol (abfd
, ieee
, symbol
, &symbol_count
,
615 &ieee
->external_symbol_max_index
, 'D');
618 symbol
->symbol
.the_bfd
= abfd
;
619 symbol
->symbol
.name
= read_id (&(ieee
->h
));
620 symbol
->symbol
.udata
= (PTR
) NULL
;
621 symbol
->symbol
.flags
= BSF_NO_FLAGS
;
623 case ieee_external_symbol_enum
:
624 next_byte (&(ieee
->h
));
626 symbol
= get_symbol (abfd
, ieee
, symbol
, &symbol_count
,
628 &ieee
->external_symbol_max_index
, 'D');
631 BFD_ASSERT (symbol
->index
>= ieee
->external_symbol_min_index
);
633 symbol
->symbol
.the_bfd
= abfd
;
634 symbol
->symbol
.name
= read_id (&(ieee
->h
));
635 symbol
->symbol
.udata
= (PTR
) NULL
;
636 symbol
->symbol
.flags
= BSF_NO_FLAGS
;
638 case ieee_attribute_record_enum
>> 8:
640 unsigned int symbol_name_index
;
641 unsigned int symbol_type_index
;
642 unsigned int symbol_attribute_def
;
644 next_byte (&(ieee
->h
)); /* Skip prefix */
645 next_byte (&(ieee
->h
));
646 symbol_name_index
= must_parse_int (&(ieee
->h
));
647 symbol_type_index
= must_parse_int (&(ieee
->h
));
648 symbol_attribute_def
= must_parse_int (&(ieee
->h
));
649 switch (symbol_attribute_def
)
652 /* Module misc; followed by two fields which describe the
653 current module block. The first fired is the type id
654 number, the second is the number of asn records
655 associated with the directive */
656 parse_int (&(ieee
->h
), &value
);
657 parse_int (&(ieee
->h
), &value
);
661 parse_int (&(ieee
->h
), &value
);
666 case ieee_value_record_enum
>> 8:
668 unsigned int symbol_name_index
;
669 ieee_symbol_index_type symbol_ignore
;
670 boolean pcrel_ignore
;
672 next_byte (&(ieee
->h
));
673 next_byte (&(ieee
->h
));
675 symbol_name_index
= must_parse_int (&(ieee
->h
));
676 parse_expression (ieee
,
677 &symbol
->symbol
.value
,
681 &symbol
->symbol
.section
);
683 symbol
->symbol
.flags
= BSF_GLOBAL
| BSF_EXPORT
;
687 case ieee_weak_external_reference_enum
:
691 next_byte (&(ieee
->h
));
692 /* Throw away the external reference index */
693 (void) must_parse_int (&(ieee
->h
));
694 /* Fetch the default size if not resolved */
695 size
= must_parse_int (&(ieee
->h
));
696 /* Fetch the defautlt value if available */
697 if (parse_int (&(ieee
->h
), &value
) == false)
701 /* This turns into a common */
702 symbol
->symbol
.section
= &bfd_com_section
;
703 symbol
->symbol
.value
= size
;
707 case ieee_external_reference_enum
:
708 next_byte (&(ieee
->h
));
710 symbol
= get_symbol (abfd
, ieee
, symbol
, &symbol_count
,
712 &ieee
->external_reference_max_index
, 'X');
715 symbol
->symbol
.the_bfd
= abfd
;
716 symbol
->symbol
.name
= read_id (&(ieee
->h
));
717 symbol
->symbol
.udata
= (PTR
) NULL
;
718 symbol
->symbol
.section
= &bfd_und_section
;
719 symbol
->symbol
.value
= (bfd_vma
) 0;
720 symbol
->symbol
.flags
= 0;
722 BFD_ASSERT (symbol
->index
>= ieee
->external_reference_min_index
);
730 if (ieee
->external_symbol_max_index
!= 0)
732 ieee
->external_symbol_count
=
733 ieee
->external_symbol_max_index
-
734 ieee
->external_symbol_min_index
+ 1;
738 ieee
->external_symbol_count
= 0;
741 if (ieee
->external_reference_max_index
!= 0)
743 ieee
->external_reference_count
=
744 ieee
->external_reference_max_index
-
745 ieee
->external_reference_min_index
+ 1;
749 ieee
->external_reference_count
= 0;
753 ieee
->external_reference_count
+ ieee
->external_symbol_count
;
755 if (symbol_count
!= abfd
->symcount
)
757 /* There are gaps in the table -- */
758 ieee
->symbol_table_full
= false;
761 *prev_symbols_ptr
= (ieee_symbol_type
*) NULL
;
762 *prev_reference_ptr
= (ieee_symbol_type
*) NULL
;
766 DEFUN (ieee_slurp_symbol_table
, (abfd
),
769 if (IEEE_DATA (abfd
)->read_symbols
== false)
771 ieee_slurp_external_symbols (abfd
);
772 IEEE_DATA (abfd
)->read_symbols
= true;
777 DEFUN (ieee_get_symtab_upper_bound
, (abfd
),
780 ieee_slurp_symbol_table (abfd
);
782 return (abfd
->symcount
!= 0) ?
783 (abfd
->symcount
+ 1) * (sizeof (ieee_symbol_type
*)) : 0;
787 Move from our internal lists to the canon table, and insert in
791 extern bfd_target ieee_vec
;
794 DEFUN (ieee_get_symtab
, (abfd
, location
),
798 ieee_symbol_type
*symp
;
799 static bfd dummy_bfd
;
800 static asymbol empty_symbol
=
801 /* the_bfd, name, value, attr, section */
802 {&dummy_bfd
, " ieee empty", (symvalue
) 0, BSF_DEBUGGING
, &bfd_abs_section
};
806 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
807 dummy_bfd
.xvec
= &ieee_vec
;
808 ieee_slurp_symbol_table (abfd
);
810 if (ieee
->symbol_table_full
== false)
812 /* Arrgh - there are gaps in the table, run through and fill them */
813 /* up with pointers to a null place */
815 for (i
= 0; i
< abfd
->symcount
; i
++)
817 location
[i
] = &empty_symbol
;
821 ieee
->external_symbol_base_offset
= -ieee
->external_symbol_min_index
;
822 for (symp
= IEEE_DATA (abfd
)->external_symbols
;
823 symp
!= (ieee_symbol_type
*) NULL
;
826 /* Place into table at correct index locations */
827 location
[symp
->index
+ ieee
->external_symbol_base_offset
] = &symp
->symbol
;
830 /* The external refs are indexed in a bit */
831 ieee
->external_reference_base_offset
=
832 -ieee
->external_reference_min_index
+ ieee
->external_symbol_count
;
834 for (symp
= IEEE_DATA (abfd
)->external_reference
;
835 symp
!= (ieee_symbol_type
*) NULL
;
838 location
[symp
->index
+ ieee
->external_reference_base_offset
] =
845 location
[abfd
->symcount
] = (asymbol
*) NULL
;
847 return abfd
->symcount
;
851 DEFUN (get_section_entry
, (abfd
, ieee
, index
),
853 ieee_data_type
* ieee AND
856 if (ieee
->section_table
[index
] == (asection
*) NULL
)
858 char *tmp
= bfd_alloc (abfd
, 11);
863 bfd_error
= no_memory
;
866 sprintf (tmp
, " fsec%4d", index
);
867 section
= bfd_make_section (abfd
, tmp
);
868 ieee
->section_table
[index
] = section
;
869 section
->flags
= SEC_NO_FLAGS
;
870 section
->target_index
= index
;
871 ieee
->section_table
[index
] = section
;
873 return ieee
->section_table
[index
];
877 DEFUN (ieee_slurp_sections
, (abfd
),
880 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
881 file_ptr offset
= ieee
->w
.r
.section_part
;
882 asection
*section
= (asection
*) NULL
;
887 bfd_byte section_type
[3];
888 ieee_seek (abfd
, offset
);
891 switch (this_byte (&(ieee
->h
)))
893 case ieee_section_type_enum
:
895 unsigned int section_index
;
896 next_byte (&(ieee
->h
));
897 section_index
= must_parse_int (&(ieee
->h
));
898 /* Fixme to be nice about a silly number of sections */
899 BFD_ASSERT (section_index
< NSECTIONS
);
901 section
= get_section_entry (abfd
, ieee
, section_index
);
903 section_type
[0] = this_byte_and_next (&(ieee
->h
));
904 switch (section_type
[0])
907 /* Normal attributes for absolute sections */
908 section_type
[1] = this_byte (&(ieee
->h
));
909 section
->flags
= SEC_LOAD
| SEC_ALLOC
| SEC_HAS_CONTENTS
;
910 switch (section_type
[1])
912 case 0xD3: /* AS Absolute section attributes */
913 next_byte (&(ieee
->h
));
914 section_type
[2] = this_byte (&(ieee
->h
));
915 switch (section_type
[2])
919 next_byte (&(ieee
->h
));
920 section
->flags
|= SEC_LOAD
| SEC_CODE
;
923 next_byte (&(ieee
->h
));
924 section
->flags
|= SEC_LOAD
| SEC_DATA
;
928 next_byte (&(ieee
->h
));
929 /* Normal rom data */
930 section
->flags
|= SEC_LOAD
| SEC_ROM
| SEC_DATA
;
937 case 0xC3: /* Named relocatable sections (type C) */
938 section_type
[1] = this_byte (&(ieee
->h
));
939 section
->flags
= SEC_LOAD
| SEC_ALLOC
| SEC_HAS_CONTENTS
;
940 switch (section_type
[1])
942 case 0xD0: /* Normal code (CP) */
943 next_byte (&(ieee
->h
));
944 section
->flags
|= SEC_LOAD
| SEC_CODE
;
946 case 0xC4: /* Normal data (CD) */
947 next_byte (&(ieee
->h
));
948 section
->flags
|= SEC_LOAD
| SEC_DATA
;
950 case 0xD2: /* Normal rom data (CR) */
951 next_byte (&(ieee
->h
));
952 section
->flags
|= SEC_LOAD
| SEC_ROM
| SEC_DATA
;
959 /* Read section name, use it if non empty. */
960 name
= read_id (&ieee
->h
);
962 section
->name
= name
;
964 /* Skip these fields, which we don't care about */
966 bfd_vma parent
, brother
, context
;
967 parse_int (&(ieee
->h
), &parent
);
968 parse_int (&(ieee
->h
), &brother
);
969 parse_int (&(ieee
->h
), &context
);
973 case ieee_section_alignment_enum
:
975 unsigned int section_index
;
978 next_byte (&(ieee
->h
));
979 section_index
= must_parse_int (&ieee
->h
);
980 section
= get_section_entry (abfd
, ieee
, section_index
);
981 if (section_index
> ieee
->section_count
)
983 ieee
->section_count
= section_index
;
985 section
->alignment_power
=
986 bfd_log2 (must_parse_int (&ieee
->h
));
987 (void) parse_int (&(ieee
->h
), &value
);
990 case ieee_e2_first_byte_enum
:
992 ieee_record_enum_type t
= (ieee_record_enum_type
) (read_2bytes (&(ieee
->h
)));
996 case ieee_section_size_enum
:
997 section
= ieee
->section_table
[must_parse_int (&(ieee
->h
))];
998 section
->_raw_size
= must_parse_int (&(ieee
->h
));
1000 case ieee_physical_region_size_enum
:
1001 section
= ieee
->section_table
[must_parse_int (&(ieee
->h
))];
1002 section
->_raw_size
= must_parse_int (&(ieee
->h
));
1004 case ieee_region_base_address_enum
:
1005 section
= ieee
->section_table
[must_parse_int (&(ieee
->h
))];
1006 section
->vma
= must_parse_int (&(ieee
->h
));
1008 case ieee_mau_size_enum
:
1009 must_parse_int (&(ieee
->h
));
1010 must_parse_int (&(ieee
->h
));
1012 case ieee_m_value_enum
:
1013 must_parse_int (&(ieee
->h
));
1014 must_parse_int (&(ieee
->h
));
1016 case ieee_section_base_address_enum
:
1017 section
= ieee
->section_table
[must_parse_int (&(ieee
->h
))];
1018 section
->vma
= must_parse_int (&(ieee
->h
));
1020 case ieee_section_offset_enum
:
1021 (void) must_parse_int (&(ieee
->h
));
1022 (void) must_parse_int (&(ieee
->h
));
1037 /***********************************************************************
1042 DEFUN (ieee_archive_p
, (abfd
),
1049 unsigned char buffer
[512];
1051 file_ptr buffer_offset
= 0;
1052 ieee_ar_data_type
*save
= abfd
->tdata
.ieee_ar_data
;
1053 ieee_ar_data_type
*ieee
;
1054 abfd
->tdata
.ieee_ar_data
= (ieee_ar_data_type
*) bfd_alloc (abfd
, sizeof (ieee_ar_data_type
));
1055 if (!abfd
->tdata
.ieee_ar_data
)
1057 bfd_error
= no_memory
;
1060 ieee
= IEEE_AR_DATA (abfd
);
1062 bfd_read ((PTR
) buffer
, 1, sizeof (buffer
), abfd
);
1064 ieee
->h
.first_byte
= buffer
;
1065 ieee
->h
.input_p
= buffer
;
1067 ieee
->h
.abfd
= abfd
;
1069 if (this_byte (&(ieee
->h
)) != Module_Beginning
)
1071 abfd
->tdata
.ieee_ar_data
= save
;
1072 return (bfd_target
*) NULL
;
1075 next_byte (&(ieee
->h
));
1076 library
= read_id (&(ieee
->h
));
1077 if (strcmp (library
, "LIBRARY") != 0)
1079 bfd_release (abfd
, ieee
);
1080 abfd
->tdata
.ieee_ar_data
= save
;
1081 return (bfd_target
*) NULL
;
1083 /* Throw away the filename */
1084 read_id (&(ieee
->h
));
1085 /* This must be an IEEE archive, so we'll buy some space to do
1088 if (!obstack_begin (&ob
, 128))
1090 bfd_error
= no_memory
;
1091 return (bfd_target
*) NULL
;
1094 ieee
->element_count
= 0;
1095 ieee
->element_index
= 0;
1097 next_byte (&(ieee
->h
)); /* Drop the ad part */
1098 must_parse_int (&(ieee
->h
)); /* And the two dummy numbers */
1099 must_parse_int (&(ieee
->h
));
1102 /* Read the index of the BB table */
1105 ieee_ar_obstack_type t
;
1106 int rec
= read_2bytes (&(ieee
->h
));
1107 if (rec
== (int) ieee_assign_value_to_variable_enum
)
1109 must_parse_int (&(ieee
->h
));
1110 t
.file_offset
= must_parse_int (&(ieee
->h
));
1111 t
.abfd
= (bfd
*) NULL
;
1112 ieee
->element_count
++;
1114 obstack_grow (&ob
, (PTR
) & t
, sizeof (t
));
1116 /* Make sure that we don't go over the end of the buffer */
1118 if (ieee_pos (abfd
) > sizeof (buffer
) / 2)
1120 /* Past half way, reseek and reprime */
1121 buffer_offset
+= ieee_pos (abfd
);
1122 bfd_seek (abfd
, buffer_offset
, SEEK_SET
);
1123 bfd_read ((PTR
) buffer
, 1, sizeof (buffer
), abfd
);
1124 ieee
->h
.first_byte
= buffer
;
1125 ieee
->h
.input_p
= buffer
;
1132 ieee
->elements
= (ieee_ar_obstack_type
*) obstack_finish (&ob
);
1133 if (!ieee
->elements
)
1135 bfd_error
= no_memory
;
1136 return (bfd_target
*) NULL
;
1139 /* Now scan the area again, and replace BB offsets with file */
1142 for (i
= 2; i
< ieee
->element_count
; i
++)
1144 bfd_seek (abfd
, ieee
->elements
[i
].file_offset
, SEEK_SET
);
1145 bfd_read ((PTR
) buffer
, 1, sizeof (buffer
), abfd
);
1146 ieee
->h
.first_byte
= buffer
;
1147 ieee
->h
.input_p
= buffer
;
1149 next_byte (&(ieee
->h
)); /* Drop F8 */
1150 next_byte (&(ieee
->h
)); /* Drop 14 */
1151 must_parse_int (&(ieee
->h
)); /* Drop size of block */
1152 if (must_parse_int (&(ieee
->h
)) != 0)
1154 /* This object has been deleted */
1155 ieee
->elements
[i
].file_offset
= 0;
1159 ieee
->elements
[i
].file_offset
= must_parse_int (&(ieee
->h
));
1163 /* abfd->has_armap = ;*/
1168 DEFUN (ieee_mkobject
, (abfd
),
1171 abfd
->tdata
.ieee_data
= (ieee_data_type
*) bfd_zalloc (abfd
, sizeof (ieee_data_type
));
1172 return abfd
->tdata
.ieee_data
? true : false;
1176 DEFUN (ieee_object_p
, (abfd
),
1181 ieee_data_type
*ieee
;
1182 unsigned char buffer
[300];
1183 ieee_data_type
*save
= IEEE_DATA (abfd
);
1185 abfd
->tdata
.ieee_data
= 0;
1186 ieee_mkobject (abfd
);
1188 ieee
= IEEE_DATA (abfd
);
1189 bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
);
1190 /* Read the first few bytes in to see if it makes sense */
1191 bfd_read ((PTR
) buffer
, 1, sizeof (buffer
), abfd
);
1193 ieee
->h
.input_p
= buffer
;
1194 if (this_byte_and_next (&(ieee
->h
)) != Module_Beginning
)
1197 ieee
->read_symbols
= false;
1198 ieee
->read_data
= false;
1199 ieee
->section_count
= 0;
1200 ieee
->external_symbol_max_index
= 0;
1201 ieee
->external_symbol_min_index
= IEEE_PUBLIC_BASE
;
1202 ieee
->external_reference_min_index
= IEEE_REFERENCE_BASE
;
1203 ieee
->external_reference_max_index
= 0;
1204 ieee
->h
.abfd
= abfd
;
1205 memset ((PTR
) ieee
->section_table
, 0, sizeof (ieee
->section_table
));
1207 processor
= ieee
->mb
.processor
= read_id (&(ieee
->h
));
1208 if (strcmp (processor
, "LIBRARY") == 0)
1210 ieee
->mb
.module_name
= read_id (&(ieee
->h
));
1211 if (abfd
->filename
== (CONST
char *) NULL
)
1213 abfd
->filename
= ieee
->mb
.module_name
;
1215 /* Determine the architecture and machine type of the object file.
1218 bfd_arch_info_type
*arch
= bfd_scan_arch (processor
);
1221 abfd
->arch_info
= arch
;
1224 if (this_byte (&(ieee
->h
)) != (int) ieee_address_descriptor_enum
)
1228 next_byte (&(ieee
->h
));
1230 if (parse_int (&(ieee
->h
), &ieee
->ad
.number_of_bits_mau
) == false)
1234 if (parse_int (&(ieee
->h
), &ieee
->ad
.number_of_maus_in_address
) == false)
1239 /* If there is a byte order info, take it */
1240 if (this_byte (&(ieee
->h
)) == (int) ieee_variable_L_enum
||
1241 this_byte (&(ieee
->h
)) == (int) ieee_variable_M_enum
)
1242 next_byte (&(ieee
->h
));
1244 for (part
= 0; part
< N_W_VARIABLES
; part
++)
1247 if (read_2bytes (&(ieee
->h
)) != (int) ieee_assign_value_to_variable_enum
)
1251 if (this_byte_and_next (&(ieee
->h
)) != part
)
1256 ieee
->w
.offset
[part
] = parse_i (&(ieee
->h
), &ok
);
1263 abfd
->flags
= HAS_SYMS
;
1264 /* By now we know that this is a real IEEE file, we're going to read
1265 the whole thing into memory so that we can run up and down it
1266 quickly. We can work out how big the file is from the trailer
1269 IEEE_DATA (abfd
)->h
.first_byte
= (unsigned char *) bfd_alloc (ieee
->h
.abfd
, ieee
->w
.r
.me_record
1271 if (!IEEE_DATA (abfd
)->h
.first_byte
)
1273 bfd_error
= no_memory
;
1276 bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
);
1277 bfd_read ((PTR
) (IEEE_DATA (abfd
)->h
.first_byte
), 1, ieee
->w
.r
.me_record
+ 50, abfd
);
1279 ieee_slurp_sections (abfd
);
1282 (void) bfd_release (abfd
, ieee
);
1283 abfd
->tdata
.ieee_data
= save
;
1284 return (bfd_target
*) NULL
;
1288 DEFUN (ieee_get_symbol_info
, (ignore_abfd
, symbol
, ret
),
1289 bfd
* ignore_abfd AND
1290 asymbol
* symbol AND
1293 bfd_symbol_info (symbol
, ret
);
1294 if (symbol
->name
[0] == ' ')
1295 ret
->name
= "* empty table entry ";
1296 if (!symbol
->section
)
1297 ret
->type
= (symbol
->flags
& BSF_LOCAL
) ? 'a' : 'A';
1301 DEFUN (ieee_print_symbol
, (ignore_abfd
, afile
, symbol
, how
),
1302 bfd
* ignore_abfd AND
1304 asymbol
* symbol AND
1305 bfd_print_symbol_type how
)
1307 FILE *file
= (FILE *) afile
;
1311 case bfd_print_symbol_name
:
1312 fprintf (file
, "%s", symbol
->name
);
1314 case bfd_print_symbol_more
:
1316 fprintf (file
, "%4x %2x", aout_symbol (symbol
)->desc
& 0xffff,
1317 aout_symbol (symbol
)->other
& 0xff);
1321 case bfd_print_symbol_all
:
1323 CONST
char *section_name
= symbol
->section
== (asection
*) NULL
?
1324 (CONST
char *) "*abs" : symbol
->section
->name
;
1325 if (symbol
->name
[0] == ' ')
1327 fprintf (file
, "* empty table entry ");
1331 bfd_print_symbol_vandf ((PTR
) file
, symbol
);
1333 fprintf (file
, " %-5s %04x %02x %s",
1335 (unsigned) ieee_symbol (symbol
)->index
,
1337 aout_symbol(symbol)->desc & 0xffff,
1338 aout_symbol(symbol)->other & 0xff,*/
1347 DEFUN (do_one
, (ieee
, current_map
, location_ptr
, s
),
1348 ieee_data_type
* ieee AND
1349 ieee_per_section_type
* current_map AND
1350 unsigned char *location_ptr AND
1353 switch (this_byte (&(ieee
->h
)))
1355 case ieee_load_constant_bytes_enum
:
1357 unsigned int number_of_maus
;
1359 next_byte (&(ieee
->h
));
1360 number_of_maus
= must_parse_int (&(ieee
->h
));
1362 for (i
= 0; i
< number_of_maus
; i
++)
1364 location_ptr
[current_map
->pc
++] = this_byte (&(ieee
->h
));
1365 next_byte (&(ieee
->h
));
1370 case ieee_load_with_relocation_enum
:
1372 boolean loop
= true;
1373 next_byte (&(ieee
->h
));
1376 switch (this_byte (&(ieee
->h
)))
1378 case ieee_variable_R_enum
:
1380 case ieee_function_signed_open_b_enum
:
1381 case ieee_function_unsigned_open_b_enum
:
1382 case ieee_function_either_open_b_enum
:
1384 unsigned int extra
= 4;
1385 boolean pcrel
= false;
1387 ieee_reloc_type
*r
=
1388 (ieee_reloc_type
*) bfd_alloc (ieee
->h
.abfd
,
1389 sizeof (ieee_reloc_type
));
1392 bfd_error
= no_memory
;
1396 *(current_map
->reloc_tail_ptr
) = r
;
1397 current_map
->reloc_tail_ptr
= &r
->next
;
1398 r
->next
= (ieee_reloc_type
*) NULL
;
1399 next_byte (&(ieee
->h
));
1401 r
->relent
.sym_ptr_ptr
= 0;
1402 parse_expression (ieee
,
1405 &pcrel
, &extra
, §ion
);
1406 r
->relent
.address
= current_map
->pc
;
1408 if (r
->relent
.sym_ptr_ptr
== 0)
1410 r
->relent
.sym_ptr_ptr
= section
->symbol_ptr_ptr
;
1413 if (this_byte (&(ieee
->h
)) == (int) ieee_comma
)
1415 next_byte (&(ieee
->h
));
1416 /* Fetch number of bytes to pad */
1417 extra
= must_parse_int (&(ieee
->h
));
1420 switch (this_byte (&(ieee
->h
)))
1422 case ieee_function_signed_close_b_enum
:
1423 next_byte (&(ieee
->h
));
1425 case ieee_function_unsigned_close_b_enum
:
1426 next_byte (&(ieee
->h
));
1428 case ieee_function_either_close_b_enum
:
1429 next_byte (&(ieee
->h
));
1434 /* Build a relocation entry for this type */
1435 /* If pc rel then stick -ve pc into instruction
1436 and take out of reloc ..
1438 I've changed this. It's all too
1439 complicated. I keep 0 in the
1450 #if KEEPMINUSPCININST
1451 bfd_put_32 (ieee
->h
.abfd
, -current_map
->pc
, location_ptr
+
1453 r
->relent
.howto
= &rel32_howto
;
1457 bfd_put_32 (ieee
->h
.abfd
, 0, location_ptr
+
1459 r
->relent
.howto
= &rel32_howto
;
1464 bfd_put_32 (ieee
->h
.abfd
, 0, location_ptr
+
1466 r
->relent
.howto
= &abs32_howto
;
1468 current_map
->pc
+= 4;
1473 #if KEEPMINUSPCININST
1474 bfd_put_16 (ieee
->h
.abfd
, (int) (-current_map
->pc
), location_ptr
+ current_map
->pc
);
1475 r
->relent
.addend
-= current_map
->pc
;
1476 r
->relent
.howto
= &rel16_howto
;
1479 bfd_put_16 (ieee
->h
.abfd
, 0, location_ptr
+ current_map
->pc
);
1480 r
->relent
.howto
= &rel16_howto
;
1486 bfd_put_16 (ieee
->h
.abfd
, 0, location_ptr
+ current_map
->pc
);
1487 r
->relent
.howto
= &abs16_howto
;
1489 current_map
->pc
+= 2;
1494 #if KEEPMINUSPCININST
1495 bfd_put_8 (ieee
->h
.abfd
, (int) (-current_map
->pc
), location_ptr
+ current_map
->pc
);
1496 r
->relent
.addend
-= current_map
->pc
;
1497 r
->relent
.howto
= &rel8_howto
;
1499 bfd_put_8 (ieee
->h
.abfd
, 0, location_ptr
+ current_map
->pc
);
1500 r
->relent
.howto
= &rel8_howto
;
1505 bfd_put_8 (ieee
->h
.abfd
, 0, location_ptr
+ current_map
->pc
);
1506 r
->relent
.howto
= &abs8_howto
;
1508 current_map
->pc
+= 1;
1520 if (parse_int (&(ieee
->h
), &this_size
) == true)
1523 for (i
= 0; i
< this_size
; i
++)
1525 location_ptr
[current_map
->pc
++] = this_byte (&(ieee
->h
));
1526 next_byte (&(ieee
->h
));
1541 /* Read in all the section data and relocation stuff too */
1543 DEFUN (ieee_slurp_section_data
, (abfd
),
1546 bfd_byte
*location_ptr
= (bfd_byte
*) NULL
;
1547 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
1548 unsigned int section_number
;
1550 ieee_per_section_type
*current_map
= (ieee_per_section_type
*) NULL
;
1552 /* Seek to the start of the data area */
1553 if (ieee
->read_data
== true)
1555 ieee
->read_data
= true;
1556 ieee_seek (abfd
, ieee
->w
.r
.data_part
);
1558 /* Allocate enough space for all the section contents */
1560 for (s
= abfd
->sections
; s
!= (asection
*) NULL
; s
= s
->next
)
1562 ieee_per_section_type
*per
= (ieee_per_section_type
*) s
->used_by_bfd
;
1563 per
->data
= (bfd_byte
*) bfd_alloc (ieee
->h
.abfd
, s
->_raw_size
);
1566 bfd_error
= no_memory
;
1570 per
->reloc_tail_ptr
=
1571 (ieee_reloc_type
**) & (s
->relocation
);
1576 switch (this_byte (&(ieee
->h
)))
1578 /* IF we see anything strange then quit */
1582 case ieee_set_current_section_enum
:
1583 next_byte (&(ieee
->h
));
1584 section_number
= must_parse_int (&(ieee
->h
));
1585 s
= ieee
->section_table
[section_number
];
1586 current_map
= (ieee_per_section_type
*) s
->used_by_bfd
;
1587 location_ptr
= current_map
->data
- s
->vma
;
1588 /* The document I have says that Microtec's compilers reset */
1589 /* this after a sec section, even though the standard says not */
1591 current_map
->pc
= s
->vma
;
1594 case ieee_e2_first_byte_enum
:
1595 next_byte (&(ieee
->h
));
1596 switch (this_byte (&(ieee
->h
)))
1598 case ieee_set_current_pc_enum
& 0xff:
1601 ieee_symbol_index_type symbol
;
1604 next_byte (&(ieee
->h
));
1605 must_parse_int (&(ieee
->h
)); /* Thow away section #*/
1606 parse_expression (ieee
, &value
,
1610 current_map
->pc
= value
;
1611 BFD_ASSERT ((unsigned) (value
- s
->vma
) <= s
->_raw_size
);
1615 case ieee_value_starting_address_enum
& 0xff:
1616 /* We've got to the end of the data now - */
1623 case ieee_repeat_data_enum
:
1625 /* Repeat the following LD or LR n times - we do this by
1626 remembering the stream pointer before running it and
1627 resetting it and running it n times. We special case
1628 the repetition of a repeat_data/load_constant
1631 unsigned int iterations
;
1632 unsigned char *start
;
1633 next_byte (&(ieee
->h
));
1634 iterations
= must_parse_int (&(ieee
->h
));
1635 start
= ieee
->h
.input_p
;
1636 if (start
[0] == (int) ieee_load_constant_bytes_enum
&&
1639 while (iterations
!= 0)
1641 location_ptr
[current_map
->pc
++] = start
[2];
1644 next_byte (&(ieee
->h
));
1645 next_byte (&(ieee
->h
));
1646 next_byte (&(ieee
->h
));
1650 while (iterations
!= 0)
1652 ieee
->h
.input_p
= start
;
1653 if (!do_one (ieee
, current_map
, location_ptr
, s
))
1660 case ieee_load_constant_bytes_enum
:
1661 case ieee_load_with_relocation_enum
:
1663 if (!do_one (ieee
, current_map
, location_ptr
, s
))
1671 DEFUN (ieee_new_section_hook
, (abfd
, newsect
),
1675 newsect
->used_by_bfd
= (PTR
)
1676 bfd_alloc (abfd
, sizeof (ieee_per_section_type
));
1677 if (!newsect
->used_by_bfd
)
1679 bfd_error
= no_memory
;
1682 ieee_per_section (newsect
)->data
= (bfd_byte
*) NULL
;
1683 ieee_per_section (newsect
)->section
= newsect
;
1688 DEFUN (ieee_get_reloc_upper_bound
, (abfd
, asect
),
1692 ieee_slurp_section_data (abfd
);
1693 return (asect
->reloc_count
+ 1) * sizeof (arelent
*);
1697 DEFUN (ieee_get_section_contents
, (abfd
, section
, location
, offset
, count
),
1702 bfd_size_type count
)
1704 ieee_per_section_type
*p
= (ieee_per_section_type
*) section
->used_by_bfd
;
1705 ieee_slurp_section_data (abfd
);
1706 (void) memcpy ((PTR
) location
, (PTR
) (p
->data
+ offset
), (unsigned) count
);
1711 DEFUN (ieee_canonicalize_reloc
, (abfd
, section
, relptr
, symbols
),
1714 arelent
** relptr AND
1717 /* ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/
1718 ieee_reloc_type
*src
= (ieee_reloc_type
*) (section
->relocation
);
1719 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
1721 while (src
!= (ieee_reloc_type
*) NULL
)
1723 /* Work out which symbol to attach it this reloc to */
1724 switch (src
->symbol
.letter
)
1727 src
->relent
.sym_ptr_ptr
=
1728 symbols
+ src
->symbol
.index
+ ieee
->external_reference_base_offset
;
1731 src
->relent
.sym_ptr_ptr
=
1732 src
->relent
.sym_ptr_ptr
[0]->section
->symbol_ptr_ptr
;
1738 *relptr
++ = &src
->relent
;
1741 *relptr
= (arelent
*) NULL
;
1742 return section
->reloc_count
;
1746 DEFUN (comp
, (ap
, bp
),
1750 arelent
*a
= *((arelent
**) ap
);
1751 arelent
*b
= *((arelent
**) bp
);
1752 return a
->address
- b
->address
;
1756 Write the section headers
1760 DEFUN (ieee_write_section_part
, (abfd
),
1763 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
1765 ieee
->w
.r
.section_part
= bfd_tell (abfd
);
1766 for (s
= abfd
->sections
; s
!= (asection
*) NULL
; s
= s
->next
)
1768 if (s
!= &bfd_abs_section
)
1770 ieee_write_byte (abfd
, ieee_section_type_enum
);
1771 ieee_write_byte (abfd
, (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
1773 if (abfd
->flags
& EXEC_P
)
1775 /* This image is executable, so output absolute sections */
1776 ieee_write_byte (abfd
, ieee_variable_A_enum
);
1777 ieee_write_byte (abfd
, ieee_variable_S_enum
);
1781 ieee_write_byte (abfd
, ieee_variable_C_enum
);
1784 switch (s
->flags
& (SEC_CODE
| SEC_DATA
| SEC_ROM
))
1786 case SEC_CODE
| SEC_LOAD
:
1788 ieee_write_byte (abfd
, ieee_variable_P_enum
);
1792 ieee_write_byte (abfd
, ieee_variable_D_enum
);
1795 case SEC_ROM
| SEC_DATA
:
1796 case SEC_ROM
| SEC_LOAD
:
1797 case SEC_ROM
| SEC_DATA
| SEC_LOAD
:
1799 ieee_write_byte (abfd
, ieee_variable_R_enum
);
1803 ieee_write_id (abfd
, s
->name
);
1805 ieee_write_int (abfd
, 0); /* Parent */
1806 ieee_write_int (abfd
, 0); /* Brother */
1807 ieee_write_int (abfd
, 0); /* Context */
1810 ieee_write_byte (abfd
, ieee_section_alignment_enum
);
1811 ieee_write_byte (abfd
, (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
1812 ieee_write_int (abfd
, 1 << s
->alignment_power
);
1815 ieee_write_2bytes (abfd
, ieee_section_size_enum
);
1816 ieee_write_byte (abfd
, (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
1817 ieee_write_int (abfd
, s
->_raw_size
);
1818 if (abfd
->flags
& EXEC_P
)
1820 /* Relocateable sections don't have asl records */
1822 ieee_write_2bytes (abfd
, ieee_section_base_address_enum
);
1823 ieee_write_byte (abfd
,
1824 (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
1825 ieee_write_int (abfd
, s
->vma
);
1834 DEFUN (do_with_relocs
, (abfd
, s
),
1838 unsigned int relocs_to_go
= s
->reloc_count
;
1840 bfd_byte
*stream
= ieee_per_section (s
)->data
;
1841 arelent
**p
= s
->orelocation
;
1843 bfd_size_type current_byte_index
= 0;
1845 qsort (s
->orelocation
,
1847 sizeof (arelent
**),
1850 /* Output the section preheader */
1851 ieee_write_byte (abfd
, ieee_set_current_section_enum
);
1852 ieee_write_byte (abfd
, (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
1854 ieee_write_twobyte (abfd
, ieee_set_current_pc_enum
);
1855 ieee_write_byte (abfd
, (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
1856 ieee_write_expression (abfd
, 0, s
->symbol
, 0, 0);
1858 if (relocs_to_go
== 0)
1860 /* If there arn't any relocations then output the load constant byte
1861 opcode rather than the load with relocation opcode */
1863 while (current_byte_index
< s
->_raw_size
)
1866 unsigned int MAXRUN
= 32;
1868 if (run
> s
->_raw_size
- current_byte_index
)
1870 run
= s
->_raw_size
- current_byte_index
;
1875 ieee_write_byte (abfd
, ieee_load_constant_bytes_enum
);
1876 /* Output a stream of bytes */
1877 ieee_write_int (abfd
, run
);
1878 bfd_write ((PTR
) (stream
+ current_byte_index
),
1882 current_byte_index
+= run
;
1888 ieee_write_byte (abfd
, ieee_load_with_relocation_enum
);
1891 /* Output the data stream as the longest sequence of bytes
1892 possible, allowing for the a reasonable packet size and
1893 relocation stuffs */
1895 if ((PTR
) stream
== (PTR
) NULL
)
1897 /* Outputting a section without data, fill it up */
1898 stream
= (unsigned char *) (bfd_alloc (abfd
, s
->_raw_size
));
1901 bfd_error
= no_memory
;
1904 memset ((PTR
) stream
, 0, s
->_raw_size
);
1906 while (current_byte_index
< s
->_raw_size
)
1909 unsigned int MAXRUN
= 32;
1912 run
= (*p
)->address
- current_byte_index
;
1918 if (run
> s
->_raw_size
- current_byte_index
)
1920 run
= s
->_raw_size
- current_byte_index
;
1925 /* Output a stream of bytes */
1926 ieee_write_int (abfd
, run
);
1927 bfd_write ((PTR
) (stream
+ current_byte_index
),
1931 current_byte_index
+= run
;
1933 /* Output any relocations here */
1934 if (relocs_to_go
&& (*p
) && (*p
)->address
== current_byte_index
)
1936 while (relocs_to_go
&& (*p
) && (*p
)->address
== current_byte_index
)
1943 if (r
->howto
->pc_relative
)
1945 r
->addend
+= current_byte_index
;
1949 switch (r
->howto
->size
)
1953 ov
= bfd_get_32 (abfd
,
1954 stream
+ current_byte_index
);
1955 current_byte_index
+= 4;
1958 ov
= bfd_get_16 (abfd
,
1959 stream
+ current_byte_index
);
1960 current_byte_index
+= 2;
1963 ov
= bfd_get_8 (abfd
,
1964 stream
+ current_byte_index
);
1965 current_byte_index
++;
1971 ieee_write_byte (abfd
, ieee_function_either_open_b_enum
);
1974 if (r
->sym_ptr_ptr
!= (asymbol
**) NULL
)
1976 ieee_write_expression (abfd
, r
->addend
+ ov
,
1978 r
->howto
->pc_relative
, s
->index
);
1982 ieee_write_expression (abfd
, r
->addend
+ ov
,
1984 r
->howto
->pc_relative
, s
->index
);
1987 if (1 || r
->howto
->size
!= 2)
1989 ieee_write_byte (abfd
, ieee_comma
);
1990 ieee_write_int (abfd
, 1 << r
->howto
->size
);
1992 ieee_write_byte (abfd
,
1993 ieee_function_either_close_b_enum
);
2005 /* If there are no relocations in the output section then we can
2006 be clever about how we write. We block items up into a max of 127
2010 DEFUN (do_as_repeat
, (abfd
, s
),
2016 ieee_write_byte (abfd
, ieee_set_current_section_enum
);
2017 ieee_write_byte (abfd
, (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
2018 ieee_write_byte (abfd
, ieee_set_current_pc_enum
>> 8);
2019 ieee_write_byte (abfd
, ieee_set_current_pc_enum
& 0xff);
2020 ieee_write_byte (abfd
, (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
2021 ieee_write_int (abfd
, s
->vma
);
2023 ieee_write_byte (abfd
, ieee_repeat_data_enum
);
2024 ieee_write_int (abfd
, s
->_raw_size
);
2025 ieee_write_byte (abfd
, ieee_load_constant_bytes_enum
);
2026 ieee_write_byte (abfd
, 1);
2027 ieee_write_byte (abfd
, 0);
2032 DEFUN (do_without_relocs
, (abfd
, s
),
2036 bfd_byte
*stream
= ieee_per_section (s
)->data
;
2038 if (stream
== 0 || ((s
->flags
& SEC_LOAD
) == 0))
2040 do_as_repeat (abfd
, s
);
2045 for (i
= 0; i
< s
->_raw_size
; i
++)
2049 do_with_relocs (abfd
, s
);
2053 do_as_repeat (abfd
, s
);
2059 static unsigned char *output_ptr_start
;
2060 static unsigned char *output_ptr
;
2061 static unsigned char *output_ptr_end
;
2062 static unsigned char *input_ptr_start
;
2063 static unsigned char *input_ptr
;
2064 static unsigned char *input_ptr_end
;
2065 static bfd
*input_bfd
;
2066 static bfd
*output_bfd
;
2067 static int output_buffer
;
2072 bfd_read ((PTR
) input_ptr_start
, 1, input_ptr_end
- input_ptr_start
, input_bfd
);
2073 input_ptr
= input_ptr_start
;
2078 bfd_write ((PTR
) (output_ptr_start
), 1, output_ptr
- output_ptr_start
, output_bfd
);
2079 output_ptr
= output_ptr_start
;
2083 #define THIS() ( *input_ptr )
2084 #define NEXT() { input_ptr++; if (input_ptr == input_ptr_end) fill(); }
2085 #define OUT(x) { *output_ptr++ = (x); if(output_ptr == output_ptr_end) flush(); }
2091 if (value
>= 0 && value
<= 127)
2097 unsigned int length
;
2098 /* How many significant bytes ? */
2099 /* FIXME FOR LONGER INTS */
2100 if (value
& 0xff000000)
2104 else if (value
& 0x00ff0000)
2108 else if (value
& 0x0000ff00)
2115 OUT ((int) ieee_number_repeat_start_enum
+ length
);
2134 int length
= THIS ();
2146 #define VAR(x) ((x | 0x80))
2161 value
= (value
<< 8) | THIS ();
2163 value
= (value
<< 8) | THIS ();
2165 value
= (value
<< 8) | THIS ();
2173 value
= (value
<< 8) | THIS ();
2175 value
= (value
<< 8) | THIS ();
2183 value
= (value
<< 8) | THIS ();
2200 /* Not a number, just bug out with the answer */
2201 write_int (*(--tos
));
2211 int value
= *(--tos
);
2220 ieee_data_type
*ieee
;
2223 section_number
= THIS ();
2226 ieee
= IEEE_DATA (input_bfd
);
2227 s
= ieee
->section_table
[section_number
];
2228 if (s
->output_section
)
2230 value
= s
->output_section
->vma
;
2236 value
+= s
->output_offset
;
2244 write_int (*(--tos
));
2254 /* Drop the int in the buffer, and copy a null into the gap, which we
2255 will overwrite later */
2257 struct output_buffer_struct
2259 unsigned char *ptrp
;
2264 DEFUN (fill_int
, (buf
),
2265 struct output_buffer_struct
*buf
)
2267 if (buf
->buffer
== output_buffer
)
2269 /* Still a chance to output the size */
2270 int value
= output_ptr
- buf
->ptrp
+ 3;
2271 buf
->ptrp
[0] = value
>> 24;
2272 buf
->ptrp
[1] = value
>> 16;
2273 buf
->ptrp
[2] = value
>> 8;
2274 buf
->ptrp
[3] = value
>> 0;
2279 DEFUN (drop_int
, (buf
),
2280 struct output_buffer_struct
*buf
)
2306 buf
->ptrp
= output_ptr
;
2307 buf
->buffer
= output_buffer
;
2347 #define ID copy_id()
2348 #define INT copy_int()
2349 #define EXP copy_expression()
2350 static void copy_till_end ();
2351 #define INTn(q) copy_int()
2352 #define EXPn(q) copy_expression()
2391 EXPn (instruction address
);
2425 EXPn (external function
);
2435 INTn (locked
register);
2458 /* Attribute record */
2516 static void block ();
2528 /* Unique typedefs for module */
2529 /* GLobal typedefs */
2530 /* High level module scope beginning */
2532 struct output_buffer_struct ob
;
2547 /* Global function */
2549 struct output_buffer_struct ob
;
2563 EXPn (size of block
);
2569 /* File name for source line numbers */
2571 struct output_buffer_struct ob
;
2591 /* Local function */
2593 struct output_buffer_struct ob
;
2611 /* Assembler module scope beginning -*/
2613 struct output_buffer_struct ob
;
2639 struct output_buffer_struct ob
;
2646 INTn (section index
);
2654 EXPn (Size in Maus
);
2709 moves all the debug information from the source bfd to the output
2710 bfd, and relocates any expressions it finds
2714 DEFUN (relocate_debug
, (output
, input
),
2720 unsigned char input_buffer
[IBS
];
2722 input_ptr_start
= input_ptr
= input_buffer
;
2723 input_ptr_end
= input_buffer
+ IBS
;
2725 bfd_read ((PTR
) input_ptr_start
, 1, IBS
, input
);
2730 During linking, we we told about the bfds which made up our
2731 contents, we have a list of them. They will still be open, so go to
2732 the debug info in each, and copy it out, relocating it as we go.
2736 DEFUN (ieee_write_debug_part
, (abfd
),
2739 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
2740 bfd_chain_type
*chain
= ieee
->chain_root
;
2741 unsigned char output_buffer
[OBS
];
2742 boolean some_debug
= false;
2743 file_ptr here
= bfd_tell (abfd
);
2745 output_ptr_start
= output_ptr
= output_buffer
;
2746 output_ptr_end
= output_buffer
+ OBS
;
2747 output_ptr
= output_buffer
;
2750 if (chain
== (bfd_chain_type
*) NULL
)
2753 /* There is no debug info, so we'll fake some up */
2754 CONST
static char fake
[] =
2756 0xf8, 0xa, 0, 5, 't', 't', 't', 't', 't', 0, 2, 3,
2757 '1', '.', '1', 0x82, 1991 >> 8, 1991 & 0xff, 9, 20, 11, 07, 50};
2758 ieee
->w
.r
.debug_information_part
= 0;
2764 /* bfd_write(fake, 1, sizeof(fake), abfd);*/
2765 /* Now write a header for each section */
2768 asection
*s
= abfd
->sections
;
2771 if (s
!= abfd
->abs_section
)
2774 ieee_write_byte (abfd
, 0xf8);
2775 ieee_write_byte (abfd
, 0x0b);
2776 ieee_write_byte (abfd
, 0);
2777 ieee_write_byte (abfd
, 0);
2778 ieee_write_byte (abfd
, 1);
2779 ieee_write_byte (abfd
, i
+ IEEE_SECTION_NUMBER_BASE
);
2780 ieee_write_expression (abfd
, 0, s
->symbol
, 0, 0, 0);
2781 ieee_write_byte (abfd
, 0);
2782 ieee_write_byte (abfd
, 0xf9);
2783 ieee_write_expression (abfd
, s
->size
,
2784 bfd_abs_section
.symbol
, 0, 0, 0);
2791 /* Close the scope */
2792 ieee_write_byte (abfd
, 0xf9);
2798 while (chain
!= (bfd_chain_type
*) NULL
)
2800 bfd
*entry
= chain
->this;
2801 ieee_data_type
*entry_ieee
= IEEE_DATA (entry
);
2802 if (entry_ieee
->w
.r
.debug_information_part
)
2804 bfd_seek (entry
, entry_ieee
->w
.r
.debug_information_part
, SEEK_SET
);
2805 relocate_debug (abfd
, entry
);
2808 chain
= chain
->next
;
2812 ieee
->w
.r
.debug_information_part
= here
;
2816 ieee
->w
.r
.debug_information_part
= 0;
2823 /* write the data in an ieee way */
2825 DEFUN (ieee_write_data_part
, (abfd
),
2829 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
2830 ieee
->w
.r
.data_part
= bfd_tell (abfd
);
2831 for (s
= abfd
->sections
; s
!= (asection
*) NULL
; s
= s
->next
)
2833 /* Sort the reloc records so we can insert them in the correct
2835 if (s
->reloc_count
!= 0)
2837 do_with_relocs (abfd
, s
);
2841 do_without_relocs (abfd
, s
);
2848 DEFUN (init_for_output
, (abfd
),
2852 for (s
= abfd
->sections
; s
!= (asection
*) NULL
; s
= s
->next
)
2854 if (s
->_raw_size
!= 0)
2856 ieee_per_section (s
)->data
= (bfd_byte
*) (bfd_alloc (abfd
, s
->_raw_size
));
2857 if (!ieee_per_section (s
)->data
)
2859 bfd_error
= no_memory
;
2867 /** exec and core file sections */
2869 /* set section contents is complicated with IEEE since the format is
2870 * not a byte image, but a record stream.
2873 DEFUN (ieee_set_section_contents
, (abfd
, section
, location
, offset
, count
),
2878 bfd_size_type count
)
2880 if (ieee_per_section (section
)->data
== (bfd_byte
*) NULL
)
2882 if (!init_for_output (abfd
))
2885 memcpy ((PTR
) (ieee_per_section (section
)->data
+ offset
),
2887 (unsigned int) count
);
2892 write the external symbols of a file, IEEE considers two sorts of
2893 external symbols, public, and referenced. It uses to internal forms
2894 to index them as well. When we write them out we turn their symbol
2895 values into indexes from the right base.
2898 DEFUN (ieee_write_external_part
, (abfd
),
2902 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
2904 unsigned int reference_index
= IEEE_REFERENCE_BASE
;
2905 unsigned int public_index
= IEEE_PUBLIC_BASE
+ 2;
2906 file_ptr here
= bfd_tell (abfd
);
2907 boolean hadone
= false;
2908 if (abfd
->outsymbols
!= (asymbol
**) NULL
)
2911 for (q
= abfd
->outsymbols
; *q
!= (asymbol
*) NULL
; q
++)
2915 if (p
->section
== &bfd_und_section
)
2917 /* This must be a symbol reference .. */
2918 ieee_write_byte (abfd
, ieee_external_reference_enum
);
2919 ieee_write_int (abfd
, reference_index
);
2920 ieee_write_id (abfd
, p
->name
);
2921 p
->value
= reference_index
;
2924 else if (bfd_is_com_section (p
->section
))
2926 /* This is a weak reference */
2927 ieee_write_byte (abfd
, ieee_external_reference_enum
);
2928 ieee_write_int (abfd
, reference_index
);
2929 ieee_write_id (abfd
, p
->name
);
2930 ieee_write_byte (abfd
, ieee_weak_external_reference_enum
);
2931 ieee_write_int (abfd
, reference_index
);
2932 ieee_write_int (abfd
, p
->value
);
2933 ieee_write_int (abfd
, BFD_FORT_COMM_DEFAULT_VALUE
);
2934 p
->value
= reference_index
;
2937 else if (p
->flags
& BSF_GLOBAL
)
2939 /* This must be a symbol definition */
2942 ieee_write_byte (abfd
, ieee_external_symbol_enum
);
2943 ieee_write_int (abfd
, public_index
);
2944 ieee_write_id (abfd
, p
->name
);
2946 ieee_write_twobyte (abfd
, ieee_attribute_record_enum
);
2947 ieee_write_int (abfd
, public_index
);
2948 ieee_write_byte (abfd
, 15); /* instruction address */
2949 ieee_write_byte (abfd
, 19); /* static symbol */
2950 ieee_write_byte (abfd
, 1); /* one of them */
2953 /* Write out the value */
2954 ieee_write_2bytes (abfd
, ieee_value_record_enum
);
2955 ieee_write_int (abfd
, public_index
);
2956 if (p
->section
!= &bfd_abs_section
)
2958 if (abfd
->flags
& EXEC_P
)
2960 /* If fully linked, then output all symbols
2962 ieee_write_int (abfd
,
2963 p
->value
+ p
->section
->output_offset
+ p
->section
->output_section
->vma
);
2968 ieee_write_expression (abfd
,
2969 p
->value
+ p
->section
->output_offset
,
2970 p
->section
->output_section
->symbol
2976 ieee_write_expression (abfd
,
2978 bfd_abs_section
.symbol
,
2981 p
->value
= public_index
;
2986 /* This can happen - when there are gaps in the symbols read */
2987 /* from an input ieee file */
2992 ieee
->w
.r
.external_part
= here
;
2997 static CONST
unsigned char exten
[] =
3000 0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3 */
3001 0xf1, 0xce, 0x20, 0x00, 39, 2,/* keep symbol in original case */
3002 0xf1, 0xce, 0x20, 0x00, 38 /* set object type relocateable to x */
3005 static CONST
unsigned char envi
[] =
3009 /* 0xf1, 0xce, 0x21, 00, 50, 0x82, 0x07, 0xc7, 0x09, 0x11, 0x11,
3012 0xf1, 0xce, 0x21, 00, 52, 0x00, /* exec ok */
3014 0xf1, 0xce, 0x21, 0, 53, 0x03,/* host unix */
3015 /* 0xf1, 0xce, 0x21, 0, 54, 2,1,1 tool & version # */
3020 DEFUN (ieee_write_me_part
, (abfd
),
3023 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
3024 ieee
->w
.r
.trailer_part
= bfd_tell (abfd
);
3025 if (abfd
->start_address
)
3027 ieee
->w
.r
.me_record
= bfd_tell (abfd
);
3028 ieee_write_2bytes (abfd
, ieee_value_starting_address_enum
);
3029 ieee_write_byte (abfd
, ieee_function_either_open_b_enum
);
3030 ieee_write_int (abfd
, abfd
->start_address
);
3031 ieee_write_byte (abfd
, ieee_function_either_close_b_enum
);
3035 ieee
->w
.r
.me_record
= bfd_tell (abfd
);
3037 ieee_write_byte (abfd
, ieee_module_end_enum
);
3042 DEFUN (ieee_write_object_contents
, (abfd
),
3045 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
3048 /* Fast forward over the header area */
3049 bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
);
3050 ieee_write_byte (abfd
, ieee_module_beginning_enum
);
3052 ieee_write_id (abfd
, bfd_printable_name (abfd
));
3053 ieee_write_id (abfd
, abfd
->filename
);
3055 /* Fast forward over the variable bits */
3056 ieee_write_byte (abfd
, ieee_address_descriptor_enum
);
3059 ieee_write_byte (abfd
, (bfd_byte
) (bfd_arch_bits_per_byte (abfd
)));
3060 /* MAU's per address */
3061 ieee_write_byte (abfd
,
3062 (bfd_byte
) (bfd_arch_bits_per_address (abfd
) / bfd_arch_bits_per_byte (abfd
)));
3064 old
= bfd_tell (abfd
);
3065 bfd_seek (abfd
, (file_ptr
) (8 * N_W_VARIABLES
), SEEK_CUR
);
3067 ieee
->w
.r
.extension_record
= bfd_tell (abfd
);
3068 bfd_write ((char *) exten
, 1, sizeof (exten
), abfd
);
3069 if (abfd
->flags
& EXEC_P
)
3070 ieee_write_byte (abfd
, 0x1);/* Absolute */
3072 ieee_write_byte (abfd
, 0x2);/* Relocateable */
3074 ieee
->w
.r
.environmental_record
= bfd_tell (abfd
);
3075 bfd_write ((char *) envi
, 1, sizeof (envi
), abfd
);
3079 ieee_write_section_part (abfd
);
3081 First write the symbols, this changes their values into table
3082 indeces so we cant use it after this point
3084 ieee_write_external_part (abfd
);
3085 /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
3088 /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
3092 Write any debugs we have been told about
3094 ieee_write_debug_part (abfd
);
3097 Can only write the data once the symbols have been written since
3098 the data contains relocation information which points to the
3101 ieee_write_data_part (abfd
);
3105 At the end we put the end !
3107 ieee_write_me_part (abfd
);
3110 /* Generate the header */
3111 bfd_seek (abfd
, old
, SEEK_SET
);
3113 for (i
= 0; i
< N_W_VARIABLES
; i
++)
3115 ieee_write_2bytes (abfd
, ieee_assign_value_to_variable_enum
);
3116 ieee_write_byte (abfd
, (bfd_byte
) i
);
3117 ieee_write_int5_out (abfd
, ieee
->w
.offset
[i
]);
3124 /* Native-level interface to symbols. */
3126 /* We read the symbols into a buffer, which is discarded when this
3127 function exits. We read the strings into a buffer large enough to
3128 hold them all plus all the cached symbol entries. */
3131 DEFUN (ieee_make_empty_symbol
, (abfd
),
3135 ieee_symbol_type
*new =
3136 (ieee_symbol_type
*) bfd_zmalloc (sizeof (ieee_symbol_type
));
3139 bfd_error
= no_error
;
3142 new->symbol
.the_bfd
= abfd
;
3143 return &new->symbol
;
3147 DEFUN (ieee_openr_next_archived_file
, (arch
, prev
),
3151 ieee_ar_data_type
*ar
= IEEE_AR_DATA (arch
);
3152 /* take the next one from the arch state, or reset */
3153 if (prev
== (bfd
*) NULL
)
3155 /* Reset the index - the first two entries are bogus*/
3156 ar
->element_index
= 2;
3160 ieee_ar_obstack_type
*p
= ar
->elements
+ ar
->element_index
;
3161 ar
->element_index
++;
3162 if (ar
->element_index
<= ar
->element_count
)
3164 if (p
->file_offset
!= (file_ptr
) 0)
3166 if (p
->abfd
== (bfd
*) NULL
)
3168 p
->abfd
= _bfd_create_empty_archive_element_shell (arch
);
3169 p
->abfd
->origin
= p
->file_offset
;
3176 bfd_error
= no_more_archived_files
;
3177 return (bfd
*) NULL
;
3184 ieee_find_nearest_line (abfd
,
3195 char **filename_ptr
;
3196 char **functionname_ptr
;
3203 ieee_generic_stat_arch_elt (abfd
, buf
)
3207 ieee_ar_data_type
*ar
= abfd
->my_archive
->tdata
.ieee_ar_data
;
3208 if (ar
== (ieee_ar_data_type
*) NULL
)
3210 bfd_error
= invalid_operation
;
3216 buf
->st_mode
= 0666;
3217 return !ieee_object_p (abfd
);
3222 DEFUN (ieee_sizeof_headers
, (abfd
, x
),
3231 DEFUN (ieee_bfd_debug_info_start
, (abfd
),
3238 DEFUN (ieee_bfd_debug_info_end
, (abfd
),
3245 /* Add this section to the list of sections we have debug info for, to
3246 be ready to output it at close time
3249 DEFUN (ieee_bfd_debug_info_accumulate
, (abfd
, section
),
3253 ieee_data_type
*ieee
= IEEE_DATA (section
->owner
);
3254 ieee_data_type
*output_ieee
= IEEE_DATA (abfd
);
3255 /* can only accumulate data from other ieee bfds */
3256 if (section
->owner
->xvec
!= abfd
->xvec
)
3258 /* Only bother once per bfd */
3259 if (ieee
->done_debug
== true)
3261 ieee
->done_debug
= true;
3263 /* Don't bother if there is no debug info */
3264 if (ieee
->w
.r
.debug_information_part
== 0)
3270 bfd_chain_type
*n
= (bfd_chain_type
*) bfd_alloc (abfd
, sizeof (bfd_chain_type
));
3273 bfd_error
= no_memory
;
3274 abort(); /* FIXME */
3276 n
->this = section
->owner
;
3277 n
->next
= (bfd_chain_type
*) NULL
;
3279 if (output_ieee
->chain_head
)
3281 output_ieee
->chain_head
->next
= n
;
3285 output_ieee
->chain_root
= n
;
3288 output_ieee
->chain_head
= n
;
3294 #define ieee_core_file_failing_command (char *(*)())(bfd_nullvoidptr)
3295 #define ieee_core_file_failing_signal (int (*)())bfd_0
3296 #define ieee_core_file_matches_executable_p ( FOO(boolean, (*),(bfd *, bfd *)))bfd_false
3297 #define ieee_slurp_armap bfd_true
3298 #define ieee_slurp_extended_name_table bfd_true
3299 #define ieee_truncate_arname (void (*)())bfd_nullvoidptr
3300 #define ieee_write_armap (FOO( boolean, (*),(bfd *, unsigned int, struct orl *, unsigned int, int))) bfd_nullvoidptr
3301 #define ieee_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr
3302 #define ieee_close_and_cleanup bfd_generic_close_and_cleanup
3303 #define ieee_set_arch_mach bfd_default_set_arch_mach
3304 #define ieee_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
3305 #define ieee_bfd_relax_section bfd_generic_relax_section
3306 #define ieee_bfd_reloc_type_lookup \
3307 ((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
3308 #define ieee_bfd_make_debug_symbol \
3309 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
3310 #define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
3311 #define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols
3312 #define ieee_bfd_final_link _bfd_generic_final_link
3315 bfd_target ieee_vec
=
3318 bfd_target_ieee_flavour
,
3319 true, /* target byte order */
3320 true, /* target headers byte order */
3321 (HAS_RELOC
| EXEC_P
| /* object flags */
3322 HAS_LINENO
| HAS_DEBUG
|
3323 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| D_PAGED
),
3324 (SEC_CODE
| SEC_DATA
| SEC_ROM
| SEC_HAS_CONTENTS
3325 | SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
3326 0, /* leading underscore */
3327 ' ', /* ar_pad_char */
3328 16, /* ar_max_namelen */
3329 1, /* minimum alignment */
3330 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
3331 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
3332 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* data */
3333 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
3334 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
3335 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* hdrs */
3338 ieee_object_p
, /* bfd_check_format */
3345 _bfd_generic_mkarchive
,
3350 ieee_write_object_contents
,
3351 _bfd_write_archive_contents
,