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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 ieee_write_byte (abfd
, byte
)
44 if (bfd_write ((PTR
) & byte
, 1, 1, abfd
) != 1)
49 ieee_write_twobyte (abfd
, twobyte
)
54 b
[1] = twobyte
& 0xff;
56 if (bfd_write ((PTR
) & b
[0], 1, 2, abfd
) != 2)
61 ieee_write_2bytes (abfd
, bytes
)
66 buffer
[0] = bytes
>> 8;
67 buffer
[1] = bytes
& 0xff;
69 if (bfd_write ((PTR
) buffer
, 1, 2, abfd
) != 2)
74 ieee_write_int (abfd
, value
)
78 if (((unsigned) value
) <= 127)
80 ieee_write_byte (abfd
, (bfd_byte
) value
);
85 /* How many significant bytes ? */
86 /* FIXME FOR LONGER INTS */
87 if (value
& 0xff000000)
91 else if (value
& 0x00ff0000)
95 else if (value
& 0x0000ff00)
102 ieee_write_byte (abfd
,
103 (bfd_byte
) ((int) ieee_number_repeat_start_enum
+ length
));
107 ieee_write_byte (abfd
, (bfd_byte
) (value
>> 24));
109 ieee_write_byte (abfd
, (bfd_byte
) (value
>> 16));
111 ieee_write_byte (abfd
, (bfd_byte
) (value
>> 8));
113 ieee_write_byte (abfd
, (bfd_byte
) (value
));
119 ieee_write_id (abfd
, id
)
123 size_t length
= strlen (id
);
126 ieee_write_byte (abfd
, (bfd_byte
) length
);
128 else if (length
< 255)
130 ieee_write_byte (abfd
, ieee_extension_length_1_enum
);
131 ieee_write_byte (abfd
, (bfd_byte
) length
);
133 else if (length
< 65535)
135 ieee_write_byte (abfd
, ieee_extension_length_2_enum
);
136 ieee_write_byte (abfd
, (bfd_byte
) (length
>> 8));
137 ieee_write_byte (abfd
, (bfd_byte
) (length
& 0xff));
143 if (bfd_write ((PTR
) id
, 1, length
, abfd
) != length
)
148 /***************************************************************************
149 Functions for reading from ieee files in the strange way that the
153 #define this_byte(ieee) *((ieee)->input_p)
154 #define next_byte(ieee) ((ieee)->input_p++)
155 #define this_byte_and_next(ieee) (*((ieee)->input_p++))
157 static unsigned short
159 common_header_type
*ieee
;
161 unsigned char c1
= this_byte_and_next (ieee
);
162 unsigned char c2
= this_byte_and_next (ieee
);
163 return (c1
<< 8) | c2
;
167 bfd_get_string (ieee
, string
, length
)
168 common_header_type
*ieee
;
173 for (i
= 0; i
< length
; i
++)
175 string
[i
] = this_byte_and_next (ieee
);
181 common_header_type
*ieee
;
185 length
= this_byte_and_next (ieee
);
188 /* Simple string of length 0 to 127 */
190 else if (length
== 0xde)
192 /* Length is next byte, allowing 0..255 */
193 length
= this_byte_and_next (ieee
);
195 else if (length
== 0xdf)
197 /* Length is next two bytes, allowing 0..65535 */
198 length
= this_byte_and_next (ieee
);
199 length
= (length
* 256) + this_byte_and_next (ieee
);
201 /* Buy memory and read string */
202 string
= bfd_alloc (ieee
->abfd
, length
+ 1);
205 bfd_set_error (bfd_error_no_memory
);
208 bfd_get_string (ieee
, string
, length
);
214 ieee_write_expression (abfd
, value
, symbol
, pcrel
, index
)
221 unsigned int term_count
= 0;
225 ieee_write_int (abfd
, value
);
229 if (bfd_is_com_section (symbol
->section
)
230 || bfd_is_und_section (symbol
->section
))
232 /* Def of a common symbol */
233 ieee_write_byte (abfd
, ieee_variable_X_enum
);
234 ieee_write_int (abfd
, symbol
->value
);
237 else if (! bfd_is_abs_section (symbol
->section
))
239 /* Ref to defined symbol - */
241 ieee_write_byte (abfd
, ieee_variable_R_enum
);
242 ieee_write_byte (abfd
,
243 (bfd_byte
) (symbol
->section
->index
+ IEEE_SECTION_NUMBER_BASE
));
245 if (symbol
->flags
& BSF_GLOBAL
)
247 ieee_write_byte (abfd
, ieee_variable_I_enum
);
248 ieee_write_int (abfd
, symbol
->value
);
251 else if (symbol
->flags
& (BSF_LOCAL
| BSF_SECTION_SYM
))
253 /* This is a reference to a defined local symbol,
254 We can easily do a local as a section+offset */
255 ieee_write_byte (abfd
, ieee_variable_R_enum
); /* or L */
256 ieee_write_byte (abfd
,
257 (bfd_byte
) (symbol
->section
->index
+ IEEE_SECTION_NUMBER_BASE
));
258 ieee_write_int (abfd
, symbol
->value
);
269 /* subtract the pc from here by asking for PC of this section*/
270 ieee_write_byte (abfd
, ieee_variable_P_enum
);
271 ieee_write_byte (abfd
, (bfd_byte
) (index
+ IEEE_SECTION_NUMBER_BASE
));
272 ieee_write_byte (abfd
, ieee_function_minus_enum
);
277 ieee_write_byte (abfd
, 0);
281 while (term_count
> 1)
283 ieee_write_byte (abfd
, ieee_function_plus_enum
);
290 /*****************************************************************************/
293 writes any integer into the buffer supplied and always takes 5 bytes
296 ieee_write_int5 (buffer
, value
)
300 buffer
[0] = (bfd_byte
) ieee_number_repeat_4_enum
;
301 buffer
[1] = (value
>> 24) & 0xff;
302 buffer
[2] = (value
>> 16) & 0xff;
303 buffer
[3] = (value
>> 8) & 0xff;
304 buffer
[4] = (value
>> 0) & 0xff;
308 ieee_write_int5_out (abfd
, value
)
313 ieee_write_int5 (b
, value
);
314 if (bfd_write ((PTR
) b
, 1, 5, abfd
) != 5)
319 parse_int (ieee
, value_ptr
)
320 common_header_type
*ieee
;
323 int value
= this_byte (ieee
);
325 if (value
>= 0 && value
<= 127)
331 else if (value
>= 0x80 && value
<= 0x88)
333 unsigned int count
= value
& 0xf;
338 result
= (result
<< 8) | this_byte_and_next (ieee
);
349 common_header_type
*ieee
;
353 *ok
= parse_int (ieee
, &x
);
358 must_parse_int (ieee
)
359 common_header_type
*ieee
;
362 BFD_ASSERT (parse_int (ieee
, &result
) == true);
370 ieee_symbol_index_type symbol
;
375 reloc_howto_type abs32_howto
376 = HOWTO (1, 0, 2, 32, false, 0, complain_overflow_bitfield
, 0, "abs32", true, 0xffffffff, 0xffffffff, false);
378 reloc_howto_type abs16_howto
379 = HOWTO (1, 0, 1, 16, false, 0, complain_overflow_bitfield
, 0, "abs16", true, 0x0000ffff, 0x0000ffff, false);
382 reloc_howto_type abs8_howto
383 = HOWTO (1, 0, 0, 8, false, 0, complain_overflow_bitfield
, 0, "abs8", true, 0x000000ff, 0x000000ff, false);
386 reloc_howto_type rel32_howto
387 = HOWTO (1, 0, 2, 32, true, 0, complain_overflow_signed
, 0, "rel32", true, 0xffffffff,
391 reloc_howto_type rel16_howto
392 = HOWTO (1, 0, 1, 16, true, 0, complain_overflow_signed
, 0, "rel16", true, 0x0000ffff, 0x0000ffff, false);
395 reloc_howto_type rel8_howto
396 = HOWTO (1, 0, 0, 8, true, 0, complain_overflow_signed
, 0, "rel8", true, 0x000000ff, 0x000000ff, false);
399 static ieee_symbol_index_type NOSYMBOL
=
404 parse_expression (ieee
, value
, symbol
, pcrel
, extra
, section
)
405 ieee_data_type
*ieee
;
407 ieee_symbol_index_type
*symbol
;
420 ieee_value_type stack
[10];
422 /* The stack pointer always points to the next unused location */
423 #define PUSH(x,y,z) TOS.symbol=x;TOS.section=y;TOS.value=z;INC;
424 #define POP(x,y,z) DEC;x=TOS.symbol;y=TOS.section;z=TOS.value;
425 ieee_value_type
*sp
= stack
;
429 switch (this_byte (&(ieee
->h
)))
431 case ieee_variable_P_enum
:
432 /* P variable, current program counter for section n */
435 next_byte (&(ieee
->h
));
437 section_n
= must_parse_int (&(ieee
->h
));
438 PUSH (NOSYMBOL
, bfd_abs_section_ptr
,
439 TOS
.value
= ieee
->section_table
[section_n
]->vma
+
440 ieee_per_section (ieee
->section_table
[section_n
])->pc
);
443 case ieee_variable_L_enum
:
444 /* L variable address of section N */
445 next_byte (&(ieee
->h
));
446 PUSH (NOSYMBOL
, ieee
->section_table
[must_parse_int (&(ieee
->h
))], 0);
448 case ieee_variable_R_enum
:
449 /* R variable, logical address of section module */
450 /* FIXME, this should be different to L */
451 next_byte (&(ieee
->h
));
452 PUSH (NOSYMBOL
, ieee
->section_table
[must_parse_int (&(ieee
->h
))], 0);
454 case ieee_variable_S_enum
:
455 /* S variable, size in MAUS of section module */
456 next_byte (&(ieee
->h
));
459 ieee
->section_table
[must_parse_int (&(ieee
->h
))]->_raw_size
);
461 case ieee_variable_I_enum
:
462 case ieee_variable_X_enum
:
463 /* Push the address of external variable n */
465 ieee_symbol_index_type sy
;
466 next_byte (&(ieee
->h
));
467 sy
.index
= (int) (must_parse_int (&(ieee
->h
)));
470 PUSH (sy
, bfd_und_section_ptr
, 0);
473 case ieee_function_minus_enum
:
475 bfd_vma value1
, value2
;
476 asection
*section1
, *section_dummy
;
477 ieee_symbol_index_type sy
;
478 next_byte (&(ieee
->h
));
480 POP (sy
, section1
, value1
);
481 POP (sy
, section_dummy
, value2
);
482 PUSH (sy
, section1
? section1
: section_dummy
, value1
- value2
);
485 case ieee_function_plus_enum
:
487 bfd_vma value1
, value2
;
490 ieee_symbol_index_type sy1
;
491 ieee_symbol_index_type sy2
;
492 next_byte (&(ieee
->h
));
494 POP (sy1
, section1
, value1
);
495 POP (sy2
, section2
, value2
);
496 PUSH (sy1
.letter
? sy1
: sy2
,
497 bfd_is_abs_section (section1
) ? section2
: section1
,
504 BFD_ASSERT (this_byte (&(ieee
->h
)) < (int) ieee_variable_A_enum
505 || this_byte (&(ieee
->h
)) > (int) ieee_variable_Z_enum
);
506 if (parse_int (&(ieee
->h
), &va
))
508 PUSH (NOSYMBOL
, bfd_abs_section_ptr
, va
);
513 Thats all that we can understand. As far as I can see
514 there is a bug in the Microtec IEEE output which I'm
515 using to scan, whereby the comma operator is omitted
516 sometimes in an expression, giving expressions with too
517 many terms. We can tell if that's the case by ensuring
518 that sp == stack here. If not, then we've pushed
519 something too far, so we keep adding. */
521 while (sp
!= stack
+ 1)
524 ieee_symbol_index_type sy1
;
525 POP (sy1
, section1
, *extra
);
530 POP (*symbol
, dummy
, *value
);
543 #define ieee_seek(abfd, offset) \
544 IEEE_DATA(abfd)->h.input_p = IEEE_DATA(abfd)->h.first_byte + offset
546 #define ieee_pos(abfd) IEEE_DATA(abfd)->h.input_p -IEEE_DATA(abfd)->h.first_byte
548 static unsigned int last_index
;
549 static char last_type
; /* is the index for an X or a D */
551 static ieee_symbol_type
*
561 ieee_data_type
*ieee
;
562 ieee_symbol_type
*last_symbol
;
563 unsigned int *symbol_count
;
564 ieee_symbol_type
***pptr
;
565 unsigned int *max_index
;
569 /* Need a new symbol */
570 unsigned int new_index
= must_parse_int (&(ieee
->h
));
571 if (new_index
!= last_index
|| this_type
!= last_type
)
573 ieee_symbol_type
*new_symbol
= (ieee_symbol_type
*) bfd_alloc (ieee
->h
.abfd
,
574 sizeof (ieee_symbol_type
));
577 bfd_set_error (bfd_error_no_memory
);
581 new_symbol
->index
= new_index
;
582 last_index
= new_index
;
585 *pptr
= &new_symbol
->next
;
586 if (new_index
> *max_index
)
588 *max_index
= new_index
;
590 last_type
= this_type
;
597 ieee_slurp_external_symbols (abfd
)
600 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
601 file_ptr offset
= ieee
->w
.r
.external_part
;
603 ieee_symbol_type
**prev_symbols_ptr
= &ieee
->external_symbols
;
604 ieee_symbol_type
**prev_reference_ptr
= &ieee
->external_reference
;
605 ieee_symbol_type
*symbol
= (ieee_symbol_type
*) NULL
;
606 unsigned int symbol_count
= 0;
608 last_index
= 0xffffff;
609 ieee
->symbol_table_full
= true;
611 ieee_seek (abfd
, offset
);
615 switch (this_byte (&(ieee
->h
)))
618 next_byte (&(ieee
->h
));
620 symbol
= get_symbol (abfd
, ieee
, symbol
, &symbol_count
,
622 &ieee
->external_symbol_max_index
, 'D');
626 symbol
->symbol
.the_bfd
= abfd
;
627 symbol
->symbol
.name
= read_id (&(ieee
->h
));
628 symbol
->symbol
.udata
.p
= (PTR
) NULL
;
629 symbol
->symbol
.flags
= BSF_NO_FLAGS
;
631 case ieee_external_symbol_enum
:
632 next_byte (&(ieee
->h
));
634 symbol
= get_symbol (abfd
, ieee
, symbol
, &symbol_count
,
636 &ieee
->external_symbol_max_index
, 'D');
640 BFD_ASSERT (symbol
->index
>= ieee
->external_symbol_min_index
);
642 symbol
->symbol
.the_bfd
= abfd
;
643 symbol
->symbol
.name
= read_id (&(ieee
->h
));
644 symbol
->symbol
.udata
.p
= (PTR
) NULL
;
645 symbol
->symbol
.flags
= BSF_NO_FLAGS
;
647 case ieee_attribute_record_enum
>> 8:
649 unsigned int symbol_name_index
;
650 unsigned int symbol_type_index
;
651 unsigned int symbol_attribute_def
;
653 next_byte (&(ieee
->h
)); /* Skip prefix */
654 next_byte (&(ieee
->h
));
655 symbol_name_index
= must_parse_int (&(ieee
->h
));
656 symbol_type_index
= must_parse_int (&(ieee
->h
));
657 symbol_attribute_def
= must_parse_int (&(ieee
->h
));
658 switch (symbol_attribute_def
)
661 /* Module misc; followed by two fields which describe the
662 current module block. The first fired is the type id
663 number, the second is the number of asn records
664 associated with the directive */
665 parse_int (&(ieee
->h
), &value
);
666 parse_int (&(ieee
->h
), &value
);
670 parse_int (&(ieee
->h
), &value
);
675 case ieee_value_record_enum
>> 8:
677 unsigned int symbol_name_index
;
678 ieee_symbol_index_type symbol_ignore
;
679 boolean pcrel_ignore
;
681 next_byte (&(ieee
->h
));
682 next_byte (&(ieee
->h
));
684 symbol_name_index
= must_parse_int (&(ieee
->h
));
685 parse_expression (ieee
,
686 &symbol
->symbol
.value
,
690 &symbol
->symbol
.section
);
692 symbol
->symbol
.flags
= BSF_GLOBAL
| BSF_EXPORT
;
696 case ieee_weak_external_reference_enum
:
700 next_byte (&(ieee
->h
));
701 /* Throw away the external reference index */
702 (void) must_parse_int (&(ieee
->h
));
703 /* Fetch the default size if not resolved */
704 size
= must_parse_int (&(ieee
->h
));
705 /* Fetch the defautlt value if available */
706 if (parse_int (&(ieee
->h
), &value
) == false)
710 /* This turns into a common */
711 symbol
->symbol
.section
= bfd_com_section_ptr
;
712 symbol
->symbol
.value
= size
;
716 case ieee_external_reference_enum
:
717 next_byte (&(ieee
->h
));
719 symbol
= get_symbol (abfd
, ieee
, symbol
, &symbol_count
,
721 &ieee
->external_reference_max_index
, 'X');
725 symbol
->symbol
.the_bfd
= abfd
;
726 symbol
->symbol
.name
= read_id (&(ieee
->h
));
727 symbol
->symbol
.udata
.p
= (PTR
) NULL
;
728 symbol
->symbol
.section
= bfd_und_section_ptr
;
729 symbol
->symbol
.value
= (bfd_vma
) 0;
730 symbol
->symbol
.flags
= 0;
732 BFD_ASSERT (symbol
->index
>= ieee
->external_reference_min_index
);
740 if (ieee
->external_symbol_max_index
!= 0)
742 ieee
->external_symbol_count
=
743 ieee
->external_symbol_max_index
-
744 ieee
->external_symbol_min_index
+ 1;
748 ieee
->external_symbol_count
= 0;
751 if (ieee
->external_reference_max_index
!= 0)
753 ieee
->external_reference_count
=
754 ieee
->external_reference_max_index
-
755 ieee
->external_reference_min_index
+ 1;
759 ieee
->external_reference_count
= 0;
763 ieee
->external_reference_count
+ ieee
->external_symbol_count
;
765 if (symbol_count
!= abfd
->symcount
)
767 /* There are gaps in the table -- */
768 ieee
->symbol_table_full
= false;
771 *prev_symbols_ptr
= (ieee_symbol_type
*) NULL
;
772 *prev_reference_ptr
= (ieee_symbol_type
*) NULL
;
778 ieee_slurp_symbol_table (abfd
)
781 if (IEEE_DATA (abfd
)->read_symbols
== false)
783 if (! ieee_slurp_external_symbols (abfd
))
785 IEEE_DATA (abfd
)->read_symbols
= true;
791 ieee_get_symtab_upper_bound (abfd
)
794 if (! ieee_slurp_symbol_table (abfd
))
797 return (abfd
->symcount
!= 0) ?
798 (abfd
->symcount
+ 1) * (sizeof (ieee_symbol_type
*)) : 0;
802 Move from our internal lists to the canon table, and insert in
806 extern const bfd_target ieee_vec
;
809 ieee_get_symtab (abfd
, location
)
813 ieee_symbol_type
*symp
;
814 static bfd dummy_bfd
;
815 static asymbol empty_symbol
=
816 /* the_bfd, name, value, attr, section */
817 {&dummy_bfd
, " ieee empty", (symvalue
) 0, BSF_DEBUGGING
, bfd_abs_section_ptr
};
821 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
822 dummy_bfd
.xvec
= &ieee_vec
;
823 if (! ieee_slurp_symbol_table (abfd
))
826 if (ieee
->symbol_table_full
== false)
828 /* Arrgh - there are gaps in the table, run through and fill them */
829 /* up with pointers to a null place */
831 for (i
= 0; i
< abfd
->symcount
; i
++)
833 location
[i
] = &empty_symbol
;
837 ieee
->external_symbol_base_offset
= -ieee
->external_symbol_min_index
;
838 for (symp
= IEEE_DATA (abfd
)->external_symbols
;
839 symp
!= (ieee_symbol_type
*) NULL
;
842 /* Place into table at correct index locations */
843 location
[symp
->index
+ ieee
->external_symbol_base_offset
] = &symp
->symbol
;
846 /* The external refs are indexed in a bit */
847 ieee
->external_reference_base_offset
=
848 -ieee
->external_reference_min_index
+ ieee
->external_symbol_count
;
850 for (symp
= IEEE_DATA (abfd
)->external_reference
;
851 symp
!= (ieee_symbol_type
*) NULL
;
854 location
[symp
->index
+ ieee
->external_reference_base_offset
] =
861 location
[abfd
->symcount
] = (asymbol
*) NULL
;
863 return abfd
->symcount
;
867 get_section_entry (abfd
, ieee
, index
)
869 ieee_data_type
*ieee
;
872 if (ieee
->section_table
[index
] == (asection
*) NULL
)
874 char *tmp
= bfd_alloc (abfd
, 11);
879 bfd_set_error (bfd_error_no_memory
);
882 sprintf (tmp
, " fsec%4d", index
);
883 section
= bfd_make_section (abfd
, tmp
);
884 ieee
->section_table
[index
] = section
;
885 section
->flags
= SEC_NO_FLAGS
;
886 section
->target_index
= index
;
887 ieee
->section_table
[index
] = section
;
889 return ieee
->section_table
[index
];
893 ieee_slurp_sections (abfd
)
896 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
897 file_ptr offset
= ieee
->w
.r
.section_part
;
898 asection
*section
= (asection
*) NULL
;
903 bfd_byte section_type
[3];
904 ieee_seek (abfd
, offset
);
907 switch (this_byte (&(ieee
->h
)))
909 case ieee_section_type_enum
:
911 unsigned int section_index
;
912 next_byte (&(ieee
->h
));
913 section_index
= must_parse_int (&(ieee
->h
));
914 /* Fixme to be nice about a silly number of sections */
915 BFD_ASSERT (section_index
< NSECTIONS
);
917 section
= get_section_entry (abfd
, ieee
, section_index
);
919 section_type
[0] = this_byte_and_next (&(ieee
->h
));
920 switch (section_type
[0])
923 /* Normal attributes for absolute sections */
924 section_type
[1] = this_byte (&(ieee
->h
));
925 section
->flags
= SEC_LOAD
| SEC_ALLOC
| SEC_HAS_CONTENTS
;
926 switch (section_type
[1])
928 case 0xD3: /* AS Absolute section attributes */
929 next_byte (&(ieee
->h
));
930 section_type
[2] = this_byte (&(ieee
->h
));
931 switch (section_type
[2])
935 next_byte (&(ieee
->h
));
936 section
->flags
|= SEC_LOAD
| SEC_CODE
;
939 next_byte (&(ieee
->h
));
940 section
->flags
|= SEC_LOAD
| SEC_DATA
;
944 next_byte (&(ieee
->h
));
945 /* Normal rom data */
946 section
->flags
|= SEC_LOAD
| SEC_ROM
| SEC_DATA
;
953 case 0xC3: /* Named relocatable sections (type C) */
954 section_type
[1] = this_byte (&(ieee
->h
));
955 section
->flags
= SEC_LOAD
| SEC_ALLOC
| SEC_HAS_CONTENTS
;
956 switch (section_type
[1])
958 case 0xD0: /* Normal code (CP) */
959 next_byte (&(ieee
->h
));
960 section
->flags
|= SEC_LOAD
| SEC_CODE
;
962 case 0xC4: /* Normal data (CD) */
963 next_byte (&(ieee
->h
));
964 section
->flags
|= SEC_LOAD
| SEC_DATA
;
966 case 0xD2: /* Normal rom data (CR) */
967 next_byte (&(ieee
->h
));
968 section
->flags
|= SEC_LOAD
| SEC_ROM
| SEC_DATA
;
975 /* Read section name, use it if non empty. */
976 name
= read_id (&ieee
->h
);
978 section
->name
= name
;
980 /* Skip these fields, which we don't care about */
982 bfd_vma parent
, brother
, context
;
983 parse_int (&(ieee
->h
), &parent
);
984 parse_int (&(ieee
->h
), &brother
);
985 parse_int (&(ieee
->h
), &context
);
989 case ieee_section_alignment_enum
:
991 unsigned int section_index
;
994 next_byte (&(ieee
->h
));
995 section_index
= must_parse_int (&ieee
->h
);
996 section
= get_section_entry (abfd
, ieee
, section_index
);
997 if (section_index
> ieee
->section_count
)
999 ieee
->section_count
= section_index
;
1001 section
->alignment_power
=
1002 bfd_log2 (must_parse_int (&ieee
->h
));
1003 (void) parse_int (&(ieee
->h
), &value
);
1006 case ieee_e2_first_byte_enum
:
1008 ieee_record_enum_type t
= (ieee_record_enum_type
) (read_2bytes (&(ieee
->h
)));
1012 case ieee_section_size_enum
:
1013 section
= ieee
->section_table
[must_parse_int (&(ieee
->h
))];
1014 section
->_raw_size
= must_parse_int (&(ieee
->h
));
1016 case ieee_physical_region_size_enum
:
1017 section
= ieee
->section_table
[must_parse_int (&(ieee
->h
))];
1018 section
->_raw_size
= must_parse_int (&(ieee
->h
));
1020 case ieee_region_base_address_enum
:
1021 section
= ieee
->section_table
[must_parse_int (&(ieee
->h
))];
1022 section
->vma
= must_parse_int (&(ieee
->h
));
1024 case ieee_mau_size_enum
:
1025 must_parse_int (&(ieee
->h
));
1026 must_parse_int (&(ieee
->h
));
1028 case ieee_m_value_enum
:
1029 must_parse_int (&(ieee
->h
));
1030 must_parse_int (&(ieee
->h
));
1032 case ieee_section_base_address_enum
:
1033 section
= ieee
->section_table
[must_parse_int (&(ieee
->h
))];
1034 section
->vma
= must_parse_int (&(ieee
->h
));
1036 case ieee_section_offset_enum
:
1037 (void) must_parse_int (&(ieee
->h
));
1038 (void) must_parse_int (&(ieee
->h
));
1053 /***********************************************************************
1058 ieee_archive_p (abfd
)
1065 unsigned char buffer
[512];
1067 file_ptr buffer_offset
= 0;
1068 ieee_ar_data_type
*save
= abfd
->tdata
.ieee_ar_data
;
1069 ieee_ar_data_type
*ieee
;
1070 abfd
->tdata
.ieee_ar_data
= (ieee_ar_data_type
*) bfd_alloc (abfd
, sizeof (ieee_ar_data_type
));
1071 if (!abfd
->tdata
.ieee_ar_data
)
1073 bfd_set_error (bfd_error_no_memory
);
1076 ieee
= IEEE_AR_DATA (abfd
);
1078 /* FIXME: Check return value. I'm not sure whether it needs to read
1079 the entire buffer or not. */
1080 bfd_read ((PTR
) buffer
, 1, sizeof (buffer
), abfd
);
1082 ieee
->h
.first_byte
= buffer
;
1083 ieee
->h
.input_p
= buffer
;
1085 ieee
->h
.abfd
= abfd
;
1087 if (this_byte (&(ieee
->h
)) != Module_Beginning
)
1089 abfd
->tdata
.ieee_ar_data
= save
;
1090 return (const bfd_target
*) NULL
;
1093 next_byte (&(ieee
->h
));
1094 library
= read_id (&(ieee
->h
));
1095 if (strcmp (library
, "LIBRARY") != 0)
1097 bfd_release (abfd
, ieee
);
1098 abfd
->tdata
.ieee_ar_data
= save
;
1099 return (const bfd_target
*) NULL
;
1101 /* Throw away the filename */
1102 read_id (&(ieee
->h
));
1103 /* This must be an IEEE archive, so we'll buy some space to do
1106 if (!obstack_begin (&ob
, 128))
1108 bfd_set_error (bfd_error_no_memory
);
1109 return (const bfd_target
*) NULL
;
1112 ieee
->element_count
= 0;
1113 ieee
->element_index
= 0;
1115 next_byte (&(ieee
->h
)); /* Drop the ad part */
1116 must_parse_int (&(ieee
->h
)); /* And the two dummy numbers */
1117 must_parse_int (&(ieee
->h
));
1120 /* Read the index of the BB table */
1123 ieee_ar_obstack_type t
;
1124 int rec
= read_2bytes (&(ieee
->h
));
1125 if (rec
== (int) ieee_assign_value_to_variable_enum
)
1127 must_parse_int (&(ieee
->h
));
1128 t
.file_offset
= must_parse_int (&(ieee
->h
));
1129 t
.abfd
= (bfd
*) NULL
;
1130 ieee
->element_count
++;
1132 obstack_grow (&ob
, (PTR
) & t
, sizeof (t
));
1134 /* Make sure that we don't go over the end of the buffer */
1136 if (ieee_pos (abfd
) > sizeof (buffer
) / 2)
1138 /* Past half way, reseek and reprime */
1139 buffer_offset
+= ieee_pos (abfd
);
1140 if (bfd_seek (abfd
, buffer_offset
, SEEK_SET
) != 0)
1142 /* FIXME: Check return value. I'm not sure whether it
1143 needs to read the entire buffer or not. */
1144 bfd_read ((PTR
) buffer
, 1, sizeof (buffer
), abfd
);
1145 ieee
->h
.first_byte
= buffer
;
1146 ieee
->h
.input_p
= buffer
;
1153 ieee
->elements
= (ieee_ar_obstack_type
*) obstack_finish (&ob
);
1154 if (!ieee
->elements
)
1156 bfd_set_error (bfd_error_no_memory
);
1157 return (const bfd_target
*) NULL
;
1160 /* Now scan the area again, and replace BB offsets with file */
1163 for (i
= 2; i
< ieee
->element_count
; i
++)
1165 if (bfd_seek (abfd
, ieee
->elements
[i
].file_offset
, SEEK_SET
) != 0)
1167 /* FIXME: Check return value. I'm not sure whether it needs to
1168 read the entire buffer or not. */
1169 bfd_read ((PTR
) buffer
, 1, sizeof (buffer
), abfd
);
1170 ieee
->h
.first_byte
= buffer
;
1171 ieee
->h
.input_p
= buffer
;
1173 next_byte (&(ieee
->h
)); /* Drop F8 */
1174 next_byte (&(ieee
->h
)); /* Drop 14 */
1175 must_parse_int (&(ieee
->h
)); /* Drop size of block */
1176 if (must_parse_int (&(ieee
->h
)) != 0)
1178 /* This object has been deleted */
1179 ieee
->elements
[i
].file_offset
= 0;
1183 ieee
->elements
[i
].file_offset
= must_parse_int (&(ieee
->h
));
1187 /* abfd->has_armap = ;*/
1192 ieee_mkobject (abfd
)
1195 abfd
->tdata
.ieee_data
= (ieee_data_type
*) bfd_zalloc (abfd
, sizeof (ieee_data_type
));
1196 return abfd
->tdata
.ieee_data
? true : false;
1200 ieee_object_p (abfd
)
1205 ieee_data_type
*ieee
;
1206 unsigned char buffer
[300];
1207 ieee_data_type
*save
= IEEE_DATA (abfd
);
1209 abfd
->tdata
.ieee_data
= 0;
1210 ieee_mkobject (abfd
);
1212 ieee
= IEEE_DATA (abfd
);
1213 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0)
1215 /* Read the first few bytes in to see if it makes sense */
1216 /* FIXME: Check return value. I'm not sure whether it needs to read
1217 the entire buffer or not. */
1218 bfd_read ((PTR
) buffer
, 1, sizeof (buffer
), abfd
);
1220 ieee
->h
.input_p
= buffer
;
1221 if (this_byte_and_next (&(ieee
->h
)) != Module_Beginning
)
1222 goto got_wrong_format
;
1224 ieee
->read_symbols
= false;
1225 ieee
->read_data
= false;
1226 ieee
->section_count
= 0;
1227 ieee
->external_symbol_max_index
= 0;
1228 ieee
->external_symbol_min_index
= IEEE_PUBLIC_BASE
;
1229 ieee
->external_reference_min_index
= IEEE_REFERENCE_BASE
;
1230 ieee
->external_reference_max_index
= 0;
1231 ieee
->h
.abfd
= abfd
;
1232 memset ((PTR
) ieee
->section_table
, 0, sizeof (ieee
->section_table
));
1234 processor
= ieee
->mb
.processor
= read_id (&(ieee
->h
));
1235 if (strcmp (processor
, "LIBRARY") == 0)
1236 goto got_wrong_format
;
1237 ieee
->mb
.module_name
= read_id (&(ieee
->h
));
1238 if (abfd
->filename
== (CONST
char *) NULL
)
1240 abfd
->filename
= ieee
->mb
.module_name
;
1242 /* Determine the architecture and machine type of the object file.
1245 bfd_arch_info_type
*arch
= bfd_scan_arch (processor
);
1247 goto got_wrong_format
;
1248 abfd
->arch_info
= arch
;
1251 if (this_byte (&(ieee
->h
)) != (int) ieee_address_descriptor_enum
)
1255 next_byte (&(ieee
->h
));
1257 if (parse_int (&(ieee
->h
), &ieee
->ad
.number_of_bits_mau
) == false)
1261 if (parse_int (&(ieee
->h
), &ieee
->ad
.number_of_maus_in_address
) == false)
1266 /* If there is a byte order info, take it */
1267 if (this_byte (&(ieee
->h
)) == (int) ieee_variable_L_enum
||
1268 this_byte (&(ieee
->h
)) == (int) ieee_variable_M_enum
)
1269 next_byte (&(ieee
->h
));
1271 for (part
= 0; part
< N_W_VARIABLES
; part
++)
1274 if (read_2bytes (&(ieee
->h
)) != (int) ieee_assign_value_to_variable_enum
)
1278 if (this_byte_and_next (&(ieee
->h
)) != part
)
1283 ieee
->w
.offset
[part
] = parse_i (&(ieee
->h
), &ok
);
1290 abfd
->flags
= HAS_SYMS
;
1291 /* By now we know that this is a real IEEE file, we're going to read
1292 the whole thing into memory so that we can run up and down it
1293 quickly. We can work out how big the file is from the trailer
1296 IEEE_DATA (abfd
)->h
.first_byte
= (unsigned char *) bfd_alloc (ieee
->h
.abfd
, ieee
->w
.r
.me_record
1298 if (!IEEE_DATA (abfd
)->h
.first_byte
)
1300 bfd_set_error (bfd_error_no_memory
);
1303 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0)
1305 /* FIXME: Check return value. I'm not sure whether it needs to read
1306 the entire buffer or not. */
1307 bfd_read ((PTR
) (IEEE_DATA (abfd
)->h
.first_byte
), 1, ieee
->w
.r
.me_record
+ 50, abfd
);
1309 ieee_slurp_sections (abfd
);
1312 bfd_set_error (bfd_error_wrong_format
);
1314 (void) bfd_release (abfd
, ieee
);
1315 abfd
->tdata
.ieee_data
= save
;
1316 return (const bfd_target
*) NULL
;
1320 ieee_get_symbol_info (ignore_abfd
, symbol
, ret
)
1325 bfd_symbol_info (symbol
, ret
);
1326 if (symbol
->name
[0] == ' ')
1327 ret
->name
= "* empty table entry ";
1328 if (!symbol
->section
)
1329 ret
->type
= (symbol
->flags
& BSF_LOCAL
) ? 'a' : 'A';
1333 ieee_print_symbol (ignore_abfd
, afile
, symbol
, how
)
1337 bfd_print_symbol_type how
;
1339 FILE *file
= (FILE *) afile
;
1343 case bfd_print_symbol_name
:
1344 fprintf (file
, "%s", symbol
->name
);
1346 case bfd_print_symbol_more
:
1348 fprintf (file
, "%4x %2x", aout_symbol (symbol
)->desc
& 0xffff,
1349 aout_symbol (symbol
)->other
& 0xff);
1353 case bfd_print_symbol_all
:
1355 CONST
char *section_name
= symbol
->section
== (asection
*) NULL
?
1356 (CONST
char *) "*abs" : symbol
->section
->name
;
1357 if (symbol
->name
[0] == ' ')
1359 fprintf (file
, "* empty table entry ");
1363 bfd_print_symbol_vandf ((PTR
) file
, symbol
);
1365 fprintf (file
, " %-5s %04x %02x %s",
1367 (unsigned) ieee_symbol (symbol
)->index
,
1369 aout_symbol(symbol)->desc & 0xffff,
1370 aout_symbol(symbol)->other & 0xff,*/
1379 do_one (ieee
, current_map
, location_ptr
, s
)
1380 ieee_data_type
*ieee
;
1381 ieee_per_section_type
*current_map
;
1382 unsigned char *location_ptr
;
1385 switch (this_byte (&(ieee
->h
)))
1387 case ieee_load_constant_bytes_enum
:
1389 unsigned int number_of_maus
;
1391 next_byte (&(ieee
->h
));
1392 number_of_maus
= must_parse_int (&(ieee
->h
));
1394 for (i
= 0; i
< number_of_maus
; i
++)
1396 location_ptr
[current_map
->pc
++] = this_byte (&(ieee
->h
));
1397 next_byte (&(ieee
->h
));
1402 case ieee_load_with_relocation_enum
:
1404 boolean loop
= true;
1405 next_byte (&(ieee
->h
));
1408 switch (this_byte (&(ieee
->h
)))
1410 case ieee_variable_R_enum
:
1412 case ieee_function_signed_open_b_enum
:
1413 case ieee_function_unsigned_open_b_enum
:
1414 case ieee_function_either_open_b_enum
:
1416 unsigned int extra
= 4;
1417 boolean pcrel
= false;
1419 ieee_reloc_type
*r
=
1420 (ieee_reloc_type
*) bfd_alloc (ieee
->h
.abfd
,
1421 sizeof (ieee_reloc_type
));
1424 bfd_set_error (bfd_error_no_memory
);
1428 *(current_map
->reloc_tail_ptr
) = r
;
1429 current_map
->reloc_tail_ptr
= &r
->next
;
1430 r
->next
= (ieee_reloc_type
*) NULL
;
1431 next_byte (&(ieee
->h
));
1433 r
->relent
.sym_ptr_ptr
= 0;
1434 parse_expression (ieee
,
1437 &pcrel
, &extra
, §ion
);
1438 r
->relent
.address
= current_map
->pc
;
1440 if (r
->relent
.sym_ptr_ptr
== 0)
1442 r
->relent
.sym_ptr_ptr
= section
->symbol_ptr_ptr
;
1445 if (this_byte (&(ieee
->h
)) == (int) ieee_comma
)
1447 next_byte (&(ieee
->h
));
1448 /* Fetch number of bytes to pad */
1449 extra
= must_parse_int (&(ieee
->h
));
1452 switch (this_byte (&(ieee
->h
)))
1454 case ieee_function_signed_close_b_enum
:
1455 next_byte (&(ieee
->h
));
1457 case ieee_function_unsigned_close_b_enum
:
1458 next_byte (&(ieee
->h
));
1460 case ieee_function_either_close_b_enum
:
1461 next_byte (&(ieee
->h
));
1466 /* Build a relocation entry for this type */
1467 /* If pc rel then stick -ve pc into instruction
1468 and take out of reloc ..
1470 I've changed this. It's all too
1471 complicated. I keep 0 in the
1482 #if KEEPMINUSPCININST
1483 bfd_put_32 (ieee
->h
.abfd
, -current_map
->pc
, location_ptr
+
1485 r
->relent
.howto
= &rel32_howto
;
1489 bfd_put_32 (ieee
->h
.abfd
, 0, location_ptr
+
1491 r
->relent
.howto
= &rel32_howto
;
1496 bfd_put_32 (ieee
->h
.abfd
, 0, location_ptr
+
1498 r
->relent
.howto
= &abs32_howto
;
1500 current_map
->pc
+= 4;
1505 #if KEEPMINUSPCININST
1506 bfd_put_16 (ieee
->h
.abfd
, (int) (-current_map
->pc
), location_ptr
+ current_map
->pc
);
1507 r
->relent
.addend
-= current_map
->pc
;
1508 r
->relent
.howto
= &rel16_howto
;
1511 bfd_put_16 (ieee
->h
.abfd
, 0, location_ptr
+ current_map
->pc
);
1512 r
->relent
.howto
= &rel16_howto
;
1518 bfd_put_16 (ieee
->h
.abfd
, 0, location_ptr
+ current_map
->pc
);
1519 r
->relent
.howto
= &abs16_howto
;
1521 current_map
->pc
+= 2;
1526 #if KEEPMINUSPCININST
1527 bfd_put_8 (ieee
->h
.abfd
, (int) (-current_map
->pc
), location_ptr
+ current_map
->pc
);
1528 r
->relent
.addend
-= current_map
->pc
;
1529 r
->relent
.howto
= &rel8_howto
;
1531 bfd_put_8 (ieee
->h
.abfd
, 0, location_ptr
+ current_map
->pc
);
1532 r
->relent
.howto
= &rel8_howto
;
1537 bfd_put_8 (ieee
->h
.abfd
, 0, location_ptr
+ current_map
->pc
);
1538 r
->relent
.howto
= &abs8_howto
;
1540 current_map
->pc
+= 1;
1552 if (parse_int (&(ieee
->h
), &this_size
) == true)
1555 for (i
= 0; i
< this_size
; i
++)
1557 location_ptr
[current_map
->pc
++] = this_byte (&(ieee
->h
));
1558 next_byte (&(ieee
->h
));
1573 /* Read in all the section data and relocation stuff too */
1575 ieee_slurp_section_data (abfd
)
1578 bfd_byte
*location_ptr
= (bfd_byte
*) NULL
;
1579 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
1580 unsigned int section_number
;
1582 ieee_per_section_type
*current_map
= (ieee_per_section_type
*) NULL
;
1584 /* Seek to the start of the data area */
1585 if (ieee
->read_data
== true)
1587 ieee
->read_data
= true;
1588 ieee_seek (abfd
, ieee
->w
.r
.data_part
);
1590 /* Allocate enough space for all the section contents */
1592 for (s
= abfd
->sections
; s
!= (asection
*) NULL
; s
= s
->next
)
1594 ieee_per_section_type
*per
= (ieee_per_section_type
*) s
->used_by_bfd
;
1595 per
->data
= (bfd_byte
*) bfd_alloc (ieee
->h
.abfd
, s
->_raw_size
);
1598 bfd_set_error (bfd_error_no_memory
);
1602 per
->reloc_tail_ptr
=
1603 (ieee_reloc_type
**) & (s
->relocation
);
1608 switch (this_byte (&(ieee
->h
)))
1610 /* IF we see anything strange then quit */
1614 case ieee_set_current_section_enum
:
1615 next_byte (&(ieee
->h
));
1616 section_number
= must_parse_int (&(ieee
->h
));
1617 s
= ieee
->section_table
[section_number
];
1618 current_map
= (ieee_per_section_type
*) s
->used_by_bfd
;
1619 location_ptr
= current_map
->data
- s
->vma
;
1620 /* The document I have says that Microtec's compilers reset */
1621 /* this after a sec section, even though the standard says not */
1623 current_map
->pc
= s
->vma
;
1626 case ieee_e2_first_byte_enum
:
1627 next_byte (&(ieee
->h
));
1628 switch (this_byte (&(ieee
->h
)))
1630 case ieee_set_current_pc_enum
& 0xff:
1633 ieee_symbol_index_type symbol
;
1636 next_byte (&(ieee
->h
));
1637 must_parse_int (&(ieee
->h
)); /* Thow away section #*/
1638 parse_expression (ieee
, &value
,
1642 current_map
->pc
= value
;
1643 BFD_ASSERT ((unsigned) (value
- s
->vma
) <= s
->_raw_size
);
1647 case ieee_value_starting_address_enum
& 0xff:
1648 /* We've got to the end of the data now - */
1655 case ieee_repeat_data_enum
:
1657 /* Repeat the following LD or LR n times - we do this by
1658 remembering the stream pointer before running it and
1659 resetting it and running it n times. We special case
1660 the repetition of a repeat_data/load_constant
1663 unsigned int iterations
;
1664 unsigned char *start
;
1665 next_byte (&(ieee
->h
));
1666 iterations
= must_parse_int (&(ieee
->h
));
1667 start
= ieee
->h
.input_p
;
1668 if (start
[0] == (int) ieee_load_constant_bytes_enum
&&
1671 while (iterations
!= 0)
1673 location_ptr
[current_map
->pc
++] = start
[2];
1676 next_byte (&(ieee
->h
));
1677 next_byte (&(ieee
->h
));
1678 next_byte (&(ieee
->h
));
1682 while (iterations
!= 0)
1684 ieee
->h
.input_p
= start
;
1685 if (!do_one (ieee
, current_map
, location_ptr
, s
))
1692 case ieee_load_constant_bytes_enum
:
1693 case ieee_load_with_relocation_enum
:
1695 if (!do_one (ieee
, current_map
, location_ptr
, s
))
1703 ieee_new_section_hook (abfd
, newsect
)
1707 newsect
->used_by_bfd
= (PTR
)
1708 bfd_alloc (abfd
, sizeof (ieee_per_section_type
));
1709 if (!newsect
->used_by_bfd
)
1711 bfd_set_error (bfd_error_no_memory
);
1714 ieee_per_section (newsect
)->data
= (bfd_byte
*) NULL
;
1715 ieee_per_section (newsect
)->section
= newsect
;
1720 ieee_get_reloc_upper_bound (abfd
, asect
)
1724 if (! ieee_slurp_section_data (abfd
))
1726 return (asect
->reloc_count
+ 1) * sizeof (arelent
*);
1730 ieee_get_section_contents (abfd
, section
, location
, offset
, count
)
1735 bfd_size_type count
;
1737 ieee_per_section_type
*p
= (ieee_per_section_type
*) section
->used_by_bfd
;
1738 ieee_slurp_section_data (abfd
);
1739 (void) memcpy ((PTR
) location
, (PTR
) (p
->data
+ offset
), (unsigned) count
);
1744 ieee_canonicalize_reloc (abfd
, section
, relptr
, symbols
)
1750 /* ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/
1751 ieee_reloc_type
*src
= (ieee_reloc_type
*) (section
->relocation
);
1752 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
1754 while (src
!= (ieee_reloc_type
*) NULL
)
1756 /* Work out which symbol to attach it this reloc to */
1757 switch (src
->symbol
.letter
)
1760 src
->relent
.sym_ptr_ptr
=
1761 symbols
+ src
->symbol
.index
+ ieee
->external_reference_base_offset
;
1764 src
->relent
.sym_ptr_ptr
=
1765 src
->relent
.sym_ptr_ptr
[0]->section
->symbol_ptr_ptr
;
1771 *relptr
++ = &src
->relent
;
1774 *relptr
= (arelent
*) NULL
;
1775 return section
->reloc_count
;
1783 arelent
*a
= *((arelent
**) ap
);
1784 arelent
*b
= *((arelent
**) bp
);
1785 return a
->address
- b
->address
;
1789 Write the section headers
1793 ieee_write_section_part (abfd
)
1796 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
1798 ieee
->w
.r
.section_part
= bfd_tell (abfd
);
1799 for (s
= abfd
->sections
; s
!= (asection
*) NULL
; s
= s
->next
)
1801 if (! bfd_is_abs_section (s
))
1803 ieee_write_byte (abfd
, ieee_section_type_enum
);
1804 ieee_write_byte (abfd
, (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
1806 if (abfd
->flags
& EXEC_P
)
1808 /* This image is executable, so output absolute sections */
1809 ieee_write_byte (abfd
, ieee_variable_A_enum
);
1810 ieee_write_byte (abfd
, ieee_variable_S_enum
);
1814 ieee_write_byte (abfd
, ieee_variable_C_enum
);
1817 switch (s
->flags
& (SEC_CODE
| SEC_DATA
| SEC_ROM
))
1819 case SEC_CODE
| SEC_LOAD
:
1821 ieee_write_byte (abfd
, ieee_variable_P_enum
);
1825 ieee_write_byte (abfd
, ieee_variable_D_enum
);
1828 case SEC_ROM
| SEC_DATA
:
1829 case SEC_ROM
| SEC_LOAD
:
1830 case SEC_ROM
| SEC_DATA
| SEC_LOAD
:
1832 ieee_write_byte (abfd
, ieee_variable_R_enum
);
1836 ieee_write_id (abfd
, s
->name
);
1838 ieee_write_int (abfd
, 0); /* Parent */
1839 ieee_write_int (abfd
, 0); /* Brother */
1840 ieee_write_int (abfd
, 0); /* Context */
1843 ieee_write_byte (abfd
, ieee_section_alignment_enum
);
1844 ieee_write_byte (abfd
, (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
1845 ieee_write_int (abfd
, 1 << s
->alignment_power
);
1848 ieee_write_2bytes (abfd
, ieee_section_size_enum
);
1849 ieee_write_byte (abfd
, (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
1850 ieee_write_int (abfd
, s
->_raw_size
);
1851 if (abfd
->flags
& EXEC_P
)
1853 /* Relocateable sections don't have asl records */
1855 ieee_write_2bytes (abfd
, ieee_section_base_address_enum
);
1856 ieee_write_byte (abfd
,
1857 (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
1858 ieee_write_int (abfd
, s
->vma
);
1867 do_with_relocs (abfd
, s
)
1871 unsigned int relocs_to_go
= s
->reloc_count
;
1873 bfd_byte
*stream
= ieee_per_section (s
)->data
;
1874 arelent
**p
= s
->orelocation
;
1876 bfd_size_type current_byte_index
= 0;
1878 qsort (s
->orelocation
,
1880 sizeof (arelent
**),
1883 /* Output the section preheader */
1884 ieee_write_byte (abfd
, ieee_set_current_section_enum
);
1885 ieee_write_byte (abfd
, (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
1887 ieee_write_twobyte (abfd
, ieee_set_current_pc_enum
);
1888 ieee_write_byte (abfd
, (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
1889 ieee_write_expression (abfd
, 0, s
->symbol
, 0, 0);
1891 if (relocs_to_go
== 0)
1893 /* If there arn't any relocations then output the load constant byte
1894 opcode rather than the load with relocation opcode */
1896 while (current_byte_index
< s
->_raw_size
)
1899 unsigned int MAXRUN
= 32;
1901 if (run
> s
->_raw_size
- current_byte_index
)
1903 run
= s
->_raw_size
- current_byte_index
;
1908 ieee_write_byte (abfd
, ieee_load_constant_bytes_enum
);
1909 /* Output a stream of bytes */
1910 ieee_write_int (abfd
, run
);
1911 if (bfd_write ((PTR
) (stream
+ current_byte_index
),
1917 current_byte_index
+= run
;
1923 ieee_write_byte (abfd
, ieee_load_with_relocation_enum
);
1926 /* Output the data stream as the longest sequence of bytes
1927 possible, allowing for the a reasonable packet size and
1928 relocation stuffs */
1930 if ((PTR
) stream
== (PTR
) NULL
)
1932 /* Outputting a section without data, fill it up */
1933 stream
= (unsigned char *) (bfd_alloc (abfd
, s
->_raw_size
));
1936 bfd_set_error (bfd_error_no_memory
);
1939 memset ((PTR
) stream
, 0, s
->_raw_size
);
1941 while (current_byte_index
< s
->_raw_size
)
1944 unsigned int MAXRUN
= 32;
1947 run
= (*p
)->address
- current_byte_index
;
1953 if (run
> s
->_raw_size
- current_byte_index
)
1955 run
= s
->_raw_size
- current_byte_index
;
1960 /* Output a stream of bytes */
1961 ieee_write_int (abfd
, run
);
1962 if (bfd_write ((PTR
) (stream
+ current_byte_index
),
1968 current_byte_index
+= run
;
1970 /* Output any relocations here */
1971 if (relocs_to_go
&& (*p
) && (*p
)->address
== current_byte_index
)
1973 while (relocs_to_go
&& (*p
) && (*p
)->address
== current_byte_index
)
1980 if (r
->howto
->pc_relative
)
1982 r
->addend
+= current_byte_index
;
1986 switch (r
->howto
->size
)
1990 ov
= bfd_get_32 (abfd
,
1991 stream
+ current_byte_index
);
1992 current_byte_index
+= 4;
1995 ov
= bfd_get_16 (abfd
,
1996 stream
+ current_byte_index
);
1997 current_byte_index
+= 2;
2000 ov
= bfd_get_8 (abfd
,
2001 stream
+ current_byte_index
);
2002 current_byte_index
++;
2008 ieee_write_byte (abfd
, ieee_function_either_open_b_enum
);
2011 if (r
->sym_ptr_ptr
!= (asymbol
**) NULL
)
2013 ieee_write_expression (abfd
, r
->addend
+ ov
,
2015 r
->howto
->pc_relative
, s
->index
);
2019 ieee_write_expression (abfd
, r
->addend
+ ov
,
2021 r
->howto
->pc_relative
, s
->index
);
2024 if (1 || r
->howto
->size
!= 2)
2026 ieee_write_byte (abfd
, ieee_comma
);
2027 ieee_write_int (abfd
, 1 << r
->howto
->size
);
2029 ieee_write_byte (abfd
,
2030 ieee_function_either_close_b_enum
);
2042 /* If there are no relocations in the output section then we can
2043 be clever about how we write. We block items up into a max of 127
2047 do_as_repeat (abfd
, s
)
2053 ieee_write_byte (abfd
, ieee_set_current_section_enum
);
2054 ieee_write_byte (abfd
, (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
2055 ieee_write_byte (abfd
, ieee_set_current_pc_enum
>> 8);
2056 ieee_write_byte (abfd
, ieee_set_current_pc_enum
& 0xff);
2057 ieee_write_byte (abfd
, (bfd_byte
) (s
->index
+ IEEE_SECTION_NUMBER_BASE
));
2058 ieee_write_int (abfd
, s
->vma
);
2060 ieee_write_byte (abfd
, ieee_repeat_data_enum
);
2061 ieee_write_int (abfd
, s
->_raw_size
);
2062 ieee_write_byte (abfd
, ieee_load_constant_bytes_enum
);
2063 ieee_write_byte (abfd
, 1);
2064 ieee_write_byte (abfd
, 0);
2069 do_without_relocs (abfd
, s
)
2073 bfd_byte
*stream
= ieee_per_section (s
)->data
;
2075 if (stream
== 0 || ((s
->flags
& SEC_LOAD
) == 0))
2077 do_as_repeat (abfd
, s
);
2082 for (i
= 0; i
< s
->_raw_size
; i
++)
2086 do_with_relocs (abfd
, s
);
2090 do_as_repeat (abfd
, s
);
2096 static unsigned char *output_ptr_start
;
2097 static unsigned char *output_ptr
;
2098 static unsigned char *output_ptr_end
;
2099 static unsigned char *input_ptr_start
;
2100 static unsigned char *input_ptr
;
2101 static unsigned char *input_ptr_end
;
2102 static bfd
*input_bfd
;
2103 static bfd
*output_bfd
;
2104 static int output_buffer
;
2109 /* FIXME: Check return value. I'm not sure whether it needs to read
2110 the entire buffer or not. */
2111 bfd_read ((PTR
) input_ptr_start
, 1, input_ptr_end
- input_ptr_start
, input_bfd
);
2112 input_ptr
= input_ptr_start
;
2117 if (bfd_write ((PTR
) (output_ptr_start
), 1, output_ptr
- output_ptr_start
,
2119 != output_ptr
- output_ptr_start
)
2121 output_ptr
= output_ptr_start
;
2125 #define THIS() ( *input_ptr )
2126 #define NEXT() { input_ptr++; if (input_ptr == input_ptr_end) fill(); }
2127 #define OUT(x) { *output_ptr++ = (x); if(output_ptr == output_ptr_end) flush(); }
2133 if (value
>= 0 && value
<= 127)
2139 unsigned int length
;
2140 /* How many significant bytes ? */
2141 /* FIXME FOR LONGER INTS */
2142 if (value
& 0xff000000)
2146 else if (value
& 0x00ff0000)
2150 else if (value
& 0x0000ff00)
2157 OUT ((int) ieee_number_repeat_start_enum
+ length
);
2176 int length
= THIS ();
2188 #define VAR(x) ((x | 0x80))
2203 value
= (value
<< 8) | THIS ();
2205 value
= (value
<< 8) | THIS ();
2207 value
= (value
<< 8) | THIS ();
2215 value
= (value
<< 8) | THIS ();
2217 value
= (value
<< 8) | THIS ();
2225 value
= (value
<< 8) | THIS ();
2242 /* Not a number, just bug out with the answer */
2243 write_int (*(--tos
));
2253 int value
= *(--tos
);
2262 ieee_data_type
*ieee
;
2265 section_number
= THIS ();
2268 ieee
= IEEE_DATA (input_bfd
);
2269 s
= ieee
->section_table
[section_number
];
2270 if (s
->output_section
)
2272 value
= s
->output_section
->vma
;
2278 value
+= s
->output_offset
;
2286 write_int (*(--tos
));
2296 /* Drop the int in the buffer, and copy a null into the gap, which we
2297 will overwrite later */
2299 struct output_buffer_struct
2301 unsigned char *ptrp
;
2307 struct output_buffer_struct
*buf
;
2309 if (buf
->buffer
== output_buffer
)
2311 /* Still a chance to output the size */
2312 int value
= output_ptr
- buf
->ptrp
+ 3;
2313 buf
->ptrp
[0] = value
>> 24;
2314 buf
->ptrp
[1] = value
>> 16;
2315 buf
->ptrp
[2] = value
>> 8;
2316 buf
->ptrp
[3] = value
>> 0;
2322 struct output_buffer_struct
*buf
;
2348 buf
->ptrp
= output_ptr
;
2349 buf
->buffer
= output_buffer
;
2389 #define ID copy_id()
2390 #define INT copy_int()
2391 #define EXP copy_expression()
2392 static void copy_till_end ();
2393 #define INTn(q) copy_int()
2394 #define EXPn(q) copy_expression()
2433 EXPn (instruction address
);
2467 EXPn (external function
);
2477 INTn (locked
register);
2500 /* Attribute record */
2558 static void block ();
2570 /* Unique typedefs for module */
2571 /* GLobal typedefs */
2572 /* High level module scope beginning */
2574 struct output_buffer_struct ob
;
2589 /* Global function */
2591 struct output_buffer_struct ob
;
2605 EXPn (size of block
);
2611 /* File name for source line numbers */
2613 struct output_buffer_struct ob
;
2633 /* Local function */
2635 struct output_buffer_struct ob
;
2653 /* Assembler module scope beginning -*/
2655 struct output_buffer_struct ob
;
2681 struct output_buffer_struct ob
;
2688 INTn (section index
);
2696 EXPn (Size in Maus
);
2751 moves all the debug information from the source bfd to the output
2752 bfd, and relocates any expressions it finds
2756 relocate_debug (output
, input
)
2762 unsigned char input_buffer
[IBS
];
2764 input_ptr_start
= input_ptr
= input_buffer
;
2765 input_ptr_end
= input_buffer
+ IBS
;
2767 /* FIXME: Check return value. I'm not sure whether it needs to read
2768 the entire buffer or not. */
2769 bfd_read ((PTR
) input_ptr_start
, 1, IBS
, input
);
2774 During linking, we we told about the bfds which made up our
2775 contents, we have a list of them. They will still be open, so go to
2776 the debug info in each, and copy it out, relocating it as we go.
2780 ieee_write_debug_part (abfd
)
2783 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
2784 bfd_chain_type
*chain
= ieee
->chain_root
;
2785 unsigned char output_buffer
[OBS
];
2786 boolean some_debug
= false;
2787 file_ptr here
= bfd_tell (abfd
);
2789 output_ptr_start
= output_ptr
= output_buffer
;
2790 output_ptr_end
= output_buffer
+ OBS
;
2791 output_ptr
= output_buffer
;
2794 if (chain
== (bfd_chain_type
*) NULL
)
2797 /* There is no debug info, so we'll fake some up */
2798 CONST
static char fake
[] =
2800 0xf8, 0xa, 0, 5, 't', 't', 't', 't', 't', 0, 2, 3,
2801 '1', '.', '1', 0x82, 1991 >> 8, 1991 & 0xff, 9, 20, 11, 07, 50};
2802 ieee
->w
.r
.debug_information_part
= 0;
2808 /* bfd_write(fake, 1, sizeof(fake), abfd);*/
2809 /* Now write a header for each section */
2812 asection
*s
= abfd
->sections
;
2815 if (s
!= abfd
->abs_section
)
2818 ieee_write_byte (abfd
, 0xf8);
2819 ieee_write_byte (abfd
, 0x0b);
2820 ieee_write_byte (abfd
, 0);
2821 ieee_write_byte (abfd
, 0);
2822 ieee_write_byte (abfd
, 1);
2823 ieee_write_byte (abfd
, i
+ IEEE_SECTION_NUMBER_BASE
);
2824 ieee_write_expression (abfd
, 0, s
->symbol
, 0, 0, 0);
2825 ieee_write_byte (abfd
, 0);
2826 ieee_write_byte (abfd
, 0xf9);
2827 ieee_write_expression (abfd
, s
->size
,
2828 bfd_abs_section_ptr
->symbol
, 0, 0, 0);
2835 /* Close the scope */
2836 ieee_write_byte (abfd
, 0xf9);
2842 while (chain
!= (bfd_chain_type
*) NULL
)
2844 bfd
*entry
= chain
->this;
2845 ieee_data_type
*entry_ieee
= IEEE_DATA (entry
);
2846 if (entry_ieee
->w
.r
.debug_information_part
)
2848 if (bfd_seek (entry
, entry_ieee
->w
.r
.debug_information_part
,
2852 relocate_debug (abfd
, entry
);
2855 chain
= chain
->next
;
2859 ieee
->w
.r
.debug_information_part
= here
;
2863 ieee
->w
.r
.debug_information_part
= 0;
2870 /* write the data in an ieee way */
2872 ieee_write_data_part (abfd
)
2876 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
2877 ieee
->w
.r
.data_part
= bfd_tell (abfd
);
2878 for (s
= abfd
->sections
; s
!= (asection
*) NULL
; s
= s
->next
)
2880 /* Sort the reloc records so we can insert them in the correct
2882 if (s
->reloc_count
!= 0)
2884 do_with_relocs (abfd
, s
);
2888 do_without_relocs (abfd
, s
);
2895 init_for_output (abfd
)
2899 for (s
= abfd
->sections
; s
!= (asection
*) NULL
; s
= s
->next
)
2901 if (s
->_raw_size
!= 0)
2903 ieee_per_section (s
)->data
= (bfd_byte
*) (bfd_alloc (abfd
, s
->_raw_size
));
2904 if (!ieee_per_section (s
)->data
)
2906 bfd_set_error (bfd_error_no_memory
);
2914 /** exec and core file sections */
2916 /* set section contents is complicated with IEEE since the format is
2917 * not a byte image, but a record stream.
2920 ieee_set_section_contents (abfd
, section
, location
, offset
, count
)
2925 bfd_size_type count
;
2927 if (ieee_per_section (section
)->data
== (bfd_byte
*) NULL
)
2929 if (!init_for_output (abfd
))
2932 memcpy ((PTR
) (ieee_per_section (section
)->data
+ offset
),
2934 (unsigned int) count
);
2939 write the external symbols of a file, IEEE considers two sorts of
2940 external symbols, public, and referenced. It uses to internal forms
2941 to index them as well. When we write them out we turn their symbol
2942 values into indexes from the right base.
2945 ieee_write_external_part (abfd
)
2949 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
2951 unsigned int reference_index
= IEEE_REFERENCE_BASE
;
2952 unsigned int public_index
= IEEE_PUBLIC_BASE
+ 2;
2953 file_ptr here
= bfd_tell (abfd
);
2954 boolean hadone
= false;
2955 if (abfd
->outsymbols
!= (asymbol
**) NULL
)
2958 for (q
= abfd
->outsymbols
; *q
!= (asymbol
*) NULL
; q
++)
2962 if (bfd_is_und_section (p
->section
))
2964 /* This must be a symbol reference .. */
2965 ieee_write_byte (abfd
, ieee_external_reference_enum
);
2966 ieee_write_int (abfd
, reference_index
);
2967 ieee_write_id (abfd
, p
->name
);
2968 p
->value
= reference_index
;
2971 else if (bfd_is_com_section (p
->section
))
2973 /* This is a weak reference */
2974 ieee_write_byte (abfd
, ieee_external_reference_enum
);
2975 ieee_write_int (abfd
, reference_index
);
2976 ieee_write_id (abfd
, p
->name
);
2977 ieee_write_byte (abfd
, ieee_weak_external_reference_enum
);
2978 ieee_write_int (abfd
, reference_index
);
2979 ieee_write_int (abfd
, p
->value
);
2980 ieee_write_int (abfd
, BFD_FORT_COMM_DEFAULT_VALUE
);
2981 p
->value
= reference_index
;
2984 else if (p
->flags
& BSF_GLOBAL
)
2986 /* This must be a symbol definition */
2989 ieee_write_byte (abfd
, ieee_external_symbol_enum
);
2990 ieee_write_int (abfd
, public_index
);
2991 ieee_write_id (abfd
, p
->name
);
2993 ieee_write_twobyte (abfd
, ieee_attribute_record_enum
);
2994 ieee_write_int (abfd
, public_index
);
2995 ieee_write_byte (abfd
, 15); /* instruction address */
2996 ieee_write_byte (abfd
, 19); /* static symbol */
2997 ieee_write_byte (abfd
, 1); /* one of them */
3000 /* Write out the value */
3001 ieee_write_2bytes (abfd
, ieee_value_record_enum
);
3002 ieee_write_int (abfd
, public_index
);
3003 if (! bfd_is_abs_section (p
->section
))
3005 if (abfd
->flags
& EXEC_P
)
3007 /* If fully linked, then output all symbols
3009 ieee_write_int (abfd
,
3010 p
->value
+ p
->section
->output_offset
+ p
->section
->output_section
->vma
);
3015 ieee_write_expression (abfd
,
3016 p
->value
+ p
->section
->output_offset
,
3017 p
->section
->output_section
->symbol
3023 ieee_write_expression (abfd
,
3025 bfd_abs_section_ptr
->symbol
,
3028 p
->value
= public_index
;
3033 /* This can happen - when there are gaps in the symbols read */
3034 /* from an input ieee file */
3039 ieee
->w
.r
.external_part
= here
;
3044 static CONST
unsigned char exten
[] =
3047 0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3 */
3048 0xf1, 0xce, 0x20, 0x00, 39, 2,/* keep symbol in original case */
3049 0xf1, 0xce, 0x20, 0x00, 38 /* set object type relocateable to x */
3052 static CONST
unsigned char envi
[] =
3056 /* 0xf1, 0xce, 0x21, 00, 50, 0x82, 0x07, 0xc7, 0x09, 0x11, 0x11,
3059 0xf1, 0xce, 0x21, 00, 52, 0x00, /* exec ok */
3061 0xf1, 0xce, 0x21, 0, 53, 0x03,/* host unix */
3062 /* 0xf1, 0xce, 0x21, 0, 54, 2,1,1 tool & version # */
3067 ieee_write_me_part (abfd
)
3070 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
3071 ieee
->w
.r
.trailer_part
= bfd_tell (abfd
);
3072 if (abfd
->start_address
)
3074 ieee
->w
.r
.me_record
= bfd_tell (abfd
);
3075 ieee_write_2bytes (abfd
, ieee_value_starting_address_enum
);
3076 ieee_write_byte (abfd
, ieee_function_either_open_b_enum
);
3077 ieee_write_int (abfd
, abfd
->start_address
);
3078 ieee_write_byte (abfd
, ieee_function_either_close_b_enum
);
3082 ieee
->w
.r
.me_record
= bfd_tell (abfd
);
3084 ieee_write_byte (abfd
, ieee_module_end_enum
);
3089 ieee_write_object_contents (abfd
)
3092 ieee_data_type
*ieee
= IEEE_DATA (abfd
);
3095 /* Fast forward over the header area */
3096 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0)
3098 ieee_write_byte (abfd
, ieee_module_beginning_enum
);
3100 ieee_write_id (abfd
, bfd_printable_name (abfd
));
3101 ieee_write_id (abfd
, abfd
->filename
);
3103 /* Fast forward over the variable bits */
3104 ieee_write_byte (abfd
, ieee_address_descriptor_enum
);
3107 ieee_write_byte (abfd
, (bfd_byte
) (bfd_arch_bits_per_byte (abfd
)));
3108 /* MAU's per address */
3109 ieee_write_byte (abfd
,
3110 (bfd_byte
) (bfd_arch_bits_per_address (abfd
) / bfd_arch_bits_per_byte (abfd
)));
3112 old
= bfd_tell (abfd
);
3113 if (bfd_seek (abfd
, (file_ptr
) (8 * N_W_VARIABLES
), SEEK_CUR
) != 0)
3116 ieee
->w
.r
.extension_record
= bfd_tell (abfd
);
3117 if (bfd_write ((char *) exten
, 1, sizeof (exten
), abfd
) != sizeof (exten
))
3119 if (abfd
->flags
& EXEC_P
)
3120 ieee_write_byte (abfd
, 0x1);/* Absolute */
3122 ieee_write_byte (abfd
, 0x2);/* Relocateable */
3124 ieee
->w
.r
.environmental_record
= bfd_tell (abfd
);
3125 if (bfd_write ((char *) envi
, 1, sizeof (envi
), abfd
) != sizeof (envi
))
3130 ieee_write_section_part (abfd
);
3132 First write the symbols, this changes their values into table
3133 indeces so we cant use it after this point
3135 ieee_write_external_part (abfd
);
3136 /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
3139 /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
3143 Write any debugs we have been told about
3145 ieee_write_debug_part (abfd
);
3148 Can only write the data once the symbols have been written since
3149 the data contains relocation information which points to the
3152 ieee_write_data_part (abfd
);
3156 At the end we put the end !
3158 ieee_write_me_part (abfd
);
3161 /* Generate the header */
3162 if (bfd_seek (abfd
, old
, SEEK_SET
) != 0)
3165 for (i
= 0; i
< N_W_VARIABLES
; i
++)
3167 ieee_write_2bytes (abfd
, ieee_assign_value_to_variable_enum
);
3168 ieee_write_byte (abfd
, (bfd_byte
) i
);
3169 ieee_write_int5_out (abfd
, ieee
->w
.offset
[i
]);
3176 /* Native-level interface to symbols. */
3178 /* We read the symbols into a buffer, which is discarded when this
3179 function exits. We read the strings into a buffer large enough to
3180 hold them all plus all the cached symbol entries. */
3183 ieee_make_empty_symbol (abfd
)
3187 ieee_symbol_type
*new =
3188 (ieee_symbol_type
*) bfd_zmalloc (sizeof (ieee_symbol_type
));
3191 bfd_set_error (bfd_error_no_error
);
3194 new->symbol
.the_bfd
= abfd
;
3195 return &new->symbol
;
3199 ieee_openr_next_archived_file (arch
, prev
)
3203 ieee_ar_data_type
*ar
= IEEE_AR_DATA (arch
);
3204 /* take the next one from the arch state, or reset */
3205 if (prev
== (bfd
*) NULL
)
3207 /* Reset the index - the first two entries are bogus*/
3208 ar
->element_index
= 2;
3212 ieee_ar_obstack_type
*p
= ar
->elements
+ ar
->element_index
;
3213 ar
->element_index
++;
3214 if (ar
->element_index
<= ar
->element_count
)
3216 if (p
->file_offset
!= (file_ptr
) 0)
3218 if (p
->abfd
== (bfd
*) NULL
)
3220 p
->abfd
= _bfd_create_empty_archive_element_shell (arch
);
3221 p
->abfd
->origin
= p
->file_offset
;
3228 bfd_set_error (bfd_error_no_more_archived_files
);
3229 return (bfd
*) NULL
;
3236 ieee_find_nearest_line (abfd
,
3247 char **filename_ptr
;
3248 char **functionname_ptr
;
3255 ieee_generic_stat_arch_elt (abfd
, buf
)
3259 ieee_ar_data_type
*ar
= abfd
->my_archive
->tdata
.ieee_ar_data
;
3260 if (ar
== (ieee_ar_data_type
*) NULL
)
3262 bfd_set_error (bfd_error_invalid_operation
);
3268 buf
->st_mode
= 0666;
3269 return !ieee_object_p (abfd
);
3274 ieee_sizeof_headers (abfd
, x
)
3282 /* The debug info routines are never used. */
3286 ieee_bfd_debug_info_start (abfd
)
3293 ieee_bfd_debug_info_end (abfd
)
3300 /* Add this section to the list of sections we have debug info for, to
3301 be ready to output it at close time
3304 ieee_bfd_debug_info_accumulate (abfd
, section
)
3308 ieee_data_type
*ieee
= IEEE_DATA (section
->owner
);
3309 ieee_data_type
*output_ieee
= IEEE_DATA (abfd
);
3310 /* can only accumulate data from other ieee bfds */
3311 if (section
->owner
->xvec
!= abfd
->xvec
)
3313 /* Only bother once per bfd */
3314 if (ieee
->done_debug
== true)
3316 ieee
->done_debug
= true;
3318 /* Don't bother if there is no debug info */
3319 if (ieee
->w
.r
.debug_information_part
== 0)
3325 bfd_chain_type
*n
= (bfd_chain_type
*) bfd_alloc (abfd
, sizeof (bfd_chain_type
));
3328 bfd_set_error (bfd_error_no_memory
);
3329 abort (); /* FIXME */
3331 n
->this = section
->owner
;
3332 n
->next
= (bfd_chain_type
*) NULL
;
3334 if (output_ieee
->chain_head
)
3336 output_ieee
->chain_head
->next
= n
;
3340 output_ieee
->chain_root
= n
;
3343 output_ieee
->chain_head
= n
;
3349 #define ieee_close_and_cleanup _bfd_generic_close_and_cleanup
3350 #define ieee_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
3352 #define ieee_slurp_armap bfd_true
3353 #define ieee_slurp_extended_name_table bfd_true
3354 #define ieee_construct_extended_name_table \
3355 ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
3357 #define ieee_truncate_arname bfd_dont_truncate_arname
3358 #define ieee_write_armap \
3360 PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
3362 #define ieee_update_armap_timestamp bfd_true
3364 #define ieee_bfd_is_local_label bfd_generic_is_local_label
3365 #define ieee_get_lineno _bfd_nosymbols_get_lineno
3366 #define ieee_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
3367 #define ieee_read_minisymbols _bfd_generic_read_minisymbols
3368 #define ieee_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
3370 #define ieee_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
3372 #define ieee_set_arch_mach _bfd_generic_set_arch_mach
3374 #define ieee_bfd_get_relocated_section_contents \
3375 bfd_generic_get_relocated_section_contents
3376 #define ieee_bfd_relax_section bfd_generic_relax_section
3377 #define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
3378 #define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols
3379 #define ieee_bfd_final_link _bfd_generic_final_link
3380 #define ieee_bfd_link_split_section _bfd_generic_link_split_section
3383 const bfd_target ieee_vec
=
3386 bfd_target_ieee_flavour
,
3387 true, /* target byte order */
3388 true, /* target headers byte order */
3389 (HAS_RELOC
| EXEC_P
| /* object flags */
3390 HAS_LINENO
| HAS_DEBUG
|
3391 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| D_PAGED
),
3392 (SEC_CODE
| SEC_DATA
| SEC_ROM
| SEC_HAS_CONTENTS
3393 | SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
3394 0, /* leading underscore */
3395 ' ', /* ar_pad_char */
3396 16, /* ar_max_namelen */
3397 1, /* minimum alignment */
3398 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
3399 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
3400 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* data */
3401 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
3402 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
3403 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* hdrs */
3406 ieee_object_p
, /* bfd_check_format */
3413 _bfd_generic_mkarchive
,
3418 ieee_write_object_contents
,
3419 _bfd_write_archive_contents
,
3423 BFD_JUMP_TABLE_GENERIC (ieee
),
3424 BFD_JUMP_TABLE_COPY (_bfd_generic
),
3425 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
3426 BFD_JUMP_TABLE_ARCHIVE (ieee
),
3427 BFD_JUMP_TABLE_SYMBOLS (ieee
),
3428 BFD_JUMP_TABLE_RELOCS (ieee
),
3429 BFD_JUMP_TABLE_WRITE (ieee
),
3430 BFD_JUMP_TABLE_LINK (ieee
),
3431 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic
),