From fdef3943443987525aea4f3ebe1f569f7070fcc8 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 16 Apr 2018 15:16:00 +0930 Subject: [PATCH] Remove IEEE 695 object support include/ * ieee.h: Delete. bfd/ * Makefile.am: Remove IEEE 695 support. * archures.c: Likewise. * bfd.c: Likewise. * config.bfd: Likewise. * configure.ac: Likewise. * doc/bfd.texinfo: Likewise. * doc/bfdint.texi: Likewise. * doc/bfdsumm.texi: Likewise. * section.c: Likewise. * targets.c: Likewise. * ieee.c: Delete. * libieee.h: Delete. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * configure: Regenerate. * po/SRC-POTFILES.in: Regenerate. binutils/ * Makefile.am: Remove IEEE 695 support. * budbg.h: Likewise. * doc/binutils.texi: Likewise. * makefile.vms: Likewise. * objcopy.c: Likewise. * objdump.c: Likewise. * rddbg.c: Likewise. * ieee.c: Delete. * Makefile.in: Regenerate. * po/POTFILES.in: Regenerate. gas/ * app.c: Remove IEEE 695 support. * symbols.c: Likewise. ld/ * ld.texinfo: Remove IEEE 695 support. * mri.c: Likewise. --- bfd/ChangeLog | 19 + bfd/Makefile.am | 4 +- bfd/Makefile.in | 5 +- bfd/archures.c | 13 - bfd/bfd-in2.h | 3 - bfd/bfd.c | 2 - bfd/config.bfd | 17 +- bfd/configure | 1 - bfd/configure.ac | 1 - bfd/doc/bfd.texinfo | 1 - bfd/doc/bfdint.texi | 5 +- bfd/doc/bfdsumm.texi | 4 +- bfd/ieee.c | 3957 ----------------------- bfd/libieee.h | 137 - bfd/po/SRC-POTFILES.in | 2 - bfd/section.c | 5 +- bfd/targets.c | 5 - binutils/ChangeLog | 13 + binutils/Makefile.am | 4 +- binutils/Makefile.in | 7 +- binutils/budbg.h | 6 - binutils/doc/binutils.texi | 4 +- binutils/ieee.c | 7398 -------------------------------------------- binutils/makefile.vms | 2 +- binutils/objcopy.c | 3 - binutils/objdump.c | 4 +- binutils/po/POTFILES.in | 2 - binutils/rddbg.c | 38 - gas/ChangeLog | 5 + gas/app.c | 2 - gas/symbols.c | 2 +- include/ChangeLog | 4 + include/ieee.h | 165 - ld/ChangeLog | 5 + ld/ld.texinfo | 3 - ld/mri.c | 3 - 36 files changed, 69 insertions(+), 11782 deletions(-) delete mode 100644 bfd/ieee.c delete mode 100644 bfd/libieee.h delete mode 100644 binutils/ieee.c delete mode 100644 include/ieee.h diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9d8ef5e..353d2b1 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,24 @@ 2018-04-16 Alan Modra + * Makefile.am: Remove IEEE 695 support. + * archures.c: Likewise. + * bfd.c: Likewise. + * config.bfd: Likewise. + * configure.ac: Likewise. + * doc/bfd.texinfo: Likewise. + * doc/bfdint.texi: Likewise. + * doc/bfdsumm.texi: Likewise. + * section.c: Likewise. + * targets.c: Likewise. + * ieee.c: Delete. + * libieee.h: Delete. + * Makefile.in: Regenerate. + * bfd-in2.h: Regenerate. + * configure: Regenerate. + * po/SRC-POTFILES.in: Regenerate. + +2018-04-16 Alan Modra + * config.bfd: Remove tandem support. 2018-04-16 Alan Modra diff --git a/bfd/Makefile.am b/bfd/Makefile.am index 88cd960..afa9ad8 100644 --- a/bfd/Makefile.am +++ b/bfd/Makefile.am @@ -400,7 +400,6 @@ BFD32_BACKENDS = \ i386msdos.lo \ i386netbsd.lo \ i386os9k.lo \ - ieee.lo \ m68k4knetbsd.lo \ m68klinux.lo \ m68knetbsd.lo \ @@ -585,7 +584,6 @@ BFD32_BACKENDS_CFILES = \ i386msdos.c \ i386netbsd.c \ i386os9k.c \ - ieee.c \ m68k4knetbsd.c \ m68klinux.c \ m68knetbsd.c \ @@ -787,7 +785,7 @@ SOURCE_HFILES = \ elf-bfd.h elf-hppa.h elf-linux-core.h elf32-hppa.h \ elf64-hppa.h elfcode.h elfcore.h \ freebsd.h genlink.h go32stub.h \ - libaout.h libbfd.h libcoff.h libecoff.h libhppa.h libieee.h \ + libaout.h libbfd.h libcoff.h libecoff.h libhppa.h \ liboasys.h libpei.h libxcoff.h mach-o.h \ netbsd.h ns32k.h \ pef.h pef-traceback.h peicode.h som.h version.h \ diff --git a/bfd/Makefile.in b/bfd/Makefile.in index 0a9167c..6311af4 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -734,7 +734,6 @@ BFD32_BACKENDS = \ i386msdos.lo \ i386netbsd.lo \ i386os9k.lo \ - ieee.lo \ m68k4knetbsd.lo \ m68klinux.lo \ m68knetbsd.lo \ @@ -919,7 +918,6 @@ BFD32_BACKENDS_CFILES = \ i386msdos.c \ i386netbsd.c \ i386os9k.c \ - ieee.c \ m68k4knetbsd.c \ m68klinux.c \ m68knetbsd.c \ @@ -1122,7 +1120,7 @@ SOURCE_HFILES = \ elf-bfd.h elf-hppa.h elf-linux-core.h elf32-hppa.h \ elf64-hppa.h elfcode.h elfcore.h \ freebsd.h genlink.h go32stub.h \ - libaout.h libbfd.h libcoff.h libecoff.h libhppa.h libieee.h \ + libaout.h libbfd.h libcoff.h libecoff.h libhppa.h \ liboasys.h libpei.h libxcoff.h mach-o.h \ netbsd.h ns32k.h \ pef.h pef-traceback.h peicode.h som.h version.h \ @@ -1556,7 +1554,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386msdos.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386netbsd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386os9k.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ieee.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihex.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/init.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/irix-core.Plo@am__quote@ diff --git a/bfd/archures.c b/bfd/archures.c index 3d61d71..bf46332 100644 --- a/bfd/archures.c +++ b/bfd/archures.c @@ -1168,19 +1168,6 @@ bfd_default_scan (const bfd_arch_info_type *info, const char *string) switch (number) { - /* FIXME: These are needed to parse IEEE objects. */ - /* The following seven case's are here only for compatibility with - older binutils (at least IEEE objects from binutils 2.9.1 require - them). */ - case bfd_mach_m68000: - case bfd_mach_m68010: - case bfd_mach_m68020: - case bfd_mach_m68030: - case bfd_mach_m68040: - case bfd_mach_m68060: - case bfd_mach_cpu32: - arch = bfd_arch_m68k; - break; case 68000: arch = bfd_arch_m68k; number = bfd_mach_m68000; diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index d04f028..fd69eb8 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -7006,8 +7006,6 @@ struct bfd struct pe_tdata *pe_obj_data; struct xcoff_tdata *xcoff_obj_data; struct ecoff_tdata *ecoff_obj_data; - struct ieee_data_struct *ieee_data; - struct ieee_ar_data_struct *ieee_ar_data; struct srec_data_struct *srec_data; struct verilog_data_struct *verilog_data; struct ihex_data_struct *ihex_data; @@ -7321,7 +7319,6 @@ enum bfd_flavour bfd_target_ecoff_flavour, bfd_target_xcoff_flavour, bfd_target_elf_flavour, - bfd_target_ieee_flavour, bfd_target_oasys_flavour, bfd_target_tekhex_flavour, bfd_target_srec_flavour, diff --git a/bfd/bfd.c b/bfd/bfd.c index 31df6cd..8b7fbab 100644 --- a/bfd/bfd.c +++ b/bfd/bfd.c @@ -310,8 +310,6 @@ CODE_FRAGMENT . struct pe_tdata *pe_obj_data; . struct xcoff_tdata *xcoff_obj_data; . struct ecoff_tdata *ecoff_obj_data; -. struct ieee_data_struct *ieee_data; -. struct ieee_ar_data_struct *ieee_ar_data; . struct srec_data_struct *srec_data; . struct verilog_data_struct *verilog_data; . struct ihex_data_struct *ihex_data; diff --git a/bfd/config.bfd b/bfd/config.bfd index a8f255a..1ca8ab4 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -109,7 +109,6 @@ case $targ in vax-*-bsd* | vax-*-ultrix* | \ we32k-*-* | \ w65-*-* | \ - *-*-ieee* | \ i370-* | \ sh5*-*-* | sh64*-*-* | \ null) @@ -127,6 +126,7 @@ case $targ in *-go32-rtems* | \ *-sony-* | \ *-tandem-* | \ + *-*-ieee* | \ *-*-netware* | \ *-*-rtemsaout* | \ *-*-rtemscoff* | \ @@ -496,7 +496,7 @@ case "${targ}" in #ifdef BFD64 cris-*-* | crisv32-*-*) targ_defvec=cris_aout_vec - targ_selvecs="cris_elf32_us_vec cris_elf32_vec ieee_vec" + targ_selvecs="cris_elf32_us_vec cris_elf32_vec" case "${targ}" in *-*-linux*) ;; *) targ_underscore=yes ;; @@ -530,7 +530,7 @@ case "${targ}" in fido-*-elf* ) targ_defvec=m68k_elf32_vec - targ_selvecs="m68k_coff_vec ieee_vec" + targ_selvecs="m68k_coff_vec" ;; fr30-*-elf) @@ -937,16 +937,16 @@ case "${targ}" in # We include core_cisco_be_vec here, rather than making a separate cisco # configuration, so that cisco-core.c gets routinely tested at # least for compilation. - targ_selvecs="core_cisco_be_vec ieee_vec" + targ_selvecs="core_cisco_be_vec" targ_underscore=yes ;; m68*-*-elf* | m68*-*-sysv4* | m68*-*-rtems* | m68*-*-uclinux*) targ_defvec=m68k_elf32_vec - targ_selvecs="m68k_coff_vec ieee_vec" + targ_selvecs="m68k_coff_vec" ;; m68*-*-coff* | m68*-*-sysv*) targ_defvec=m68k_coff_vec - targ_selvecs="m68k_coff_vec m68k_versados_vec ieee_vec" + targ_selvecs="m68k_coff_vec m68k_versados_vec" ;; m68*-*-hpux*) targ_defvec=m68k_aout_hp300hpux_vec @@ -1001,7 +1001,6 @@ case "${targ}" in ;; m68*-*-psos*) targ_defvec=m68k_elf32_vec - targ_selvecs=ieee_vec targ_underscore=yes ;; @@ -1793,10 +1792,6 @@ case "${targ}" in targ_underscore=yes ;; - *-*-ieee*) - targ_defvec=ieee_vec - ;; - # END OF targmatch.h *) echo 1>&2 "*** BFD does not support target ${targ}." diff --git a/bfd/configure b/bfd/configure index d3d05b4..2c7feae 100755 --- a/bfd/configure +++ b/bfd/configure @@ -14433,7 +14433,6 @@ do ia64_elf64_hpux_be_vec) tb="$tb elf64-ia64.lo elfxx-ia64.lo elf64.lo $elf"; target_size=64 ;; ia64_elf64_vms_vec) tb="$tb elf64-ia64-vms.lo elf64-ia64.lo elfxx-ia64.lo elf64.lo vms-lib.lo vms-misc.lo $elf"; target_size=64 ;; ia64_pei_vec) tb="$tb pei-ia64.lo pepigen.lo $coff"; target_size=64 ;; - ieee_vec) tb="$tb ieee.lo" ;; ip2k_elf32_vec) tb="$tb elf32-ip2k.lo elf32.lo $elf" ;; iq2000_elf32_vec) tb="$tb elf32-iq2000.lo elf32.lo $elf" ;; k1om_elf64_vec) tb="$tb elf64-x86-64.lo elfxx-x86.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;; diff --git a/bfd/configure.ac b/bfd/configure.ac index 77edd1b..7787f0a 100644 --- a/bfd/configure.ac +++ b/bfd/configure.ac @@ -510,7 +510,6 @@ do ia64_elf64_hpux_be_vec) tb="$tb elf64-ia64.lo elfxx-ia64.lo elf64.lo $elf"; target_size=64 ;; ia64_elf64_vms_vec) tb="$tb elf64-ia64-vms.lo elf64-ia64.lo elfxx-ia64.lo elf64.lo vms-lib.lo vms-misc.lo $elf"; target_size=64 ;; ia64_pei_vec) tb="$tb pei-ia64.lo pepigen.lo $coff"; target_size=64 ;; - ieee_vec) tb="$tb ieee.lo" ;; ip2k_elf32_vec) tb="$tb elf32-ip2k.lo elf32.lo $elf" ;; iq2000_elf32_vec) tb="$tb elf32-iq2000.lo elf32.lo $elf" ;; k1om_elf64_vec) tb="$tb elf64-x86-64.lo elfxx-x86.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;; diff --git a/bfd/doc/bfd.texinfo b/bfd/doc/bfd.texinfo index 479a4a8..8f925a1 100644 --- a/bfd/doc/bfd.texinfo +++ b/bfd/doc/bfd.texinfo @@ -294,7 +294,6 @@ structures. * mmo :: mmo backend @ignore * oasys :: oasys backends -* ieee :: ieee backend * srecord :: s-record backend @end ignore @end menu diff --git a/bfd/doc/bfdint.texi b/bfd/doc/bfdint.texi index 954a47a..c9f8942 100644 --- a/bfd/doc/bfdint.texi +++ b/bfd/doc/bfdint.texi @@ -336,8 +336,6 @@ COFF. ECOFF. @item bfd_target_elf_flavour ELF. -@item bfd_target_ieee_flavour -IEEE-695. @item bfd_target_oasys_flavour OASYS. @item bfd_target_tekhex_flavour @@ -1167,8 +1165,7 @@ address of the section contents. In general, relocations can be arbitrarily complex. For example, relocations used in dynamic linking systems often require the linker to allocate space in a different section and use the offset within that -section as the value to store. In the IEEE object file format, -relocations may involve arbitrary expressions. +section as the value to store. When doing a relocatable link, the linker may or may not have to do anything with a relocation, depending upon the definition of the diff --git a/bfd/doc/bfdsumm.texi b/bfd/doc/bfdsumm.texi index c02c27a..848c06e 100644 --- a/bfd/doc/bfdsumm.texi +++ b/bfd/doc/bfdsumm.texi @@ -120,7 +120,7 @@ to allow users to throw it away. There is one word of type information within the symbol, so if the format supports symbol type information within symbols (for example, COFF, -IEEE, Oasys) and the type is simple enough to fit within one word +Oasys) and the type is simple enough to fit within one word (nearly everything but aggregates), the information will be preserved. @item relocation level @@ -146,5 +146,5 @@ pointer to the symbol, which allows finding out the address of the function whose line number is being described. The rest of the list is made up of pairs: offsets into the section and line numbers. Any format which can simply derive this information can pass it successfully -between formats (COFF, IEEE and Oasys). +between formats. @end table diff --git a/bfd/ieee.c b/bfd/ieee.c deleted file mode 100644 index aa10aa2..0000000 --- a/bfd/ieee.c +++ /dev/null @@ -1,3957 +0,0 @@ -/* BFD back-end for ieee-695 objects. - Copyright (C) 1990-2018 Free Software Foundation, Inc. - - Written by Steve Chamberlain of Cygnus Support. - - This file is part of BFD, the Binary File Descriptor library. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, - MA 02110-1301, USA. */ - - -#define KEEPMINUSPCININST 0 - -/* IEEE 695 format is a stream of records, which we parse using a simple one- - token (which is one byte in this lexicon) lookahead recursive decent - parser. */ - -#include "sysdep.h" -#include "bfd.h" -#include "libbfd.h" -#include "ieee.h" -#include "libieee.h" -#include "safe-ctype.h" -#include "libiberty.h" - -struct output_buffer_struct -{ - unsigned char *ptrp; - int buffer; -}; - -static unsigned char *output_ptr_start; -static unsigned char *output_ptr; -static unsigned char *output_ptr_end; -static unsigned char *input_ptr_start; -static unsigned char *input_ptr; -static unsigned char *input_ptr_end; -static bfd *input_bfd; -static bfd *output_bfd; -static int output_buffer; - - -static void block (void); - -/* Functions for writing to ieee files in the strange way that the - standard requires. */ - -static bfd_boolean -ieee_write_byte (bfd *abfd, int barg) -{ - bfd_byte byte; - - byte = barg; - if (bfd_bwrite ((void *) &byte, (bfd_size_type) 1, abfd) != 1) - return FALSE; - return TRUE; -} - -static bfd_boolean -ieee_write_2bytes (bfd *abfd, int bytes) -{ - bfd_byte buffer[2]; - - buffer[0] = bytes >> 8; - buffer[1] = bytes & 0xff; - if (bfd_bwrite ((void *) buffer, (bfd_size_type) 2, abfd) != 2) - return FALSE; - return TRUE; -} - -static bfd_boolean -ieee_write_int (bfd *abfd, bfd_vma value) -{ - if (value <= 127) - { - if (! ieee_write_byte (abfd, (bfd_byte) value)) - return FALSE; - } - else - { - unsigned int length; - - /* How many significant bytes ? */ - /* FIXME FOR LONGER INTS. */ - if (value & 0xff000000) - length = 4; - else if (value & 0x00ff0000) - length = 3; - else if (value & 0x0000ff00) - length = 2; - else - length = 1; - - if (! ieee_write_byte (abfd, - (bfd_byte) ((int) ieee_number_repeat_start_enum - + length))) - return FALSE; - switch (length) - { - case 4: - if (! ieee_write_byte (abfd, (bfd_byte) (value >> 24))) - return FALSE; - /* Fall through. */ - case 3: - if (! ieee_write_byte (abfd, (bfd_byte) (value >> 16))) - return FALSE; - /* Fall through. */ - case 2: - if (! ieee_write_byte (abfd, (bfd_byte) (value >> 8))) - return FALSE; - /* Fall through. */ - case 1: - if (! ieee_write_byte (abfd, (bfd_byte) (value))) - return FALSE; - } - } - - return TRUE; -} - -static bfd_boolean -ieee_write_id (bfd *abfd, const char *id) -{ - size_t length = strlen (id); - - if (length <= 127) - { - if (! ieee_write_byte (abfd, (bfd_byte) length)) - return FALSE; - } - else if (length < 255) - { - if (! ieee_write_byte (abfd, ieee_extension_length_1_enum) - || ! ieee_write_byte (abfd, (bfd_byte) length)) - return FALSE; - } - else if (length < 65535) - { - if (! ieee_write_byte (abfd, ieee_extension_length_2_enum) - || ! ieee_write_2bytes (abfd, (int) length)) - return FALSE; - } - else - { - _bfd_error_handler - /* xgettext:c-format */ - (_("%pB: string too long (%ld chars, max 65535)"), abfd, (long) length); - bfd_set_error (bfd_error_invalid_operation); - return FALSE; - } - - if (bfd_bwrite ((void *) id, (bfd_size_type) length, abfd) != length) - return FALSE; - return TRUE; -} - -/* Functions for reading from ieee files in the strange way that the - standard requires. */ - -#define this_byte(ieee) *((ieee)->input_p) -#define this_byte_and_next(ieee) ((ieee)->input_p < (ieee)->end_p ? *((ieee)->input_p++) : 0) - -static bfd_boolean -next_byte (common_header_type * ieee) -{ - ieee->input_p++; - - return ieee->input_p < ieee->last_byte; -} - -static unsigned short -read_2bytes (common_header_type *ieee) -{ - unsigned char c1 = this_byte_and_next (ieee); - unsigned char c2 = this_byte_and_next (ieee); - - return (c1 << 8) | c2; -} - -static void -bfd_get_string (common_header_type *ieee, char *string, size_t length) -{ - size_t i; - - for (i = 0; i < length; i++) - string[i] = this_byte_and_next (ieee); -} - -static char * -read_id (common_header_type *ieee) -{ - size_t length; - char *string; - - length = this_byte_and_next (ieee); - if (length <= 0x7f) - /* Simple string of length 0 to 127. */ - ; - - else if (length == 0xde) - /* Length is next byte, allowing 0..255. */ - length = this_byte_and_next (ieee); - - else if (length == 0xdf) - { - /* Length is next two bytes, allowing 0..65535. */ - length = this_byte_and_next (ieee); - length = (length * 256) + this_byte_and_next (ieee); - } - - /* PR 21612: Check for an invalid length. */ - if (ieee->input_p + length >= ieee->end_p) - { - _bfd_error_handler (_("IEEE parser: string length: %#lx longer than buffer: %#lx"), - (long) length, (long) (ieee->end_p - ieee->input_p)); - bfd_set_error (bfd_error_invalid_operation); - return NULL; - } - - /* Buy memory and read string. */ - string = bfd_alloc (ieee->abfd, (bfd_size_type) length + 1); - if (!string) - return NULL; - bfd_get_string (ieee, string, length); - string[length] = 0; - return string; -} - -static bfd_boolean -ieee_write_expression (bfd *abfd, - bfd_vma value, - asymbol *symbol, - bfd_boolean pcrel, - unsigned int sindex) -{ - unsigned int term_count = 0; - - if (value != 0) - { - if (! ieee_write_int (abfd, value)) - return FALSE; - term_count++; - } - - /* Badly formatted binaries can have a missing symbol, - so test here to prevent a seg fault. */ - if (symbol != NULL) - { - if (bfd_is_com_section (symbol->section) - || bfd_is_und_section (symbol->section)) - { - /* Def of a common symbol. */ - if (! ieee_write_byte (abfd, ieee_variable_X_enum) - || ! ieee_write_int (abfd, symbol->value)) - return FALSE; - term_count ++; - } - else if (! bfd_is_abs_section (symbol->section)) - { - /* Ref to defined symbol - */ - if (symbol->flags & BSF_GLOBAL) - { - if (! ieee_write_byte (abfd, ieee_variable_I_enum) - || ! ieee_write_int (abfd, symbol->value)) - return FALSE; - term_count++; - } - else if (symbol->flags & (BSF_LOCAL | BSF_SECTION_SYM)) - { - /* This is a reference to a defined local symbol. We can - easily do a local as a section+offset. */ - if (! ieee_write_byte (abfd, ieee_variable_R_enum) - || ! ieee_write_byte (abfd, - (bfd_byte) (symbol->section->index - + IEEE_SECTION_NUMBER_BASE))) - return FALSE; - - term_count++; - if (symbol->value != 0) - { - if (! ieee_write_int (abfd, symbol->value)) - return FALSE; - term_count++; - } - } - else - { - _bfd_error_handler - /* xgettext:c-format */ - (_("%pB: unrecognized symbol `%s' flags 0x%x"), - abfd, bfd_asymbol_name (symbol), symbol->flags); - bfd_set_error (bfd_error_invalid_operation); - return FALSE; - } - } - } - - if (pcrel) - { - /* Subtract the pc from here by asking for PC of this section. */ - if (! ieee_write_byte (abfd, ieee_variable_P_enum) - || ! ieee_write_byte (abfd, - (bfd_byte) (sindex + IEEE_SECTION_NUMBER_BASE)) - || ! ieee_write_byte (abfd, ieee_function_minus_enum)) - return FALSE; - } - - /* Handle the degenerate case of a 0 address. */ - if (term_count == 0) - if (! ieee_write_int (abfd, (bfd_vma) 0)) - return FALSE; - - while (term_count > 1) - { - if (! ieee_write_byte (abfd, ieee_function_plus_enum)) - return FALSE; - term_count--; - } - - return TRUE; -} - -/* Writes any integer into the buffer supplied and always takes 5 bytes. */ - -static void -ieee_write_int5 (bfd_byte *buffer, bfd_vma value) -{ - buffer[0] = (bfd_byte) ieee_number_repeat_4_enum; - buffer[1] = (value >> 24) & 0xff; - buffer[2] = (value >> 16) & 0xff; - buffer[3] = (value >> 8) & 0xff; - buffer[4] = (value >> 0) & 0xff; -} - -static bfd_boolean -ieee_write_int5_out (bfd *abfd, bfd_vma value) -{ - bfd_byte b[5]; - - ieee_write_int5 (b, value); - if (bfd_bwrite ((void *) b, (bfd_size_type) 5, abfd) != 5) - return FALSE; - return TRUE; -} - -static bfd_boolean -parse_int (common_header_type *ieee, bfd_vma *value_ptr) -{ - int value = this_byte (ieee); - int result; - - if (value >= 0 && value <= 127) - { - *value_ptr = value; - return next_byte (ieee); - } - else if (value >= 0x80 && value <= 0x88) - { - unsigned int count = value & 0xf; - - result = 0; - if (! next_byte (ieee)) - return FALSE; - while (count) - { - result = (result << 8) | this_byte_and_next (ieee); - count--; - } - *value_ptr = result; - return TRUE; - } - return FALSE; -} - -static int -parse_i (common_header_type *ieee, bfd_boolean *ok) -{ - bfd_vma x = 0; - *ok = parse_int (ieee, &x); - return x; -} - -static bfd_vma -must_parse_int (common_header_type *ieee) -{ - bfd_vma result = 0; - BFD_ASSERT (parse_int (ieee, &result)); - return result; -} - -typedef struct -{ - bfd_vma value; - asection *section; - ieee_symbol_index_type symbol; -} ieee_value_type; - - -#if KEEPMINUSPCININST - -#define SRC_MASK(arg) arg -#define PCREL_OFFSET FALSE - -#else - -#define SRC_MASK(arg) 0 -#define PCREL_OFFSET TRUE - -#endif - -static reloc_howto_type abs32_howto = - HOWTO (1, - 0, - 2, - 32, - FALSE, - 0, - complain_overflow_bitfield, - 0, - "abs32", - TRUE, - 0xffffffff, - 0xffffffff, - FALSE); - -static reloc_howto_type abs16_howto = - HOWTO (1, - 0, - 1, - 16, - FALSE, - 0, - complain_overflow_bitfield, - 0, - "abs16", - TRUE, - 0x0000ffff, - 0x0000ffff, - FALSE); - -static reloc_howto_type abs8_howto = - HOWTO (1, - 0, - 0, - 8, - FALSE, - 0, - complain_overflow_bitfield, - 0, - "abs8", - TRUE, - 0x000000ff, - 0x000000ff, - FALSE); - -static reloc_howto_type rel32_howto = - HOWTO (1, - 0, - 2, - 32, - TRUE, - 0, - complain_overflow_signed, - 0, - "rel32", - TRUE, - SRC_MASK (0xffffffff), - 0xffffffff, - PCREL_OFFSET); - -static reloc_howto_type rel16_howto = - HOWTO (1, - 0, - 1, - 16, - TRUE, - 0, - complain_overflow_signed, - 0, - "rel16", - TRUE, - SRC_MASK (0x0000ffff), - 0x0000ffff, - PCREL_OFFSET); - -static reloc_howto_type rel8_howto = - HOWTO (1, - 0, - 0, - 8, - TRUE, - 0, - complain_overflow_signed, - 0, - "rel8", - TRUE, - SRC_MASK (0x000000ff), - 0x000000ff, - PCREL_OFFSET); - -static ieee_symbol_index_type NOSYMBOL = {0, 0}; - -static bfd_boolean -parse_expression (ieee_data_type *ieee, - bfd_vma *value, - ieee_symbol_index_type *symbol, - bfd_boolean *pcrel, - unsigned int *extra, - asection **section) - -{ - bfd_boolean loop = TRUE; - ieee_value_type stack[10]; - ieee_value_type *sp = stack; - asection *dummy; - -#define POS sp[1] -#define TOS sp[0] -#define NOS sp[-1] -#define INC sp++; -#define DEC sp--; - - /* The stack pointer always points to the next unused location. */ -#define PUSH(x,y,z) TOS.symbol = x; TOS.section = y; TOS.value = z; INC; -#define POP(x,y,z) DEC; x = TOS.symbol; y = TOS.section; z = TOS.value; - - while (loop && ieee->h.input_p < ieee->h.last_byte) - { - switch (this_byte (&(ieee->h))) - { - case ieee_variable_P_enum: - /* P variable, current program counter for section n. */ - { - int section_n; - - if (! next_byte (&(ieee->h))) - return FALSE; - *pcrel = TRUE; - section_n = must_parse_int (&(ieee->h)); - (void) section_n; - PUSH (NOSYMBOL, bfd_abs_section_ptr, 0); - break; - } - - case ieee_variable_L_enum: - /* L variable address of section N. */ - if (! next_byte (&(ieee->h))) - return FALSE; - PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0); - break; - - case ieee_variable_R_enum: - /* R variable, logical address of section module. */ - /* FIXME, this should be different to L. */ - if (! next_byte (&(ieee->h))) - return FALSE; - PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0); - break; - - case ieee_variable_S_enum: - /* S variable, size in MAUS of section module. */ - if (! next_byte (&(ieee->h))) - return FALSE; - PUSH (NOSYMBOL, - 0, - ieee->section_table[must_parse_int (&(ieee->h))]->size); - break; - - case ieee_variable_I_enum: - /* Push the address of variable n. */ - { - ieee_symbol_index_type sy; - - if (! next_byte (&(ieee->h))) - return FALSE; - sy.index = (int) must_parse_int (&(ieee->h)); - sy.letter = 'I'; - - PUSH (sy, bfd_abs_section_ptr, 0); - } - break; - - case ieee_variable_X_enum: - /* Push the address of external variable n. */ - { - ieee_symbol_index_type sy; - - if (! next_byte (&(ieee->h))) - return FALSE; - - sy.index = (int) (must_parse_int (&(ieee->h))); - sy.letter = 'X'; - - PUSH (sy, bfd_und_section_ptr, 0); - } - break; - - case ieee_function_minus_enum: - { - bfd_vma value1, value2; - asection *section1, *section_dummy; - ieee_symbol_index_type sy; - - if (! next_byte (&(ieee->h))) - return FALSE; - - POP (sy, section1, value1); - POP (sy, section_dummy, value2); - PUSH (sy, section1 ? section1 : section_dummy, value2 - value1); - } - break; - - case ieee_function_plus_enum: - { - bfd_vma value1, value2; - asection *section1; - asection *section2; - ieee_symbol_index_type sy1; - ieee_symbol_index_type sy2; - - if (! next_byte (&(ieee->h))) - return FALSE; - - POP (sy1, section1, value1); - POP (sy2, section2, value2); - PUSH (sy1.letter ? sy1 : sy2, - bfd_is_abs_section (section1) ? section2 : section1, - value1 + value2); - } - break; - - default: - { - bfd_vma va; - - BFD_ASSERT (this_byte (&(ieee->h)) < (int) ieee_variable_A_enum - || this_byte (&(ieee->h)) > (int) ieee_variable_Z_enum); - if (parse_int (&(ieee->h), &va)) - { - PUSH (NOSYMBOL, bfd_abs_section_ptr, va); - } - else - /* Thats all that we can understand. */ - loop = FALSE; - } - } - } - - /* As far as I can see there is a bug in the Microtec IEEE output - which I'm using to scan, whereby the comma operator is omitted - sometimes in an expression, giving expressions with too many - terms. We can tell if that's the case by ensuring that - sp == stack here. If not, then we've pushed something too far, - so we keep adding. */ - while (sp != stack + 1) - { - asection *section1; - ieee_symbol_index_type sy1; - - POP (sy1, section1, *extra); - (void) section1; - (void) sy1; - } - - POP (*symbol, dummy, *value); - if (section) - *section = dummy; - - return TRUE; -} - -#define ieee_pos(ieee) \ - (ieee->h.input_p - ieee->h.first_byte) - -/* Find the first part of the ieee file after HERE. */ - -static file_ptr -ieee_part_after (ieee_data_type *ieee, file_ptr here) -{ - int part; - file_ptr after = ieee->w.r.me_record; - - /* File parts can come in any order, except that module end is - guaranteed to be last (and the header first). */ - for (part = 0; part < N_W_VARIABLES; part++) - if (ieee->w.offset[part] > here && after > ieee->w.offset[part]) - after = ieee->w.offset[part]; - - return after; -} - -static bfd_boolean -ieee_seek (ieee_data_type * ieee, file_ptr offset) -{ - /* PR 17512: file: 017-1157-0.004. */ - if (offset < 0 || (bfd_size_type) offset >= ieee->h.total_amt) - { - ieee->h.input_p = ieee->h.first_byte + ieee->h.total_amt; - ieee->h.end_p = ieee->h.last_byte = ieee->h.input_p; - return FALSE; - } - - ieee->h.input_p = ieee->h.first_byte + offset; - ieee->h.end_p = ieee->h.last_byte = (ieee->h.first_byte + ieee_part_after (ieee, offset)); - return TRUE; -} - -static unsigned int last_index; -static char last_type; /* Is the index for an X or a D. */ - -static ieee_symbol_type * -get_symbol (bfd *abfd ATTRIBUTE_UNUSED, - ieee_data_type *ieee, - ieee_symbol_type *last_symbol, - unsigned int *symbol_count, - ieee_symbol_type ***pptr, - unsigned int *max_index, - int this_type) -{ - /* Need a new symbol. */ - unsigned int new_index = must_parse_int (&(ieee->h)); - - if (new_index != last_index || this_type != last_type) - { - ieee_symbol_type *new_symbol; - bfd_size_type amt = sizeof (ieee_symbol_type); - - new_symbol = bfd_alloc (ieee->h.abfd, amt); - if (!new_symbol) - return NULL; - - new_symbol->index = new_index; - last_index = new_index; - (*symbol_count)++; - **pptr = new_symbol; - *pptr = &new_symbol->next; - if (new_index > *max_index) - *max_index = new_index; - - last_type = this_type; - new_symbol->symbol.section = bfd_abs_section_ptr; - return new_symbol; - } - return last_symbol; -} - -static bfd_boolean -ieee_slurp_external_symbols (bfd *abfd) -{ - ieee_data_type *ieee = IEEE_DATA (abfd); - file_ptr offset = ieee->w.r.external_part; - - ieee_symbol_type **prev_symbols_ptr = &ieee->external_symbols; - ieee_symbol_type **prev_reference_ptr = &ieee->external_reference; - ieee_symbol_type *symbol = NULL; - unsigned int symbol_count = 0; - bfd_boolean loop = TRUE; - - last_index = 0xffffff; - ieee->symbol_table_full = TRUE; - - if (! ieee_seek (ieee, offset)) - return FALSE; - - while (loop) - { - switch (this_byte (&(ieee->h))) - { - case ieee_nn_record: - if (! next_byte (&(ieee->h))) - return FALSE; - - symbol = get_symbol (abfd, ieee, symbol, &symbol_count, - & prev_symbols_ptr, - & ieee->external_symbol_max_index, 'I'); - if (symbol == NULL) - return FALSE; - - symbol->symbol.the_bfd = abfd; - symbol->symbol.name = read_id (&(ieee->h)); - symbol->symbol.udata.p = NULL; - symbol->symbol.flags = BSF_NO_FLAGS; - break; - - case ieee_external_symbol_enum: - if (! next_byte (&(ieee->h))) - return FALSE; - - symbol = get_symbol (abfd, ieee, symbol, &symbol_count, - &prev_symbols_ptr, - &ieee->external_symbol_max_index, 'D'); - if (symbol == NULL) - return FALSE; - - BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index); - - symbol->symbol.the_bfd = abfd; - symbol->symbol.name = read_id (&(ieee->h)); - symbol->symbol.udata.p = NULL; - symbol->symbol.flags = BSF_NO_FLAGS; - break; - case ieee_attribute_record_enum >> 8: - { - unsigned int symbol_name_index; - unsigned int symbol_type_index; - unsigned int symbol_attribute_def; - bfd_vma value = 0; - - switch (read_2bytes (&ieee->h)) - { - case ieee_attribute_record_enum: - symbol_name_index = must_parse_int (&(ieee->h)); - symbol_type_index = must_parse_int (&(ieee->h)); - (void) symbol_type_index; - symbol_attribute_def = must_parse_int (&(ieee->h)); - switch (symbol_attribute_def) - { - case 8: - case 19: - parse_int (&ieee->h, &value); - break; - default: - _bfd_error_handler - /* xgettext:c-format */ - (_("%pB: unimplemented ATI record %u for symbol %u"), - abfd, symbol_attribute_def, symbol_name_index); - bfd_set_error (bfd_error_bad_value); - return FALSE; - break; - } - break; - case ieee_external_reference_info_record_enum: - /* Skip over ATX record. */ - parse_int (&(ieee->h), &value); - parse_int (&(ieee->h), &value); - parse_int (&(ieee->h), &value); - parse_int (&(ieee->h), &value); - break; - case ieee_atn_record_enum: - /* We may get call optimization information here, - which we just ignore. The format is - {$F1}${CE}{index}{$00}{$3F}{$3F}{#_of_ASNs}. */ - parse_int (&ieee->h, &value); - parse_int (&ieee->h, &value); - parse_int (&ieee->h, &value); - if (value != 0x3f) - { - _bfd_error_handler - /* xgettext:c-format */ - (_("%pB: unexpected ATN type %" PRId64 " in external part"), - abfd, (int64_t) value); - bfd_set_error (bfd_error_bad_value); - return FALSE; - } - parse_int (&ieee->h, &value); - parse_int (&ieee->h, &value); - while (value > 0) - { - bfd_vma val1; - - --value; - - switch (read_2bytes (&ieee->h)) - { - case ieee_asn_record_enum: - parse_int (&ieee->h, &val1); - parse_int (&ieee->h, &val1); - break; - - default: - _bfd_error_handler - (_("%pB: unexpected type after ATN"), abfd); - bfd_set_error (bfd_error_bad_value); - return FALSE; - } - } - } - } - break; - - case ieee_value_record_enum >> 8: - { - unsigned int symbol_name_index; - ieee_symbol_index_type symbol_ignore; - bfd_boolean pcrel_ignore; - unsigned int extra; - - if (! next_byte (&(ieee->h))) - return FALSE; - if (! next_byte (&(ieee->h))) - return FALSE; - - symbol_name_index = must_parse_int (&(ieee->h)); - (void) symbol_name_index; - if (! parse_expression (ieee, - &symbol->symbol.value, - &symbol_ignore, - &pcrel_ignore, - &extra, - &symbol->symbol.section)) - return FALSE; - - /* Fully linked IEEE-695 files tend to give every symbol - an absolute value. Try to convert that back into a - section relative value. FIXME: This won't always to - the right thing. */ - if (bfd_is_abs_section (symbol->symbol.section) - && (abfd->flags & HAS_RELOC) == 0) - { - bfd_vma val; - asection *s; - - val = symbol->symbol.value; - for (s = abfd->sections; s != NULL; s = s->next) - { - if (val >= s->vma && val < s->vma + s->size) - { - symbol->symbol.section = s; - symbol->symbol.value -= s->vma; - break; - } - } - } - - symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT; - - } - break; - case ieee_weak_external_reference_enum: - { - bfd_vma size; - bfd_vma value; - - if (! next_byte (&(ieee->h))) - return FALSE; - - /* Throw away the external reference index. */ - (void) must_parse_int (&(ieee->h)); - /* Fetch the default size if not resolved. */ - size = must_parse_int (&(ieee->h)); - /* Fetch the default value if available. */ - if (! parse_int (&(ieee->h), &value)) - value = 0; - /* This turns into a common. */ - symbol->symbol.section = bfd_com_section_ptr; - symbol->symbol.value = size; - } - break; - - case ieee_external_reference_enum: - if (! next_byte (&(ieee->h))) - return FALSE; - - symbol = get_symbol (abfd, ieee, symbol, &symbol_count, - &prev_reference_ptr, - &ieee->external_reference_max_index, 'X'); - if (symbol == NULL) - return FALSE; - - symbol->symbol.the_bfd = abfd; - symbol->symbol.name = read_id (&(ieee->h)); - symbol->symbol.udata.p = NULL; - symbol->symbol.section = bfd_und_section_ptr; - symbol->symbol.value = (bfd_vma) 0; - symbol->symbol.flags = 0; - - BFD_ASSERT (symbol->index >= ieee->external_reference_min_index); - break; - - default: - loop = FALSE; - } - } - - if (ieee->external_symbol_max_index != 0) - { - ieee->external_symbol_count = - ieee->external_symbol_max_index - - ieee->external_symbol_min_index + 1; - } - else - ieee->external_symbol_count = 0; - - if (ieee->external_reference_max_index != 0) - { - ieee->external_reference_count = - ieee->external_reference_max_index - - ieee->external_reference_min_index + 1; - } - else - ieee->external_reference_count = 0; - - abfd->symcount = - ieee->external_reference_count + ieee->external_symbol_count; - - if (symbol_count != abfd->symcount) - /* There are gaps in the table -- */ - ieee->symbol_table_full = FALSE; - - *prev_symbols_ptr = NULL; - *prev_reference_ptr = NULL; - - return TRUE; -} - -static bfd_boolean -ieee_slurp_symbol_table (bfd *abfd) -{ - if (! IEEE_DATA (abfd)->read_symbols) - { - if (! ieee_slurp_external_symbols (abfd)) - return FALSE; - IEEE_DATA (abfd)->read_symbols = TRUE; - } - return TRUE; -} - -static long -ieee_get_symtab_upper_bound (bfd *abfd) -{ - if (! ieee_slurp_symbol_table (abfd)) - return -1; - - return (abfd->symcount != 0) ? - (abfd->symcount + 1) * (sizeof (ieee_symbol_type *)) : 0; -} - -/* Move from our internal lists to the canon table, and insert in - symbol index order. */ - -extern const bfd_target ieee_vec; - -static long -ieee_canonicalize_symtab (bfd *abfd, asymbol **location) -{ - ieee_symbol_type *symp; - static bfd dummy_bfd; - static asymbol empty_symbol = - { - &dummy_bfd, - " ieee empty", - (symvalue) 0, - BSF_DEBUGGING, - bfd_abs_section_ptr -#ifdef __STDC__ - /* K&R compilers can't initialise unions. */ - , { 0 } -#endif - }; - - if (abfd->symcount) - { - ieee_data_type *ieee = IEEE_DATA (abfd); - - dummy_bfd.xvec = &ieee_vec; - if (! ieee_slurp_symbol_table (abfd)) - return -1; - - if (! ieee->symbol_table_full) - { - /* Arrgh - there are gaps in the table, run through and fill them - up with pointers to a null place. */ - unsigned int i; - - for (i = 0; i < abfd->symcount; i++) - location[i] = &empty_symbol; - } - - ieee->external_symbol_base_offset = -ieee->external_symbol_min_index; - for (symp = IEEE_DATA (abfd)->external_symbols; - symp != (ieee_symbol_type *) NULL; - symp = symp->next) - /* Place into table at correct index locations. */ - location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol; - - /* The external refs are indexed in a bit. */ - ieee->external_reference_base_offset = - -ieee->external_reference_min_index + ieee->external_symbol_count; - - for (symp = IEEE_DATA (abfd)->external_reference; - symp != (ieee_symbol_type *) NULL; - symp = symp->next) - location[symp->index + ieee->external_reference_base_offset] = - &symp->symbol; - } - - if (abfd->symcount) - location[abfd->symcount] = (asymbol *) NULL; - - return abfd->symcount; -} - -static asection * -get_section_entry (bfd *abfd, ieee_data_type *ieee, unsigned int sindex) -{ - if (sindex >= ieee->section_table_size) - { - unsigned int c, i; - asection **n; - bfd_size_type amt; - - c = ieee->section_table_size; - if (c == 0) - c = 20; - while (c <= sindex) - c *= 2; - - amt = c; - amt *= sizeof (asection *); - n = bfd_realloc (ieee->section_table, amt); - if (n == NULL) - return NULL; - - for (i = ieee->section_table_size; i < c; i++) - n[i] = NULL; - - ieee->section_table = n; - ieee->section_table_size = c; - } - - if (ieee->section_table[sindex] == (asection *) NULL) - { - char *tmp = bfd_alloc (abfd, (bfd_size_type) 11); - asection *section; - - if (!tmp) - return NULL; - sprintf (tmp, " fsec%4d", sindex); - section = bfd_make_section (abfd, tmp); - ieee->section_table[sindex] = section; - section->target_index = sindex; - ieee->section_table[sindex] = section; - } - return ieee->section_table[sindex]; -} - -static bfd_boolean -ieee_slurp_sections (bfd *abfd) -{ - ieee_data_type *ieee = IEEE_DATA (abfd); - file_ptr offset = ieee->w.r.section_part; - char *name; - - if (offset != 0) - { - bfd_byte section_type[3]; - - if (! ieee_seek (ieee, offset)) - return FALSE; - - while (TRUE) - { - switch (this_byte (&(ieee->h))) - { - case ieee_section_type_enum: - { - asection *section; - unsigned int section_index; - - if (! next_byte (&(ieee->h))) - return FALSE; - section_index = must_parse_int (&(ieee->h)); - - section = get_section_entry (abfd, ieee, section_index); - - section_type[0] = this_byte_and_next (&(ieee->h)); - - /* Set minimal section attributes. Attributes are - extended later, based on section contents. */ - switch (section_type[0]) - { - case 0xC1: - /* Normal attributes for absolute sections. */ - section_type[1] = this_byte (&(ieee->h)); - section->flags = SEC_ALLOC; - switch (section_type[1]) - { - /* AS Absolute section attributes. */ - case 0xD3: - if (! next_byte (&(ieee->h))) - return FALSE; - section_type[2] = this_byte (&(ieee->h)); - switch (section_type[2]) - { - case 0xD0: - /* Normal code. */ - if (! next_byte (&(ieee->h))) - return FALSE; - section->flags |= SEC_CODE; - break; - case 0xC4: - /* Normal data. */ - if (! next_byte (&(ieee->h))) - return FALSE; - section->flags |= SEC_DATA; - break; - case 0xD2: - if (! next_byte (&(ieee->h))) - return FALSE; - /* Normal rom data. */ - section->flags |= SEC_ROM | SEC_DATA; - break; - default: - break; - } - } - break; - - /* Named relocatable sections (type C). */ - case 0xC3: - section_type[1] = this_byte (&(ieee->h)); - section->flags = SEC_ALLOC; - switch (section_type[1]) - { - case 0xD0: /* Normal code (CP). */ - if (! next_byte (&(ieee->h))) - return FALSE; - section->flags |= SEC_CODE; - break; - case 0xC4: /* Normal data (CD). */ - if (! next_byte (&(ieee->h))) - return FALSE; - section->flags |= SEC_DATA; - break; - case 0xD2: /* Normal rom data (CR). */ - if (! next_byte (&(ieee->h))) - return FALSE; - section->flags |= SEC_ROM | SEC_DATA; - break; - default: - break; - } - } - - /* Read section name, use it if non empty. */ - name = read_id (&ieee->h); - if (name == NULL) - return FALSE; - if (name[0]) - section->name = name; - - /* Skip these fields, which we don't care about. */ - { - bfd_vma parent, brother, context; - - parse_int (&(ieee->h), &parent); - parse_int (&(ieee->h), &brother); - parse_int (&(ieee->h), &context); - } - } - break; - case ieee_section_alignment_enum: - { - unsigned int section_index; - bfd_vma value; - asection *section; - - if (! next_byte (&(ieee->h))) - return FALSE; - section_index = must_parse_int (&ieee->h); - section = get_section_entry (abfd, ieee, section_index); - if (section_index > ieee->section_count) - ieee->section_count = section_index; - - section->alignment_power = - bfd_log2 (must_parse_int (&ieee->h)); - (void) parse_int (&(ieee->h), &value); - } - break; - case ieee_e2_first_byte_enum: - { - asection *section; - ieee_record_enum_type t; - - t = (ieee_record_enum_type) (read_2bytes (&(ieee->h))); - switch (t) - { - case ieee_section_size_enum: - section = ieee->section_table[must_parse_int (&(ieee->h))]; - section->size = must_parse_int (&(ieee->h)); - break; - case ieee_physical_region_size_enum: - section = ieee->section_table[must_parse_int (&(ieee->h))]; - section->size = must_parse_int (&(ieee->h)); - break; - case ieee_region_base_address_enum: - section = ieee->section_table[must_parse_int (&(ieee->h))]; - section->vma = must_parse_int (&(ieee->h)); - section->lma = section->vma; - break; - case ieee_mau_size_enum: - must_parse_int (&(ieee->h)); - must_parse_int (&(ieee->h)); - break; - case ieee_m_value_enum: - must_parse_int (&(ieee->h)); - must_parse_int (&(ieee->h)); - break; - case ieee_section_base_address_enum: - section = ieee->section_table[must_parse_int (&(ieee->h))]; - section->vma = must_parse_int (&(ieee->h)); - section->lma = section->vma; - break; - case ieee_section_offset_enum: - (void) must_parse_int (&(ieee->h)); - (void) must_parse_int (&(ieee->h)); - break; - default: - return TRUE; - } - } - break; - default: - return TRUE; - } - } - } - - return TRUE; -} - -/* Make a section for the debugging information, if any. We don't try - to interpret the debugging information; we just point the section - at the area in the file so that program which understand can dig it - out. */ - -static bfd_boolean -ieee_slurp_debug (bfd *abfd) -{ - ieee_data_type *ieee = IEEE_DATA (abfd); - asection *sec; - file_ptr debug_end; - flagword flags; - - if (ieee->w.r.debug_information_part == 0) - return TRUE; - - flags = SEC_DEBUGGING | SEC_HAS_CONTENTS; - sec = bfd_make_section_with_flags (abfd, ".debug", flags); - if (sec == NULL) - return FALSE; - sec->filepos = ieee->w.r.debug_information_part; - - debug_end = ieee_part_after (ieee, ieee->w.r.debug_information_part); - sec->size = debug_end - ieee->w.r.debug_information_part; - - return TRUE; -} - -/* Archive stuff. */ - -static const bfd_target * -ieee_archive_p (bfd *abfd) -{ - char *library; - unsigned int i; - static unsigned char buffer[512]; - file_ptr buffer_offset = 0; - ieee_ar_data_type *save = abfd->tdata.ieee_ar_data; - ieee_ar_data_type *ieee; - bfd_size_type alc_elts; - ieee_ar_obstack_type *elts = NULL; - bfd_size_type amt = sizeof (ieee_ar_data_type); - - abfd->tdata.ieee_ar_data = bfd_alloc (abfd, amt); - if (!abfd->tdata.ieee_ar_data) - goto error_ret_restore; - ieee = IEEE_AR_DATA (abfd); - - /* Ignore the return value here. It doesn't matter if we don't read - the entire buffer. We might have a very small ieee file. */ - if (bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd) <= 0) - goto got_wrong_format_error; - - ieee->h.first_byte = buffer; - ieee->h.input_p = buffer; - ieee->h.total_amt = sizeof (buffer); - ieee->h.end_p = buffer + sizeof (buffer); - - ieee->h.abfd = abfd; - - if (this_byte (&(ieee->h)) != Module_Beginning) - goto got_wrong_format_error; - - (void) next_byte (&(ieee->h)); - - library = read_id (&(ieee->h)); - if (library == NULL) - goto got_wrong_format_error; - if (strcmp (library, "LIBRARY") != 0) - goto got_wrong_format_error; - - /* Throw away the filename. */ - read_id (&(ieee->h)); - - ieee->element_count = 0; - ieee->element_index = 0; - - (void) next_byte (&(ieee->h)); /* Drop the ad part. */ - must_parse_int (&(ieee->h)); /* And the two dummy numbers. */ - must_parse_int (&(ieee->h)); - - alc_elts = 10; - elts = bfd_malloc (alc_elts * sizeof *elts); - if (elts == NULL) - goto error_return; - - /* Read the index of the BB table. */ - while (1) - { - int rec; - ieee_ar_obstack_type *t; - - rec = read_2bytes (&(ieee->h)); - if (rec != (int) ieee_assign_value_to_variable_enum) - break; - - if (ieee->element_count >= alc_elts) - { - ieee_ar_obstack_type *n; - - alc_elts *= 2; - n = bfd_realloc (elts, alc_elts * sizeof (* elts)); - if (n == NULL) - goto error_return; - elts = n; - } - - t = &elts[ieee->element_count]; - ieee->element_count++; - - must_parse_int (&(ieee->h)); - t->file_offset = must_parse_int (&(ieee->h)); - t->abfd = (bfd *) NULL; - - /* Make sure that we don't go over the end of the buffer. */ - if ((size_t) ieee_pos (IEEE_DATA (abfd)) > sizeof (buffer) / 2) - { - /* Past half way, reseek and reprime. */ - buffer_offset += ieee_pos (IEEE_DATA (abfd)); - if (bfd_seek (abfd, buffer_offset, SEEK_SET) != 0) - goto error_return; - - /* Again ignore return value of bfd_bread. */ - bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd); - ieee->h.first_byte = buffer; - ieee->h.input_p = buffer; - ieee->h.total_amt = sizeof (buffer); - ieee->h.end_p = buffer + sizeof (buffer); - } - } - - amt = ieee->element_count; - amt *= sizeof *ieee->elements; - ieee->elements = bfd_alloc (abfd, amt); - if (ieee->elements == NULL) - goto error_return; - - memcpy (ieee->elements, elts, (size_t) amt); - free (elts); - elts = NULL; - - /* Now scan the area again, and replace BB offsets with file offsets. */ - for (i = 2; i < ieee->element_count; i++) - { - if (bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET) != 0) - goto error_return; - - /* Again ignore return value of bfd_bread. */ - bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd); - ieee->h.first_byte = buffer; - ieee->h.input_p = buffer; - ieee->h.total_amt = sizeof (buffer); - ieee->h.end_p = buffer + sizeof (buffer); - - (void) next_byte (&(ieee->h)); /* Drop F8. */ - if (! next_byte (&(ieee->h))) /* Drop 14. */ - goto error_return; - must_parse_int (&(ieee->h)); /* Drop size of block. */ - - if (must_parse_int (&(ieee->h)) != 0) - /* This object has been deleted. */ - ieee->elements[i].file_offset = 0; - else - ieee->elements[i].file_offset = must_parse_int (&(ieee->h)); - } - - /* abfd->has_armap = ;*/ - - return abfd->xvec; - - got_wrong_format_error: - bfd_set_error (bfd_error_wrong_format); - error_return: - if (elts != NULL) - free (elts); - bfd_release (abfd, ieee); - error_ret_restore: - abfd->tdata.ieee_ar_data = save; - - return NULL; -} - -static bfd_boolean -ieee_mkobject (bfd *abfd) -{ - bfd_size_type amt; - - output_ptr_start = NULL; - output_ptr = NULL; - output_ptr_end = NULL; - input_ptr_start = NULL; - input_ptr = NULL; - input_ptr_end = NULL; - input_bfd = NULL; - output_bfd = NULL; - output_buffer = 0; - amt = sizeof (ieee_data_type); - abfd->tdata.ieee_data = bfd_zalloc (abfd, amt); - return abfd->tdata.ieee_data != NULL; -} - -static bfd_boolean -do_one (ieee_data_type *ieee, - ieee_per_section_type *current_map, - unsigned char *location_ptr, - asection *s, - int iterations) -{ - switch (this_byte (&(ieee->h))) - { - case ieee_load_constant_bytes_enum: - { - unsigned int number_of_maus; - unsigned int i; - - if (! next_byte (&(ieee->h))) - return FALSE; - number_of_maus = must_parse_int (&(ieee->h)); - - for (i = 0; i < number_of_maus; i++) - { - location_ptr[current_map->pc++] = this_byte (&(ieee->h)); - next_byte (&(ieee->h)); - } - } - break; - - case ieee_load_with_relocation_enum: - { - bfd_boolean loop = TRUE; - - if (! next_byte (&(ieee->h))) - return FALSE; - while (loop) - { - switch (this_byte (&(ieee->h))) - { - case ieee_variable_R_enum: - - case ieee_function_signed_open_b_enum: - case ieee_function_unsigned_open_b_enum: - case ieee_function_either_open_b_enum: - { - unsigned int extra = 4; - bfd_boolean pcrel = FALSE; - asection *section; - ieee_reloc_type *r; - - r = bfd_alloc (ieee->h.abfd, sizeof (* r)); - if (!r) - return FALSE; - - *(current_map->reloc_tail_ptr) = r; - current_map->reloc_tail_ptr = &r->next; - r->next = (ieee_reloc_type *) NULL; - if (! next_byte (&(ieee->h))) - return FALSE; - - r->relent.sym_ptr_ptr = 0; - if (! parse_expression (ieee, - &r->relent.addend, - &r->symbol, - &pcrel, &extra, §ion)) - return FALSE; - - r->relent.address = current_map->pc; - s->flags |= SEC_RELOC; - s->owner->flags |= HAS_RELOC; - s->reloc_count++; - if (r->relent.sym_ptr_ptr == NULL && section != NULL) - r->relent.sym_ptr_ptr = section->symbol_ptr_ptr; - - if (this_byte (&(ieee->h)) == (int) ieee_comma) - { - if (! next_byte (&(ieee->h))) - return FALSE; - /* Fetch number of bytes to pad. */ - extra = must_parse_int (&(ieee->h)); - }; - - switch (this_byte (&(ieee->h))) - { - case ieee_function_signed_close_b_enum: - if (! next_byte (&(ieee->h))) - return FALSE; - break; - case ieee_function_unsigned_close_b_enum: - if (! next_byte (&(ieee->h))) - return FALSE; - break; - case ieee_function_either_close_b_enum: - if (! next_byte (&(ieee->h))) - return FALSE; - break; - default: - break; - } - /* Build a relocation entry for this type. */ - /* If pc rel then stick -ve pc into instruction - and take out of reloc .. - - I've changed this. It's all too complicated. I - keep 0 in the instruction now. */ - - switch (extra) - { - case 0: - case 4: - - if (pcrel) - { -#if KEEPMINUSPCININST - bfd_put_32 (ieee->h.abfd, -current_map->pc, - location_ptr + current_map->pc); - r->relent.howto = &rel32_howto; - r->relent.addend -= current_map->pc; -#else - bfd_put_32 (ieee->h.abfd, (bfd_vma) 0, location_ptr + - current_map->pc); - r->relent.howto = &rel32_howto; -#endif - } - else - { - bfd_put_32 (ieee->h.abfd, (bfd_vma) 0, - location_ptr + current_map->pc); - r->relent.howto = &abs32_howto; - } - current_map->pc += 4; - break; - case 2: - if (pcrel) - { -#if KEEPMINUSPCININST - bfd_put_16 (ieee->h.abfd, (bfd_vma) -current_map->pc, - location_ptr + current_map->pc); - r->relent.addend -= current_map->pc; - r->relent.howto = &rel16_howto; -#else - - bfd_put_16 (ieee->h.abfd, (bfd_vma) 0, - location_ptr + current_map->pc); - r->relent.howto = &rel16_howto; -#endif - } - - else - { - bfd_put_16 (ieee->h.abfd, (bfd_vma) 0, - location_ptr + current_map->pc); - r->relent.howto = &abs16_howto; - } - current_map->pc += 2; - break; - case 1: - if (pcrel) - { -#if KEEPMINUSPCININST - bfd_put_8 (ieee->h.abfd, (int) (-current_map->pc), location_ptr + current_map->pc); - r->relent.addend -= current_map->pc; - r->relent.howto = &rel8_howto; -#else - bfd_put_8 (ieee->h.abfd, 0, location_ptr + current_map->pc); - r->relent.howto = &rel8_howto; -#endif - } - else - { - bfd_put_8 (ieee->h.abfd, 0, location_ptr + current_map->pc); - r->relent.howto = &abs8_howto; - } - current_map->pc += 1; - break; - - default: - BFD_FAIL (); - return FALSE; - } - } - break; - default: - { - bfd_vma this_size; - - if (parse_int (&(ieee->h), &this_size)) - { - unsigned int i; - - for (i = 0; i < this_size; i++) - { - location_ptr[current_map->pc++] = this_byte (&(ieee->h)); - if (! next_byte (&(ieee->h))) - return FALSE; - } - } - else - loop = FALSE; - } - } - - /* Prevent more than the first load-item of an LR record - from being repeated (MRI convention). */ - if (iterations != 1) - loop = FALSE; - } - } - } - return TRUE; -} - -/* Read in all the section data and relocation stuff too. */ - -static bfd_boolean -ieee_slurp_section_data (bfd *abfd) -{ - bfd_byte *location_ptr = (bfd_byte *) NULL; - ieee_data_type *ieee = IEEE_DATA (abfd); - unsigned int section_number; - ieee_per_section_type *current_map = NULL; - asection *s; - - /* Seek to the start of the data area. */ - if (ieee->read_data) - return TRUE; - ieee->read_data = TRUE; - - if (! ieee_seek (ieee, ieee->w.r.data_part)) - return FALSE; - - /* Allocate enough space for all the section contents. */ - for (s = abfd->sections; s != (asection *) NULL; s = s->next) - { - ieee_per_section_type *per = ieee_per_section (s); - arelent **relpp; - - if ((s->flags & SEC_DEBUGGING) != 0) - continue; - per->data = bfd_alloc (ieee->h.abfd, s->size); - if (!per->data) - return FALSE; - relpp = &s->relocation; - per->reloc_tail_ptr = (ieee_reloc_type **) relpp; - } - - while (TRUE) - { - switch (this_byte (&(ieee->h))) - { - /* IF we see anything strange then quit. */ - default: - return TRUE; - - case ieee_set_current_section_enum: - if (! next_byte (&(ieee->h))) - return FALSE; - section_number = must_parse_int (&(ieee->h)); - s = ieee->section_table[section_number]; - s->flags |= SEC_LOAD | SEC_HAS_CONTENTS; - current_map = ieee_per_section (s); - location_ptr = current_map->data - s->vma; - /* The document I have says that Microtec's compilers reset - this after a sec section, even though the standard says not - to, SO... */ - current_map->pc = s->vma; - break; - - case ieee_e2_first_byte_enum: - if (! next_byte (&(ieee->h))) - return FALSE; - switch (this_byte (&(ieee->h))) - { - case ieee_set_current_pc_enum & 0xff: - { - bfd_vma value; - ieee_symbol_index_type symbol; - unsigned int extra; - bfd_boolean pcrel; - - if (! next_byte (&(ieee->h))) - return FALSE; - must_parse_int (&(ieee->h)); /* Throw away section #. */ - if (! parse_expression (ieee, &value, - &symbol, - &pcrel, &extra, - 0)) - return FALSE; - - current_map->pc = value; - BFD_ASSERT ((unsigned) (value - s->vma) <= s->size); - } - break; - - case ieee_value_starting_address_enum & 0xff: - if (! next_byte (&(ieee->h))) - return FALSE; - if (this_byte (&(ieee->h)) == ieee_function_either_open_b_enum) - { - if (! next_byte (&(ieee->h))) - return FALSE; - } - abfd->start_address = must_parse_int (&(ieee->h)); - /* We've got to the end of the data now - */ - return TRUE; - default: - BFD_FAIL (); - return FALSE; - } - break; - case ieee_repeat_data_enum: - { - /* Repeat the following LD or LR n times - we do this by - remembering the stream pointer before running it and - resetting it and running it n times. We special case - the repetition of a repeat_data/load_constant. */ - unsigned int iterations; - unsigned char *start; - - if (! next_byte (&(ieee->h))) - return FALSE; - iterations = must_parse_int (&(ieee->h)); - start = ieee->h.input_p; - if (start[0] == (int) ieee_load_constant_bytes_enum - && start[1] == 1) - { - while (iterations != 0) - { - location_ptr[current_map->pc++] = start[2]; - iterations--; - } - (void) next_byte (&(ieee->h)); - (void) next_byte (&(ieee->h)); - if (! next_byte (&(ieee->h))) - return FALSE; - } - else - { - while (iterations != 0) - { - ieee->h.input_p = start; - if (!do_one (ieee, current_map, location_ptr, s, - (int) iterations)) - return FALSE; - iterations--; - } - } - } - break; - case ieee_load_constant_bytes_enum: - case ieee_load_with_relocation_enum: - if (!do_one (ieee, current_map, location_ptr, s, 1)) - return FALSE; - } - } -} - -static const bfd_target * -ieee_object_p (bfd *abfd) -{ - char *processor; - unsigned int part; - ieee_data_type *ieee; - static unsigned char buffer[300]; - ieee_data_type *save = IEEE_DATA (abfd); - bfd_size_type amt; - - abfd->tdata.ieee_data = 0; - ieee_mkobject (abfd); - - ieee = IEEE_DATA (abfd); - if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) - goto fail; - /* Read the first few bytes in to see if it makes sense. Ignore - bfd_bread return value; The file might be very small. */ - if (bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd) <= 0) - goto got_wrong_format; - - ieee->h.input_p = buffer; - ieee->h.total_amt = sizeof (buffer); - ieee->h.end_p = buffer + sizeof (buffer); - - if (this_byte_and_next (&(ieee->h)) != Module_Beginning) - goto got_wrong_format; - - ieee->read_symbols = FALSE; - ieee->read_data = FALSE; - ieee->section_count = 0; - ieee->external_symbol_max_index = 0; - ieee->external_symbol_min_index = IEEE_PUBLIC_BASE; - ieee->external_reference_min_index = IEEE_REFERENCE_BASE; - ieee->external_reference_max_index = 0; - ieee->h.abfd = abfd; - ieee->section_table = NULL; - ieee->section_table_size = 0; - - processor = ieee->mb.processor = read_id (&(ieee->h)); - if (processor == NULL) - goto got_wrong_format; - if (strcmp (processor, "LIBRARY") == 0) - goto got_wrong_format; - ieee->mb.module_name = read_id (&(ieee->h)); - if (ieee->mb.module_name == NULL) - goto got_wrong_format; - if (abfd->filename == (const char *) NULL) - abfd->filename = xstrdup (ieee->mb.module_name); - - /* Determine the architecture and machine type of the object file. */ - { - const bfd_arch_info_type *arch; - char family[10]; - - /* IEEE does not specify the format of the processor identification - string, so the compiler is free to put in it whatever it wants. - We try here to recognize different processors belonging to the - m68k family. Code for other processors can be added here. */ - if ((processor[0] == '6') && (processor[1] == '8')) - { - if (processor[2] == '3') /* 683xx integrated processors. */ - { - switch (processor[3]) - { - case '0': /* 68302, 68306, 68307 */ - case '2': /* 68322, 68328 */ - case '5': /* 68356 */ - strcpy (family, "68000"); /* MC68000-based controllers. */ - break; - - case '3': /* 68330, 68331, 68332, 68333, - 68334, 68335, 68336, 68338 */ - case '6': /* 68360 */ - case '7': /* 68376 */ - strcpy (family, "68332"); /* CPU32 and CPU32+ */ - break; - - case '4': - if (processor[4] == '9') /* 68349 */ - strcpy (family, "68030"); /* CPU030 */ - else /* 68340, 68341 */ - strcpy (family, "68332"); /* CPU32 and CPU32+ */ - break; - - default: /* Does not exist yet. */ - strcpy (family, "68332"); /* Guess it will be CPU32 */ - } - } - else if (TOUPPER (processor[3]) == 'F') /* 68F333 */ - strcpy (family, "68332"); /* CPU32 */ - else if ((TOUPPER (processor[3]) == 'C') /* Embedded controllers. */ - && ((TOUPPER (processor[2]) == 'E') - || (TOUPPER (processor[2]) == 'H') - || (TOUPPER (processor[2]) == 'L'))) - { - strcpy (family, "68"); - strncat (family, processor + 4, 7); - family[9] = '\0'; - } - else /* "Regular" processors. */ - { - strncpy (family, processor, 9); - family[9] = '\0'; - } - } - else if ((CONST_STRNEQ (processor, "cpu32")) /* CPU32 and CPU32+ */ - || (CONST_STRNEQ (processor, "CPU32"))) - strcpy (family, "68332"); - else - { - strncpy (family, processor, 9); - family[9] = '\0'; - } - - arch = bfd_scan_arch (family); - if (arch == 0) - goto got_wrong_format; - abfd->arch_info = arch; - } - - if (this_byte (&(ieee->h)) != (int) ieee_address_descriptor_enum) - goto fail; - - if (! next_byte (&(ieee->h))) - goto fail; - - if (! parse_int (&(ieee->h), &ieee->ad.number_of_bits_mau)) - goto fail; - - if (! parse_int (&(ieee->h), &ieee->ad.number_of_maus_in_address)) - goto fail; - - /* If there is a byte order info, take it. */ - if (this_byte (&(ieee->h)) == (int) ieee_variable_L_enum - || this_byte (&(ieee->h)) == (int) ieee_variable_M_enum) - { - if (! next_byte (&(ieee->h))) - goto fail; - } - - for (part = 0; part < N_W_VARIABLES; part++) - { - bfd_boolean ok; - - if (read_2bytes (&(ieee->h)) != (int) ieee_assign_value_to_variable_enum) - goto fail; - - if (this_byte_and_next (&(ieee->h)) != part) - goto fail; - - ieee->w.offset[part] = parse_i (&(ieee->h), &ok); - if (! ok) - goto fail; - } - - if (ieee->w.r.external_part != 0) - abfd->flags = HAS_SYMS; - - /* By now we know that this is a real IEEE file, we're going to read - the whole thing into memory so that we can run up and down it - quickly. We can work out how big the file is from the trailer - record. */ - - amt = ieee->w.r.me_record + 1; - IEEE_DATA (abfd)->h.first_byte = bfd_alloc (ieee->h.abfd, amt); - if (!IEEE_DATA (abfd)->h.first_byte) - goto fail; - if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) - goto fail; - - /* FIXME: Check return value. I'm not sure whether it needs to read - the entire buffer or not. */ - amt = bfd_bread ((void *) (IEEE_DATA (abfd)->h.first_byte), - (bfd_size_type) ieee->w.r.me_record + 1, abfd); - if (amt <= 0) - goto fail; - - IEEE_DATA (abfd)->h.total_amt = amt; - if (ieee_slurp_sections (abfd)) - goto fail; - - if (! ieee_slurp_debug (abfd)) - goto fail; - - /* Parse section data to activate file and section flags implied by - section contents. */ - if (! ieee_slurp_section_data (abfd)) - goto fail; - - return abfd->xvec; -got_wrong_format: - bfd_set_error (bfd_error_wrong_format); -fail: - bfd_release (abfd, ieee); - abfd->tdata.ieee_data = save; - return (const bfd_target *) NULL; -} - -static void -ieee_get_symbol_info (bfd *ignore_abfd ATTRIBUTE_UNUSED, - asymbol *symbol, - symbol_info *ret) -{ - bfd_symbol_info (symbol, ret); - if (symbol->name[0] == ' ') - ret->name = "* empty table entry "; - if (!symbol->section) - ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A'; -} - -static void -ieee_print_symbol (bfd *abfd, - void * afile, - asymbol *symbol, - bfd_print_symbol_type how) -{ - FILE *file = (FILE *) afile; - - switch (how) - { - case bfd_print_symbol_name: - fprintf (file, "%s", symbol->name); - break; - case bfd_print_symbol_more: - BFD_FAIL (); - break; - case bfd_print_symbol_all: - { - const char *section_name = - (symbol->section == (asection *) NULL - ? "*abs" - : symbol->section->name); - - if (symbol->name[0] == ' ') - fprintf (file, "* empty table entry "); - else - { - bfd_print_symbol_vandf (abfd, (void *) file, symbol); - - fprintf (file, " %-5s %04x %02x %s", - section_name, - (unsigned) ieee_symbol (symbol)->index, - (unsigned) 0, - symbol->name); - } - } - break; - } -} - -static bfd_boolean -ieee_new_section_hook (bfd *abfd, asection *newsect) -{ - if (!newsect->used_by_bfd) - { - newsect->used_by_bfd = bfd_alloc (abfd, sizeof (ieee_per_section_type)); - if (!newsect->used_by_bfd) - return FALSE; - } - ieee_per_section (newsect)->data = NULL; - ieee_per_section (newsect)->section = newsect; - return _bfd_generic_new_section_hook (abfd, newsect); -} - -static long -ieee_get_reloc_upper_bound (bfd *abfd, sec_ptr asect) -{ - if ((asect->flags & SEC_DEBUGGING) != 0) - return 0; - if (! ieee_slurp_section_data (abfd)) - return -1; - return (asect->reloc_count + 1) * sizeof (arelent *); -} - -static bfd_boolean -ieee_get_section_contents (bfd *abfd, - sec_ptr section, - void * location, - file_ptr offset, - bfd_size_type count) -{ - ieee_per_section_type *p = ieee_per_section (section); - if ((section->flags & SEC_DEBUGGING) != 0) - return _bfd_generic_get_section_contents (abfd, section, location, - offset, count); - ieee_slurp_section_data (abfd); - (void) memcpy ((void *) location, (void *) (p->data + offset), (unsigned) count); - return TRUE; -} - -static long -ieee_canonicalize_reloc (bfd *abfd, - sec_ptr section, - arelent **relptr, - asymbol **symbols) -{ - ieee_reloc_type *src = (ieee_reloc_type *) (section->relocation); - ieee_data_type *ieee = IEEE_DATA (abfd); - - if ((section->flags & SEC_DEBUGGING) != 0) - return 0; - - while (src != (ieee_reloc_type *) NULL) - { - /* Work out which symbol to attach it this reloc to. */ - switch (src->symbol.letter) - { - case 'I': - src->relent.sym_ptr_ptr = - symbols + src->symbol.index + ieee->external_symbol_base_offset; - break; - case 'X': - src->relent.sym_ptr_ptr = - symbols + src->symbol.index + ieee->external_reference_base_offset; - break; - case 0: - if (src->relent.sym_ptr_ptr != NULL) - src->relent.sym_ptr_ptr = - src->relent.sym_ptr_ptr[0]->section->symbol_ptr_ptr; - break; - default: - - BFD_FAIL (); - } - *relptr++ = &src->relent; - src = src->next; - } - *relptr = NULL; - return section->reloc_count; -} - -static int -comp (const void * ap, const void * bp) -{ - arelent *a = *((arelent **) ap); - arelent *b = *((arelent **) bp); - return a->address - b->address; -} - -/* Write the section headers. */ - -static bfd_boolean -ieee_write_section_part (bfd *abfd) -{ - ieee_data_type *ieee = IEEE_DATA (abfd); - asection *s; - - ieee->w.r.section_part = bfd_tell (abfd); - for (s = abfd->sections; s != (asection *) NULL; s = s->next) - { - if (! bfd_is_abs_section (s) - && (s->flags & SEC_DEBUGGING) == 0) - { - if (! ieee_write_byte (abfd, ieee_section_type_enum) - || ! ieee_write_byte (abfd, - (bfd_byte) (s->index - + IEEE_SECTION_NUMBER_BASE))) - return FALSE; - - if (abfd->flags & EXEC_P) - { - /* This image is executable, so output absolute sections. */ - if (! ieee_write_byte (abfd, ieee_variable_A_enum) - || ! ieee_write_byte (abfd, ieee_variable_S_enum)) - return FALSE; - } - else - { - if (! ieee_write_byte (abfd, ieee_variable_C_enum)) - return FALSE; - } - - switch (s->flags & (SEC_CODE | SEC_DATA | SEC_ROM)) - { - case SEC_CODE | SEC_LOAD: - case SEC_CODE: - if (! ieee_write_byte (abfd, ieee_variable_P_enum)) - return FALSE; - break; - case SEC_DATA: - default: - if (! ieee_write_byte (abfd, ieee_variable_D_enum)) - return FALSE; - break; - case SEC_ROM: - case SEC_ROM | SEC_DATA: - case SEC_ROM | SEC_LOAD: - case SEC_ROM | SEC_DATA | SEC_LOAD: - if (! ieee_write_byte (abfd, ieee_variable_R_enum)) - return FALSE; - } - - - if (! ieee_write_id (abfd, s->name)) - return FALSE; - /* Alignment. */ - if (! ieee_write_byte (abfd, ieee_section_alignment_enum) - || ! ieee_write_byte (abfd, - (bfd_byte) (s->index - + IEEE_SECTION_NUMBER_BASE)) - || ! ieee_write_int (abfd, (bfd_vma) 1 << s->alignment_power)) - return FALSE; - - /* Size. */ - if (! ieee_write_2bytes (abfd, ieee_section_size_enum) - || ! ieee_write_byte (abfd, - (bfd_byte) (s->index - + IEEE_SECTION_NUMBER_BASE)) - || ! ieee_write_int (abfd, s->size)) - return FALSE; - if (abfd->flags & EXEC_P) - { - /* Relocateable sections don't have asl records. */ - /* Vma. */ - if (! ieee_write_2bytes (abfd, ieee_section_base_address_enum) - || ! ieee_write_byte (abfd, - ((bfd_byte) - (s->index - + IEEE_SECTION_NUMBER_BASE))) - || ! ieee_write_int (abfd, s->lma)) - return FALSE; - } - } - } - - return TRUE; -} - -static bfd_boolean -do_with_relocs (bfd *abfd, asection *s) -{ - unsigned int number_of_maus_in_address = - bfd_arch_bits_per_address (abfd) / bfd_arch_bits_per_byte (abfd); - unsigned int relocs_to_go = s->reloc_count; - bfd_byte *stream = ieee_per_section (s)->data; - arelent **p = s->orelocation; - bfd_size_type current_byte_index = 0; - - qsort (s->orelocation, - relocs_to_go, - sizeof (arelent **), - comp); - - /* Output the section preheader. */ - if (! ieee_write_byte (abfd, ieee_set_current_section_enum) - || ! ieee_write_byte (abfd, - (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE)) - || ! ieee_write_2bytes (abfd, ieee_set_current_pc_enum) - || ! ieee_write_byte (abfd, - (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE))) - return FALSE; - - if ((abfd->flags & EXEC_P) != 0 && relocs_to_go == 0) - { - if (! ieee_write_int (abfd, s->lma)) - return FALSE; - } - else - { - if (! ieee_write_expression (abfd, (bfd_vma) 0, s->symbol, 0, 0)) - return FALSE; - } - - if (relocs_to_go == 0) - { - /* If there aren't any relocations then output the load constant - byte opcode rather than the load with relocation opcode. */ - while (current_byte_index < s->size) - { - bfd_size_type run; - unsigned int MAXRUN = 127; - - run = MAXRUN; - if (run > s->size - current_byte_index) - run = s->size - current_byte_index; - - if (run != 0) - { - if (! ieee_write_byte (abfd, ieee_load_constant_bytes_enum)) - return FALSE; - /* Output a stream of bytes. */ - if (! ieee_write_int (abfd, run)) - return FALSE; - if (bfd_bwrite ((void *) (stream + current_byte_index), run, abfd) - != run) - return FALSE; - current_byte_index += run; - } - } - } - else - { - if (! ieee_write_byte (abfd, ieee_load_with_relocation_enum)) - return FALSE; - - /* Output the data stream as the longest sequence of bytes - possible, allowing for the a reasonable packet size and - relocation stuffs. */ - if (stream == NULL) - { - /* Outputting a section without data, fill it up. */ - stream = bfd_zalloc (abfd, s->size); - if (!stream) - return FALSE; - } - while (current_byte_index < s->size) - { - bfd_size_type run; - unsigned int MAXRUN = 127; - - if (relocs_to_go) - { - run = (*p)->address - current_byte_index; - if (run > MAXRUN) - run = MAXRUN; - } - else - run = MAXRUN; - - if (run > s->size - current_byte_index) - run = s->size - current_byte_index; - - if (run != 0) - { - /* Output a stream of bytes. */ - if (! ieee_write_int (abfd, run)) - return FALSE; - if (bfd_bwrite ((void *) (stream + current_byte_index), run, abfd) - != run) - return FALSE; - current_byte_index += run; - } - - /* Output any relocations here. */ - if (relocs_to_go && (*p) && (*p)->address == current_byte_index) - { - while (relocs_to_go - && (*p) && (*p)->address == current_byte_index) - { - arelent *r = *p; - bfd_signed_vma ov; - switch (r->howto->size) - { - case 2: - ov = bfd_get_signed_32 (abfd, - stream + current_byte_index); - current_byte_index += 4; - break; - case 1: - ov = bfd_get_signed_16 (abfd, - stream + current_byte_index); - current_byte_index += 2; - break; - case 0: - ov = bfd_get_signed_8 (abfd, - stream + current_byte_index); - current_byte_index++; - break; - default: - ov = 0; - BFD_FAIL (); - return FALSE; - } - - ov &= r->howto->src_mask; - - if (r->howto->pc_relative - && ! r->howto->pcrel_offset) - ov += r->address; - - if (! ieee_write_byte (abfd, - ieee_function_either_open_b_enum)) - return FALSE; - - if (r->sym_ptr_ptr != (asymbol **) NULL) - { - if (! ieee_write_expression (abfd, r->addend + ov, - *(r->sym_ptr_ptr), - r->howto->pc_relative, - (unsigned) s->index)) - return FALSE; - } - else - { - if (! ieee_write_expression (abfd, r->addend + ov, - (asymbol *) NULL, - r->howto->pc_relative, - (unsigned) s->index)) - return FALSE; - } - - if (number_of_maus_in_address - != bfd_get_reloc_size (r->howto)) - { - bfd_vma rsize = bfd_get_reloc_size (r->howto); - if (! ieee_write_int (abfd, rsize)) - return FALSE; - } - if (! ieee_write_byte (abfd, - ieee_function_either_close_b_enum)) - return FALSE; - - relocs_to_go--; - p++; - } - - } - } - } - - return TRUE; -} - -/* If there are no relocations in the output section then we can be - clever about how we write. We block items up into a max of 127 - bytes. */ - -static bfd_boolean -do_as_repeat (bfd *abfd, asection *s) -{ - if (s->size) - { - if (! ieee_write_byte (abfd, ieee_set_current_section_enum) - || ! ieee_write_byte (abfd, - (bfd_byte) (s->index - + IEEE_SECTION_NUMBER_BASE)) - || ! ieee_write_byte (abfd, ieee_set_current_pc_enum >> 8) - || ! ieee_write_byte (abfd, ieee_set_current_pc_enum & 0xff) - || ! ieee_write_byte (abfd, - (bfd_byte) (s->index - + IEEE_SECTION_NUMBER_BASE))) - return FALSE; - - if ((abfd->flags & EXEC_P) != 0) - { - if (! ieee_write_int (abfd, s->lma)) - return FALSE; - } - else - { - if (! ieee_write_expression (abfd, (bfd_vma) 0, s->symbol, 0, 0)) - return FALSE; - } - - if (! ieee_write_byte (abfd, ieee_repeat_data_enum) - || ! ieee_write_int (abfd, s->size) - || ! ieee_write_byte (abfd, ieee_load_constant_bytes_enum) - || ! ieee_write_byte (abfd, 1) - || ! ieee_write_byte (abfd, 0)) - return FALSE; - } - - return TRUE; -} - -static bfd_boolean -do_without_relocs (bfd *abfd, asection *s) -{ - bfd_byte *stream = ieee_per_section (s)->data; - - if (stream == 0 || ((s->flags & SEC_LOAD) == 0)) - { - if (! do_as_repeat (abfd, s)) - return FALSE; - } - else - { - unsigned int i; - - for (i = 0; i < s->size; i++) - { - if (stream[i] != 0) - { - if (! do_with_relocs (abfd, s)) - return FALSE; - return TRUE; - } - } - if (! do_as_repeat (abfd, s)) - return FALSE; - } - - return TRUE; -} - -static void -fill (void) -{ - bfd_size_type amt = input_ptr_end - input_ptr_start; - /* FIXME: Check return value. I'm not sure whether it needs to read - the entire buffer or not. */ - bfd_bread ((void *) input_ptr_start, amt, input_bfd); - input_ptr = input_ptr_start; -} - -static void -flush (void) -{ - bfd_size_type amt = output_ptr - output_ptr_start; - - if (bfd_bwrite ((void *) (output_ptr_start), amt, output_bfd) != amt) - abort (); - output_ptr = output_ptr_start; - output_buffer++; -} - -#define THIS() ( *input_ptr ) -#define NEXT() { input_ptr++; if (input_ptr == input_ptr_end) fill (); } -#define OUT(x) { *output_ptr++ = (x); if (output_ptr == output_ptr_end) flush (); } - -static void -write_int (int value) -{ - if (value >= 0 && value <= 127) - { - OUT (value); - } - else - { - unsigned int length; - - /* How many significant bytes ? */ - /* FIXME FOR LONGER INTS. */ - if (value & 0xff000000) - length = 4; - else if (value & 0x00ff0000) - length = 3; - else if (value & 0x0000ff00) - length = 2; - else - length = 1; - - OUT ((int) ieee_number_repeat_start_enum + length); - switch (length) - { - case 4: - OUT (value >> 24); - /* Fall through. */ - case 3: - OUT (value >> 16); - /* Fall through. */ - case 2: - OUT (value >> 8); - /* Fall through. */ - case 1: - OUT (value); - } - } -} - -static void -copy_id (void) -{ - int length = THIS (); - char ch; - - OUT (length); - NEXT (); - while (length--) - { - ch = THIS (); - OUT (ch); - NEXT (); - } -} - -#define VAR(x) ((x | 0x80)) -static void -copy_expression (void) -{ - int stack[10]; - int *tos = stack; - int value; - - while (1) - { - switch (THIS ()) - { - case 0x84: - NEXT (); - value = THIS (); - NEXT (); - value = (value << 8) | THIS (); - NEXT (); - value = (value << 8) | THIS (); - NEXT (); - value = (value << 8) | THIS (); - NEXT (); - *tos++ = value; - break; - case 0x83: - NEXT (); - value = THIS (); - NEXT (); - value = (value << 8) | THIS (); - NEXT (); - value = (value << 8) | THIS (); - NEXT (); - *tos++ = value; - break; - case 0x82: - NEXT (); - value = THIS (); - NEXT (); - value = (value << 8) | THIS (); - NEXT (); - *tos++ = value; - break; - case 0x81: - NEXT (); - value = THIS (); - NEXT (); - *tos++ = value; - break; - case 0x80: - NEXT (); - *tos++ = 0; - break; - default: - if (THIS () > 0x84) - { - /* Not a number, just bug out with the answer. */ - write_int (*(--tos)); - return; - } - *tos++ = THIS (); - NEXT (); - break; - case 0xa5: - /* PLUS anything. */ - value = *(--tos); - value += *(--tos); - *tos++ = value; - NEXT (); - break; - case VAR ('R'): - { - int section_number; - ieee_data_type *ieee; - asection *s; - - NEXT (); - section_number = THIS (); - - NEXT (); - ieee = IEEE_DATA (input_bfd); - s = ieee->section_table[section_number]; - value = 0; - if (s->output_section) - value = s->output_section->lma; - value += s->output_offset; - *tos++ = value; - } - break; - case 0x90: - { - NEXT (); - write_int (*(--tos)); - OUT (0x90); - return; - } - } - } -} - -/* Drop the int in the buffer, and copy a null into the gap, which we - will overwrite later. */ - -static void -fill_int (struct output_buffer_struct *buf) -{ - if (buf->buffer == output_buffer) - { - /* Still a chance to output the size. */ - int value = output_ptr - buf->ptrp + 3; - buf->ptrp[0] = value >> 24; - buf->ptrp[1] = value >> 16; - buf->ptrp[2] = value >> 8; - buf->ptrp[3] = value >> 0; - } -} - -static void -drop_int (struct output_buffer_struct *buf) -{ - int type = THIS (); - int ch; - - if (type <= 0x84) - { - NEXT (); - switch (type) - { - case 0x84: - ch = THIS (); - NEXT (); - /* Fall through. */ - case 0x83: - ch = THIS (); - NEXT (); - /* Fall through. */ - case 0x82: - ch = THIS (); - NEXT (); - /* Fall through. */ - case 0x81: - ch = THIS (); - NEXT (); - /* Fall through. */ - case 0x80: - break; - } - } - (void) ch; - OUT (0x84); - buf->ptrp = output_ptr; - buf->buffer = output_buffer; - OUT (0); - OUT (0); - OUT (0); - OUT (0); -} - -static void -copy_int (void) -{ - int type = THIS (); - int ch; - if (type <= 0x84) - { - OUT (type); - NEXT (); - switch (type) - { - case 0x84: - ch = THIS (); - NEXT (); - OUT (ch); - /* Fall through. */ - case 0x83: - ch = THIS (); - NEXT (); - OUT (ch); - /* Fall through. */ - case 0x82: - ch = THIS (); - NEXT (); - OUT (ch); - /* Fall through. */ - case 0x81: - ch = THIS (); - NEXT (); - OUT (ch); - /* Fall through. */ - case 0x80: - break; - } - } -} - -#define ID copy_id () -#define INT copy_int () -#define EXP copy_expression () -#define INTn(q) copy_int () -#define EXPn(q) copy_expression () - -static void -copy_till_end (void) -{ - int ch = THIS (); - - while (1) - { - while (ch <= 0x80) - { - OUT (ch); - NEXT (); - ch = THIS (); - } - switch (ch) - { - case 0x84: - OUT (THIS ()); - NEXT (); - /* Fall through. */ - case 0x83: - OUT (THIS ()); - NEXT (); - /* Fall through. */ - case 0x82: - OUT (THIS ()); - NEXT (); - /* Fall through. */ - case 0x81: - OUT (THIS ()); - NEXT (); - OUT (THIS ()); - NEXT (); - - ch = THIS (); - break; - default: - return; - } - } - -} - -static void -f1_record (void) -{ - int ch; - - /* ATN record. */ - NEXT (); - ch = THIS (); - switch (ch) - { - default: - OUT (0xf1); - OUT (ch); - break; - case 0xc9: - NEXT (); - OUT (0xf1); - OUT (0xc9); - INT; - INT; - ch = THIS (); - switch (ch) - { - case 0x16: - NEXT (); - break; - case 0x01: - NEXT (); - break; - case 0x00: - NEXT (); - INT; - break; - case 0x03: - NEXT (); - INT; - break; - case 0x13: - EXPn (instruction address); - break; - default: - break; - } - break; - case 0xd8: - /* EXternal ref. */ - NEXT (); - OUT (0xf1); - OUT (0xd8); - EXP; - EXP; - EXP; - EXP; - break; - case 0xce: - NEXT (); - OUT (0xf1); - OUT (0xce); - INT; - INT; - ch = THIS (); - INT; - switch (ch) - { - case 0x01: - INT; - INT; - break; - case 0x02: - INT; - break; - case 0x04: - EXPn (external function); - break; - case 0x05: - break; - case 0x07: - INTn (line number); - INT; - case 0x08: - break; - case 0x0a: - INTn (locked register); - INT; - break; - case 0x3f: - copy_till_end (); - break; - case 0x3e: - copy_till_end (); - break; - case 0x40: - copy_till_end (); - break; - case 0x41: - ID; - break; - } - } -} - -static void -f0_record (void) -{ - /* Attribute record. */ - NEXT (); - OUT (0xf0); - INTn (Symbol name); - ID; -} - -static void -f2_record (void) -{ - NEXT (); - OUT (0xf2); - INT; - NEXT (); - OUT (0xce); - INT; - copy_till_end (); -} - -static void -f8_record (void) -{ - int ch; - NEXT (); - ch = THIS (); - switch (ch) - { - case 0x01: - case 0x02: - case 0x03: - /* Unique typedefs for module. */ - /* GLobal typedefs. */ - /* High level module scope beginning. */ - { - struct output_buffer_struct ob; - - NEXT (); - OUT (0xf8); - OUT (ch); - drop_int (&ob); - ID; - - block (); - - NEXT (); - fill_int (&ob); - OUT (0xf9); - } - break; - case 0x04: - /* Global function. */ - { - struct output_buffer_struct ob; - - NEXT (); - OUT (0xf8); - OUT (0x04); - drop_int (&ob); - ID; - INTn (stack size); - INTn (ret val); - EXPn (offset); - - block (); - - NEXT (); - OUT (0xf9); - EXPn (size of block); - fill_int (&ob); - } - break; - - case 0x05: - /* File name for source line numbers. */ - { - struct output_buffer_struct ob; - - NEXT (); - OUT (0xf8); - OUT (0x05); - drop_int (&ob); - ID; - INTn (year); - INTn (month); - INTn (day); - INTn (hour); - INTn (monute); - INTn (second); - block (); - NEXT (); - OUT (0xf9); - fill_int (&ob); - } - break; - - case 0x06: - /* Local function. */ - { - struct output_buffer_struct ob; - - NEXT (); - OUT (0xf8); - OUT (0x06); - drop_int (&ob); - ID; - INTn (stack size); - INTn (type return); - EXPn (offset); - block (); - NEXT (); - OUT (0xf9); - EXPn (size); - fill_int (&ob); - } - break; - - case 0x0a: - /* Assembler module scope beginning - */ - { - struct output_buffer_struct ob; - - NEXT (); - OUT (0xf8); - OUT (0x0a); - drop_int (&ob); - ID; - ID; - INT; - ID; - INT; - INT; - INT; - INT; - INT; - INT; - - block (); - - NEXT (); - OUT (0xf9); - fill_int (&ob); - } - break; - case 0x0b: - { - struct output_buffer_struct ob; - - NEXT (); - OUT (0xf8); - OUT (0x0b); - drop_int (&ob); - ID; - INT; - INTn (section index); - EXPn (offset); - INTn (stuff); - - block (); - - OUT (0xf9); - NEXT (); - EXPn (Size in Maus); - fill_int (&ob); - } - break; - } -} - -static void -e2_record (void) -{ - OUT (0xe2); - NEXT (); - OUT (0xce); - NEXT (); - INT; - EXP; -} - -static void -block (void) -{ - int ch; - - while (1) - { - ch = THIS (); - switch (ch) - { - case 0xe1: - case 0xe5: - return; - case 0xf9: - return; - case 0xf0: - f0_record (); - break; - case 0xf1: - f1_record (); - break; - case 0xf2: - f2_record (); - break; - case 0xf8: - f8_record (); - break; - case 0xe2: - e2_record (); - break; - - } - } -} - -/* Moves all the debug information from the source bfd to the output - bfd, and relocates any expressions it finds. */ - -static void -relocate_debug (bfd *output ATTRIBUTE_UNUSED, - bfd *input) -{ -#define IBS 400 -#define OBS 400 - unsigned char input_buffer[IBS]; - - input_ptr_start = input_ptr = input_buffer; - input_ptr_end = input_buffer + IBS; - input_bfd = input; - /* FIXME: Check return value. I'm not sure whether it needs to read - the entire buffer or not. */ - bfd_bread ((void *) input_ptr_start, (bfd_size_type) IBS, input); - block (); -} - -/* Gather together all the debug information from each input BFD into - one place, relocating it and emitting it as we go. */ - -static bfd_boolean -ieee_write_debug_part (bfd *abfd) -{ - ieee_data_type *ieee = IEEE_DATA (abfd); - bfd_chain_type *chain = ieee->chain_root; - unsigned char obuff[OBS]; - bfd_boolean some_debug = FALSE; - file_ptr here = bfd_tell (abfd); - - output_ptr_start = output_ptr = obuff; - output_ptr_end = obuff + OBS; - output_ptr = obuff; - output_bfd = abfd; - - if (chain == (bfd_chain_type *) NULL) - { - asection *s; - - for (s = abfd->sections; s != NULL; s = s->next) - if ((s->flags & SEC_DEBUGGING) != 0) - break; - if (s == NULL) - { - ieee->w.r.debug_information_part = 0; - return TRUE; - } - - ieee->w.r.debug_information_part = here; - if (bfd_bwrite (s->contents, s->size, abfd) != s->size) - return FALSE; - } - else - { - while (chain != (bfd_chain_type *) NULL) - { - bfd *entry = chain->this; - ieee_data_type *entry_ieee = IEEE_DATA (entry); - - if (entry_ieee->w.r.debug_information_part) - { - if (bfd_seek (entry, entry_ieee->w.r.debug_information_part, - SEEK_SET) != 0) - return FALSE; - relocate_debug (abfd, entry); - } - - chain = chain->next; - } - - if (some_debug) - ieee->w.r.debug_information_part = here; - else - ieee->w.r.debug_information_part = 0; - - flush (); - } - - return TRUE; -} - -/* Write the data in an ieee way. */ - -static bfd_boolean -ieee_write_data_part (bfd *abfd) -{ - asection *s; - - ieee_data_type *ieee = IEEE_DATA (abfd); - ieee->w.r.data_part = bfd_tell (abfd); - - for (s = abfd->sections; s != (asection *) NULL; s = s->next) - { - /* Skip sections that have no loadable contents (.bss, - debugging, etc.) */ - if ((s->flags & SEC_LOAD) == 0) - continue; - - /* Sort the reloc records so we can insert them in the correct - places. */ - if (s->reloc_count != 0) - { - if (! do_with_relocs (abfd, s)) - return FALSE; - } - else - { - if (! do_without_relocs (abfd, s)) - return FALSE; - } - } - - return TRUE; -} - -static bfd_boolean -init_for_output (bfd *abfd) -{ - asection *s; - - for (s = abfd->sections; s != (asection *) NULL; s = s->next) - { - if ((s->flags & SEC_DEBUGGING) != 0) - continue; - if (s->size != 0) - { - bfd_size_type size = s->size; - ieee_per_section (s)->data = bfd_alloc (abfd, size); - if (!ieee_per_section (s)->data) - return FALSE; - } - } - return TRUE; -} - -/* Exec and core file sections. */ - -/* Set section contents is complicated with IEEE since the format is - not a byte image, but a record stream. */ - -static bfd_boolean -ieee_set_section_contents (bfd *abfd, - sec_ptr section, - const void * location, - file_ptr offset, - bfd_size_type count) -{ - if ((section->flags & SEC_DEBUGGING) != 0) - { - if (section->contents == NULL) - { - bfd_size_type size = section->size; - section->contents = bfd_alloc (abfd, size); - if (section->contents == NULL) - return FALSE; - } - /* bfd_set_section_contents has already checked that everything - is within range. */ - memcpy (section->contents + offset, location, (size_t) count); - return TRUE; - } - - if (ieee_per_section (section)->data == (bfd_byte *) NULL) - { - if (!init_for_output (abfd)) - return FALSE; - } - memcpy ((void *) (ieee_per_section (section)->data + offset), - (void *) location, - (unsigned int) count); - return TRUE; -} - -/* Write the external symbols of a file. IEEE considers two sorts of - external symbols, public, and referenced. It uses to internal - forms to index them as well. When we write them out we turn their - symbol values into indexes from the right base. */ - -static bfd_boolean -ieee_write_external_part (bfd *abfd) -{ - asymbol **q; - ieee_data_type *ieee = IEEE_DATA (abfd); - unsigned int reference_index = IEEE_REFERENCE_BASE; - unsigned int public_index = IEEE_PUBLIC_BASE + 2; - file_ptr here = bfd_tell (abfd); - bfd_boolean hadone = FALSE; - - if (abfd->outsymbols != (asymbol **) NULL) - { - - for (q = abfd->outsymbols; *q != (asymbol *) NULL; q++) - { - asymbol *p = *q; - - if (bfd_is_und_section (p->section)) - { - /* This must be a symbol reference. */ - if (! ieee_write_byte (abfd, ieee_external_reference_enum) - || ! ieee_write_int (abfd, (bfd_vma) reference_index) - || ! ieee_write_id (abfd, p->name)) - return FALSE; - p->value = reference_index; - reference_index++; - hadone = TRUE; - } - else if (bfd_is_com_section (p->section)) - { - /* This is a weak reference. */ - if (! ieee_write_byte (abfd, ieee_external_reference_enum) - || ! ieee_write_int (abfd, (bfd_vma) reference_index) - || ! ieee_write_id (abfd, p->name) - || ! ieee_write_byte (abfd, - ieee_weak_external_reference_enum) - || ! ieee_write_int (abfd, (bfd_vma) reference_index) - || ! ieee_write_int (abfd, p->value)) - return FALSE; - p->value = reference_index; - reference_index++; - hadone = TRUE; - } - else if (p->flags & BSF_GLOBAL) - { - /* This must be a symbol definition. */ - if (! ieee_write_byte (abfd, ieee_external_symbol_enum) - || ! ieee_write_int (abfd, (bfd_vma) public_index) - || ! ieee_write_id (abfd, p->name) - || ! ieee_write_2bytes (abfd, ieee_attribute_record_enum) - || ! ieee_write_int (abfd, (bfd_vma) public_index) - || ! ieee_write_byte (abfd, 15) /* Instruction address. */ - || ! ieee_write_byte (abfd, 19) /* Static symbol. */ - || ! ieee_write_byte (abfd, 1)) /* One of them. */ - return FALSE; - - /* Write out the value. */ - if (! ieee_write_2bytes (abfd, ieee_value_record_enum) - || ! ieee_write_int (abfd, (bfd_vma) public_index)) - return FALSE; - if (! bfd_is_abs_section (p->section)) - { - if (abfd->flags & EXEC_P) - { - /* If fully linked, then output all symbols - relocated. */ - if (! (ieee_write_int - (abfd, - (p->value - + p->section->output_offset - + p->section->output_section->vma)))) - return FALSE; - } - else - { - if (! (ieee_write_expression - (abfd, - p->value + p->section->output_offset, - p->section->output_section->symbol, - FALSE, 0))) - return FALSE; - } - } - else - { - if (! ieee_write_expression (abfd, - p->value, - bfd_abs_section_ptr->symbol, - FALSE, 0)) - return FALSE; - } - p->value = public_index; - public_index++; - hadone = TRUE; - } - else - { - /* This can happen - when there are gaps in the symbols read - from an input ieee file. */ - } - } - } - if (hadone) - ieee->w.r.external_part = here; - - return TRUE; -} - - -static const unsigned char exten[] = -{ - 0xf0, 0x20, 0x00, - 0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3. */ - 0xf1, 0xce, 0x20, 0x00, 39, 2, /* Keep symbol in original case. */ - 0xf1, 0xce, 0x20, 0x00, 38 /* Set object type relocatable to x. */ -}; - -static const unsigned char envi[] = -{ - 0xf0, 0x21, 0x00, - -/* 0xf1, 0xce, 0x21, 00, 50, 0x82, 0x07, 0xc7, 0x09, 0x11, 0x11, - 0x19, 0x2c, -*/ - 0xf1, 0xce, 0x21, 00, 52, 0x00, /* exec ok. */ - - 0xf1, 0xce, 0x21, 0, 53, 0x03,/* host unix. */ -/* 0xf1, 0xce, 0x21, 0, 54, 2,1,1 tool & version # */ -}; - -static bfd_boolean -ieee_write_me_part (bfd *abfd) -{ - ieee_data_type *ieee = IEEE_DATA (abfd); - ieee->w.r.trailer_part = bfd_tell (abfd); - if (abfd->start_address) - { - if (! ieee_write_2bytes (abfd, ieee_value_starting_address_enum) - || ! ieee_write_byte (abfd, ieee_function_either_open_b_enum) - || ! ieee_write_int (abfd, abfd->start_address) - || ! ieee_write_byte (abfd, ieee_function_either_close_b_enum)) - return FALSE; - } - ieee->w.r.me_record = bfd_tell (abfd); - if (! ieee_write_byte (abfd, ieee_module_end_enum)) - return FALSE; - return TRUE; -} - -/* Write out the IEEE processor ID. */ - -static bfd_boolean -ieee_write_processor (bfd *abfd) -{ - const bfd_arch_info_type *arch; - - arch = bfd_get_arch_info (abfd); - switch (arch->arch) - { - default: - if (! ieee_write_id (abfd, bfd_printable_name (abfd))) - return FALSE; - break; - - case bfd_arch_h8300: - if (! ieee_write_id (abfd, "H8/300")) - return FALSE; - break; - - case bfd_arch_h8500: - if (! ieee_write_id (abfd, "H8/500")) - return FALSE; - break; - - case bfd_arch_m68k: - { - const char *id; - - switch (arch->mach) - { - default: id = "68020"; break; - case bfd_mach_m68000: id = "68000"; break; - case bfd_mach_m68008: id = "68008"; break; - case bfd_mach_m68010: id = "68010"; break; - case bfd_mach_m68020: id = "68020"; break; - case bfd_mach_m68030: id = "68030"; break; - case bfd_mach_m68040: id = "68040"; break; - case bfd_mach_m68060: id = "68060"; break; - case bfd_mach_cpu32: id = "cpu32"; break; - case bfd_mach_mcf_isa_a_nodiv: id = "isa-a:nodiv"; break; - case bfd_mach_mcf_isa_a: id = "isa-a"; break; - case bfd_mach_mcf_isa_a_mac: id = "isa-a:mac"; break; - case bfd_mach_mcf_isa_a_emac: id = "isa-a:emac"; break; - case bfd_mach_mcf_isa_aplus: id = "isa-aplus"; break; - case bfd_mach_mcf_isa_aplus_mac: id = "isa-aplus:mac"; break; - case bfd_mach_mcf_isa_aplus_emac: id = "isa-aplus:mac"; break; - case bfd_mach_mcf_isa_b_nousp: id = "isa-b:nousp"; break; - case bfd_mach_mcf_isa_b_nousp_mac: id = "isa-b:nousp:mac"; break; - case bfd_mach_mcf_isa_b_nousp_emac: id = "isa-b:nousp:emac"; break; - case bfd_mach_mcf_isa_b: id = "isa-b"; break; - case bfd_mach_mcf_isa_b_mac: id = "isa-b:mac"; break; - case bfd_mach_mcf_isa_b_emac: id = "isa-b:emac"; break; - case bfd_mach_mcf_isa_b_float: id = "isa-b:float"; break; - case bfd_mach_mcf_isa_b_float_mac: id = "isa-b:float:mac"; break; - case bfd_mach_mcf_isa_b_float_emac: id = "isa-b:float:emac"; break; - case bfd_mach_mcf_isa_c: id = "isa-c"; break; - case bfd_mach_mcf_isa_c_mac: id = "isa-c:mac"; break; - case bfd_mach_mcf_isa_c_emac: id = "isa-c:emac"; break; - case bfd_mach_mcf_isa_c_nodiv: id = "isa-c:nodiv"; break; - case bfd_mach_mcf_isa_c_nodiv_mac: id = "isa-c:nodiv:mac"; break; - case bfd_mach_mcf_isa_c_nodiv_emac: id = "isa-c:nodiv:emac"; break; - } - - if (! ieee_write_id (abfd, id)) - return FALSE; - } - break; - } - - return TRUE; -} - -static bfd_boolean -ieee_write_object_contents (bfd *abfd) -{ - ieee_data_type *ieee = IEEE_DATA (abfd); - unsigned int i; - file_ptr old; - - /* Fast forward over the header area. */ - if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) - return FALSE; - - if (! ieee_write_byte (abfd, ieee_module_beginning_enum) - || ! ieee_write_processor (abfd) - || ! ieee_write_id (abfd, abfd->filename)) - return FALSE; - - /* Fast forward over the variable bits. */ - if (! ieee_write_byte (abfd, ieee_address_descriptor_enum)) - return FALSE; - - /* Bits per MAU. */ - if (! ieee_write_byte (abfd, (bfd_byte) (bfd_arch_bits_per_byte (abfd)))) - return FALSE; - /* MAU's per address. */ - if (! ieee_write_byte (abfd, - (bfd_byte) (bfd_arch_bits_per_address (abfd) - / bfd_arch_bits_per_byte (abfd)))) - return FALSE; - - old = bfd_tell (abfd); - if (bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR) != 0) - return FALSE; - - ieee->w.r.extension_record = bfd_tell (abfd); - if (bfd_bwrite ((char *) exten, (bfd_size_type) sizeof (exten), abfd) - != sizeof (exten)) - return FALSE; - if (abfd->flags & EXEC_P) - { - if (! ieee_write_byte (abfd, 0x1)) /* Absolute. */ - return FALSE; - } - else - { - if (! ieee_write_byte (abfd, 0x2)) /* Relocateable. */ - return FALSE; - } - - ieee->w.r.environmental_record = bfd_tell (abfd); - if (bfd_bwrite ((char *) envi, (bfd_size_type) sizeof (envi), abfd) - != sizeof (envi)) - return FALSE; - - /* The HP emulator database requires a timestamp in the file. */ - { - time_t now; - const struct tm *t; - - time (&now); - t = (struct tm *) localtime (&now); - if (! ieee_write_2bytes (abfd, (int) ieee_atn_record_enum) - || ! ieee_write_byte (abfd, 0x21) - || ! ieee_write_byte (abfd, 0) - || ! ieee_write_byte (abfd, 50) - || ! ieee_write_int (abfd, (bfd_vma) (t->tm_year + 1900)) - || ! ieee_write_int (abfd, (bfd_vma) (t->tm_mon + 1)) - || ! ieee_write_int (abfd, (bfd_vma) t->tm_mday) - || ! ieee_write_int (abfd, (bfd_vma) t->tm_hour) - || ! ieee_write_int (abfd, (bfd_vma) t->tm_min) - || ! ieee_write_int (abfd, (bfd_vma) t->tm_sec)) - return FALSE; - } - - output_bfd = abfd; - - flush (); - - if (! ieee_write_section_part (abfd)) - return FALSE; - /* First write the symbols. This changes their values into table - indeces so we cant use it after this point. */ - if (! ieee_write_external_part (abfd)) - return FALSE; - - /* Write any debugs we have been told about. */ - if (! ieee_write_debug_part (abfd)) - return FALSE; - - /* Can only write the data once the symbols have been written, since - the data contains relocation information which points to the - symbols. */ - if (! ieee_write_data_part (abfd)) - return FALSE; - - /* At the end we put the end! */ - if (! ieee_write_me_part (abfd)) - return FALSE; - - /* Generate the header. */ - if (bfd_seek (abfd, old, SEEK_SET) != 0) - return FALSE; - - for (i = 0; i < N_W_VARIABLES; i++) - { - if (! ieee_write_2bytes (abfd, ieee_assign_value_to_variable_enum) - || ! ieee_write_byte (abfd, (bfd_byte) i) - || ! ieee_write_int5_out (abfd, (bfd_vma) ieee->w.offset[i])) - return FALSE; - } - - return TRUE; -} - -/* Native-level interface to symbols. */ - -/* We read the symbols into a buffer, which is discarded when this - function exits. We read the strings into a buffer large enough to - hold them all plus all the cached symbol entries. */ - -static asymbol * -ieee_make_empty_symbol (bfd *abfd) -{ - bfd_size_type amt = sizeof (ieee_symbol_type); - ieee_symbol_type *new_symbol = (ieee_symbol_type *) bfd_zalloc (abfd, amt); - - if (!new_symbol) - return NULL; - new_symbol->symbol.the_bfd = abfd; - return &new_symbol->symbol; -} - -static bfd * -ieee_openr_next_archived_file (bfd *arch, bfd *prev) -{ - ieee_ar_data_type *ar = IEEE_AR_DATA (arch); - - /* Take the next one from the arch state, or reset. */ - if (prev == (bfd *) NULL) - /* Reset the index - the first two entries are bogus. */ - ar->element_index = 2; - - while (TRUE) - { - ieee_ar_obstack_type *p = ar->elements + ar->element_index; - - ar->element_index++; - if (ar->element_index <= ar->element_count) - { - if (p->file_offset != (file_ptr) 0) - { - if (p->abfd == (bfd *) NULL) - { - p->abfd = _bfd_create_empty_archive_element_shell (arch); - p->abfd->origin = p->file_offset; - } - return p->abfd; - } - } - else - { - bfd_set_error (bfd_error_no_more_archived_files); - return NULL; - } - } -} - -#define ieee_find_nearest_line _bfd_nosymbols_find_nearest_line -#define ieee_find_line _bfd_nosymbols_find_line -#define ieee_find_inliner_info _bfd_nosymbols_find_inliner_info - -static int -ieee_generic_stat_arch_elt (bfd *abfd, struct stat *buf) -{ - ieee_ar_data_type *ar = (ieee_ar_data_type *) NULL; - ieee_data_type *ieee; - - if (abfd->my_archive != NULL) - ar = abfd->my_archive->tdata.ieee_ar_data; - if (ar == (ieee_ar_data_type *) NULL) - { - bfd_set_error (bfd_error_invalid_operation); - return -1; - } - - if (IEEE_DATA (abfd) == NULL) - { - if (ieee_object_p (abfd) == NULL) - { - bfd_set_error (bfd_error_wrong_format); - return -1; - } - } - - ieee = IEEE_DATA (abfd); - - buf->st_size = ieee->w.r.me_record + 1; - buf->st_mode = 0644; - return 0; -} - -static int -ieee_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, - struct bfd_link_info *info ATTRIBUTE_UNUSED) -{ - return 0; -} - -#define ieee_close_and_cleanup _bfd_generic_close_and_cleanup -#define ieee_bfd_free_cached_info _bfd_generic_bfd_free_cached_info - -#define ieee_slurp_armap _bfd_bool_bfd_true -#define ieee_slurp_extended_name_table _bfd_bool_bfd_true -#define ieee_construct_extended_name_table \ - _bfd_noarchive_construct_extended_name_table -#define ieee_truncate_arname bfd_dont_truncate_arname -#define ieee_write_armap _bfd_noarchive_write_armap -#define ieee_read_ar_hdr _bfd_ptr_bfd_null_error -#define ieee_write_ar_hdr _bfd_noarchive_write_ar_hdr -#define ieee_update_armap_timestamp _bfd_bool_bfd_true -#define ieee_get_elt_at_index _bfd_generic_get_elt_at_index - -#define ieee_get_symbol_version_string \ - _bfd_nosymbols_get_symbol_version_string -#define ieee_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false -#define ieee_bfd_is_local_label_name bfd_generic_is_local_label_name -#define ieee_get_lineno _bfd_nosymbols_get_lineno -#define ieee_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol -#define ieee_read_minisymbols _bfd_generic_read_minisymbols -#define ieee_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol - -#define ieee_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup -#define ieee_bfd_reloc_name_lookup _bfd_norelocs_bfd_reloc_name_lookup - -#define ieee_set_arch_mach _bfd_generic_set_arch_mach - -#define ieee_get_section_contents_in_window \ - _bfd_generic_get_section_contents_in_window -#define ieee_bfd_get_relocated_section_contents \ - bfd_generic_get_relocated_section_contents -#define ieee_bfd_relax_section bfd_generic_relax_section -#define ieee_bfd_gc_sections bfd_generic_gc_sections -#define ieee_bfd_lookup_section_flags bfd_generic_lookup_section_flags -#define ieee_bfd_merge_sections bfd_generic_merge_sections -#define ieee_bfd_is_group_section bfd_generic_is_group_section -#define ieee_bfd_discard_group bfd_generic_discard_group -#define ieee_section_already_linked \ - _bfd_generic_section_already_linked -#define ieee_bfd_define_common_symbol bfd_generic_define_common_symbol -#define ieee_bfd_define_start_stop bfd_generic_define_start_stop -#define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create -#define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols -#define ieee_bfd_link_just_syms _bfd_generic_link_just_syms -#define ieee_bfd_copy_link_hash_symbol_type \ - _bfd_generic_copy_link_hash_symbol_type -#define ieee_bfd_final_link _bfd_generic_final_link -#define ieee_bfd_link_split_section _bfd_generic_link_split_section -#define ieee_bfd_link_check_relocs _bfd_generic_link_check_relocs -#define ieee_set_reloc _bfd_generic_set_reloc - -const bfd_target ieee_vec = -{ - "ieee", /* Name. */ - bfd_target_ieee_flavour, - BFD_ENDIAN_UNKNOWN, /* Target byte order. */ - BFD_ENDIAN_UNKNOWN, /* Target headers byte order. */ - (HAS_RELOC | EXEC_P | /* Object flags. */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), - (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS - | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* Section flags. */ - '_', /* Leading underscore. */ - ' ', /* AR_pad_char. */ - 16, /* AR_max_namelen. */ - 0, /* match priority. */ - bfd_getb64, bfd_getb_signed_64, bfd_putb64, - bfd_getb32, bfd_getb_signed_32, bfd_putb32, - bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */ - bfd_getb64, bfd_getb_signed_64, bfd_putb64, - bfd_getb32, bfd_getb_signed_32, bfd_putb32, - bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Headers. */ - - {_bfd_dummy_target, - ieee_object_p, /* bfd_check_format. */ - ieee_archive_p, - _bfd_dummy_target, - }, - { - _bfd_bool_bfd_false_error, - ieee_mkobject, - _bfd_generic_mkarchive, - _bfd_bool_bfd_false_error - }, - { - _bfd_bool_bfd_false_error, - ieee_write_object_contents, - _bfd_write_archive_contents, - _bfd_bool_bfd_false_error, - }, - - /* ieee_close_and_cleanup, ieee_bfd_free_cached_info, ieee_new_section_hook, - ieee_get_section_contents, ieee_get_section_contents_in_window. */ - BFD_JUMP_TABLE_GENERIC (ieee), - - BFD_JUMP_TABLE_COPY (_bfd_generic), - BFD_JUMP_TABLE_CORE (_bfd_nocore), - - /* ieee_slurp_armap, ieee_slurp_extended_name_table, - ieee_construct_extended_name_table, ieee_truncate_arname, - ieee_write_armap, ieee_read_ar_hdr, ieee_openr_next_archived_file, - ieee_get_elt_at_index, ieee_generic_stat_arch_elt, - ieee_update_armap_timestamp. */ - BFD_JUMP_TABLE_ARCHIVE (ieee), - - /* ieee_get_symtab_upper_bound, ieee_canonicalize_symtab, - ieee_make_empty_symbol, ieee_print_symbol, ieee_get_symbol_info, - ieee_bfd_is_local_label_name, ieee_get_lineno, - ieee_find_nearest_line, ieee_bfd_make_debug_symbol, - ieee_read_minisymbols, ieee_minisymbol_to_symbol. */ - BFD_JUMP_TABLE_SYMBOLS (ieee), - - /* ieee_get_reloc_upper_bound, ieee_canonicalize_reloc, - ieee_bfd_reloc_type_lookup. */ - BFD_JUMP_TABLE_RELOCS (ieee), - - /* ieee_set_arch_mach, ieee_set_section_contents. */ - BFD_JUMP_TABLE_WRITE (ieee), - - /* ieee_sizeof_headers, ieee_bfd_get_relocated_section_contents, - ieee_bfd_relax_section, ieee_bfd_link_hash_table_create, - ieee_bfd_link_add_symbols, ieee_bfd_final_link, - ieee_bfd_link_split_section, ieee_bfd_gc_sections, - ieee_bfd_merge_sections. */ - BFD_JUMP_TABLE_LINK (ieee), - - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - - NULL, - - NULL -}; diff --git a/bfd/libieee.h b/bfd/libieee.h deleted file mode 100644 index 2bbaebf..0000000 --- a/bfd/libieee.h +++ /dev/null @@ -1,137 +0,0 @@ -/* IEEE-695 object file formats: definitions internal to BFD. - Copyright (C) 1990-2018 Free Software Foundation, Inc. - Written by Cygnus Support. Mostly Steve Chamberlain's fault. - - This file is part of BFD, the Binary File Descriptor library. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, - MA 02110-1301, USA. */ - -typedef struct { - unsigned int index:24; - char letter; -} ieee_symbol_index_type; - -typedef struct ct { - bfd *this; - struct ct *next; -} bfd_chain_type; - -typedef struct ieee_symbol -{ - asymbol symbol; - struct ieee_symbol *next; - - unsigned int index; -} ieee_symbol_type; - - -typedef struct ieee_reloc { - arelent relent; - struct ieee_reloc *next; - ieee_symbol_index_type symbol; - -} ieee_reloc_type; - -#define ieee_symbol(x) ((ieee_symbol_type *)(x)) - -typedef struct ieee_per_section -{ - asection *section; - bfd_byte *data; - bfd_vma offset; - bfd_vma pc; - /* For output */ - file_ptr current_pos; - unsigned int current_byte; - bfd_boolean initialized; - ieee_reloc_type **reloc_tail_ptr; -} ieee_per_section_type; - -#define ieee_per_section(x) ((ieee_per_section_type *)((x)->used_by_bfd)) - -typedef struct { - unsigned char *input_p; - unsigned char *end_p; - unsigned char *first_byte; - unsigned char *last_byte; - bfd_size_type total_amt; - bfd *abfd; -} common_header_type ; - -typedef struct ieee_data_struct -{ - common_header_type h; - bfd_boolean read_symbols; - bfd_boolean read_data; - file_ptr output_cursor; - /* Map of section indexes to section ptrs */ - asection **section_table; - unsigned int section_table_size; - ieee_address_descriptor_type ad; - ieee_module_begin_type mb; - ieee_w_variable_type w; - - unsigned int section_count; - - unsigned int map_idx; - /* List of GLOBAL EXPORT symbols */ - ieee_symbol_type *external_symbols; - /* List of UNDEFINED symbols */ - ieee_symbol_type *external_reference; - - /* When the symbols have been canonicalized, they are in a - * special order, we remember various bases here.. */ - unsigned int external_symbol_max_index; - unsigned int external_symbol_min_index; - unsigned int external_symbol_count; - int external_symbol_base_offset; - - unsigned int external_reference_max_index; - unsigned int external_reference_min_index; - unsigned int external_reference_count; - int external_reference_base_offset; - - - bfd_boolean symbol_table_full; - - -bfd_boolean done_debug; - - -bfd_chain_type *chain_head; -bfd_chain_type *chain_root; - -} ieee_data_type; - -typedef struct { - file_ptr file_offset; - bfd *abfd; -} ieee_ar_obstack_type; - -typedef struct ieee_ar_data_struct -{ - common_header_type h; - ieee_ar_obstack_type *elements; - - unsigned int element_index ; - unsigned int element_count; - -} ieee_ar_data_type; - -#define IEEE_DATA(abfd) ((abfd)->tdata.ieee_data) -#define IEEE_AR_DATA(abfd) ((abfd)->tdata.ieee_ar_data) - -#define ptr(abfd) (ieee_data(abfd)->input_p) diff --git a/bfd/po/SRC-POTFILES.in b/bfd/po/SRC-POTFILES.in index 76aad8a..310d977 100644 --- a/bfd/po/SRC-POTFILES.in +++ b/bfd/po/SRC-POTFILES.in @@ -277,7 +277,6 @@ i386mach3.c i386msdos.c i386netbsd.c i386os9k.c -ieee.c ihex.c init.c irix-core.c @@ -287,7 +286,6 @@ libbfd.h libcoff.h libecoff.h libhppa.h -libieee.h liboasys.h libpei.h libxcoff.h diff --git a/bfd/section.c b/bfd/section.c index 6aa18d5..752f291 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -65,10 +65,7 @@ SUBSECTION data in place until a <> call is made. Other back ends may read in all the data at once. For example, an S-record file has to be read once to determine the - size of the data. An IEEE-695 file doesn't contain raw data in - sections, but data and relocation expressions intermixed, so - the data area has to be parsed to get out the data and - relocations. + size of the data. INODE Section Output, typedef asection, Section Input, Sections diff --git a/bfd/targets.c b/bfd/targets.c index 4951d02..0c6d9c1 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -151,7 +151,6 @@ DESCRIPTION . bfd_target_ecoff_flavour, . bfd_target_xcoff_flavour, . bfd_target_elf_flavour, -. bfd_target_ieee_flavour, . bfd_target_oasys_flavour, . bfd_target_tekhex_flavour, . bfd_target_srec_flavour, @@ -689,7 +688,6 @@ extern const bfd_target ia64_elf64_le_vec; extern const bfd_target ia64_elf64_hpux_be_vec; extern const bfd_target ia64_elf64_vms_vec; extern const bfd_target ia64_pei_vec; -extern const bfd_target ieee_vec; extern const bfd_target ip2k_elf32_vec; extern const bfd_target iq2000_elf32_vec; extern const bfd_target k1om_elf64_vec; @@ -1121,8 +1119,6 @@ static const bfd_target * const _bfd_target_vector[] = &ia64_pei_vec, #endif - &ieee_vec, - &ip2k_elf32_vec, &iq2000_elf32_vec, @@ -1860,7 +1856,6 @@ bfd_flavour_name (enum bfd_flavour flavour) case bfd_target_ecoff_flavour: return "ECOFF"; case bfd_target_xcoff_flavour: return "XCOFF"; case bfd_target_elf_flavour: return "ELF"; - case bfd_target_ieee_flavour: return "IEEE"; case bfd_target_oasys_flavour: return "Oasys"; case bfd_target_tekhex_flavour: return "Tekhex"; case bfd_target_srec_flavour: return "Srec"; diff --git a/binutils/ChangeLog b/binutils/ChangeLog index a1c1a54..d58bc4d 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,5 +1,18 @@ 2018-04-16 Alan Modra + * Makefile.am: Remove IEEE 695 support. + * budbg.h: Likewise. + * doc/binutils.texi: Likewise. + * makefile.vms: Likewise. + * objcopy.c: Likewise. + * objdump.c: Likewise. + * rddbg.c: Likewise. + * ieee.c: Delete. + * Makefile.in: Regenerate. + * po/POTFILES.in: Regenerate. + +2018-04-16 Alan Modra + * testsuite/binutils-all/copy-2.d: Remove newsos3 support. * testsuite/binutils-all/nm.exp: Likewise. diff --git a/binutils/Makefile.am b/binutils/Makefile.am index ffcaf82..d827d9e 100644 --- a/binutils/Makefile.am +++ b/binutils/Makefile.am @@ -130,7 +130,7 @@ CFILES = \ coffdump.c coffgrok.c cxxfilt.c \ dwarf.c debug.c dlltool.c dllwrap.c \ elfcomm.c emul_aix.c emul_vanilla.c filemode.c \ - ieee.c is-ranlib.c is-strip.c maybe-ranlib.c maybe-strip.c \ + is-ranlib.c is-strip.c maybe-ranlib.c maybe-strip.c \ nm.c not-ranlib.c not-strip.c \ objcopy.c objdump.c prdbg.c \ od-xcoff.c od-macho.c \ @@ -145,7 +145,7 @@ GENERATED_CFILES = \ arparse.c arlex.c sysroff.c sysinfo.c syslex.c \ defparse.c deflex.c rcparse.c mcparse.c -DEBUG_SRCS = rddbg.c debug.c stabs.c ieee.c rdcoff.c +DEBUG_SRCS = rddbg.c debug.c stabs.c rdcoff.c WRITE_DEBUG_SRCS = $(DEBUG_SRCS) wrstabs.c # Extra object files for objdump diff --git a/binutils/Makefile.in b/binutils/Makefile.in index ccecdf7..7099bd4 100644 --- a/binutils/Makefile.in +++ b/binutils/Makefile.in @@ -174,7 +174,7 @@ am_nm_new_OBJECTS = nm.$(OBJEXT) $(am__objects_1) nm_new_OBJECTS = $(am_nm_new_OBJECTS) nm_new_LDADD = $(LDADD) am__objects_3 = rddbg.$(OBJEXT) debug.$(OBJEXT) stabs.$(OBJEXT) \ - ieee.$(OBJEXT) rdcoff.$(OBJEXT) + rdcoff.$(OBJEXT) am__objects_4 = $(am__objects_3) wrstabs.$(OBJEXT) am_objcopy_OBJECTS = objcopy.$(OBJEXT) not-strip.$(OBJEXT) \ rename.$(OBJEXT) $(am__objects_4) $(am__objects_1) @@ -530,7 +530,7 @@ CFILES = \ coffdump.c coffgrok.c cxxfilt.c \ dwarf.c debug.c dlltool.c dllwrap.c \ elfcomm.c emul_aix.c emul_vanilla.c filemode.c \ - ieee.c is-ranlib.c is-strip.c maybe-ranlib.c maybe-strip.c \ + is-ranlib.c is-strip.c maybe-ranlib.c maybe-strip.c \ nm.c not-ranlib.c not-strip.c \ objcopy.c objdump.c prdbg.c \ od-xcoff.c od-macho.c \ @@ -545,7 +545,7 @@ GENERATED_CFILES = \ arparse.c arlex.c sysroff.c sysinfo.c syslex.c \ defparse.c deflex.c rcparse.c mcparse.c -DEBUG_SRCS = rddbg.c debug.c stabs.c ieee.c rdcoff.c +DEBUG_SRCS = rddbg.c debug.c stabs.c rdcoff.c WRITE_DEBUG_SRCS = $(DEBUG_SRCS) wrstabs.c # Code shared by all the binutils. @@ -902,7 +902,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emul_aix.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emul_vanilla.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filemode.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ieee.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is-ranlib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is-strip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/maybe-ranlib.Po@am__quote@ diff --git a/binutils/budbg.h b/binutils/budbg.h index e16698f..8e67297 100644 --- a/binutils/budbg.h +++ b/binutils/budbg.h @@ -44,12 +44,6 @@ extern bfd_boolean parse_stab extern bfd_boolean write_stabs_in_sections_debugging_info (bfd *, void *, bfd_byte **, bfd_size_type *, bfd_byte **, bfd_size_type *); -/* Routines used to read and write IEEE debugging information. */ - -extern bfd_boolean parse_ieee (void *, bfd *, const bfd_byte *, bfd_size_type); - -extern bfd_boolean write_ieee_debugging_info (bfd *, void *); - /* Routine used to read COFF debugging information. */ extern bfd_boolean parse_coff (bfd *, asymbol **, long, void *); diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index c965200..3a32cc4 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -2162,9 +2162,9 @@ for more information on demangling. @item -g @itemx --debugging -Display debugging information. This attempts to parse STABS and IEEE +Display debugging information. This attempts to parse STABS debugging format information stored in the file and print it out using -a C like syntax. If neither of these formats are found this option +a C like syntax. If no STABS debuging was found this option falls back on the @option{-W} option to print any DWARF information in the file. diff --git a/binutils/ieee.c b/binutils/ieee.c deleted file mode 100644 index 902b882..0000000 --- a/binutils/ieee.c +++ /dev/null @@ -1,7398 +0,0 @@ -/* ieee.c -- Read and write IEEE-695 debugging information. - Copyright (C) 1996-2018 Free Software Foundation, Inc. - Written by Ian Lance Taylor . - - This file is part of GNU Binutils. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA - 02110-1301, USA. */ - -/* This file reads and writes IEEE-695 debugging information. */ - -#include "sysdep.h" -#include -#include "bfd.h" -#include "ieee.h" -#include "libiberty.h" -#include "debug.h" -#include "budbg.h" -#include "filenames.h" - -/* This structure holds an entry on the block stack. */ - -struct ieee_block -{ - /* The kind of block. */ - int kind; - /* The source file name, for a BB5 block. */ - const char *filename; - /* The index of the function type, for a BB4 or BB6 block. */ - unsigned int fnindx; - /* TRUE if this function is being skipped. */ - bfd_boolean skip; -}; - -/* This structure is the block stack. */ - -#define BLOCKSTACK_SIZE (16) - -struct ieee_blockstack -{ - /* The stack pointer. */ - struct ieee_block *bsp; - /* The stack. */ - struct ieee_block stack[BLOCKSTACK_SIZE]; -}; - -/* This structure holds information for a variable. */ - -enum ieee_var_kind - { - IEEE_UNKNOWN, - IEEE_EXTERNAL, - IEEE_GLOBAL, - IEEE_STATIC, - IEEE_LOCAL, - IEEE_FUNCTION - }; - -struct ieee_var -{ - /* Start of name. */ - const char *name; - /* Length of name. */ - unsigned long namlen; - /* Type. */ - debug_type type; - /* Slot if we make an indirect type. */ - debug_type *pslot; - /* Kind of variable or function. */ - enum ieee_var_kind kind; -}; - -/* This structure holds all the variables. */ - -struct ieee_vars -{ - /* Number of slots allocated. */ - unsigned int alloc; - /* Variables. */ - struct ieee_var *vars; -}; - -/* This structure holds information for a type. We need this because - we don't want to represent bitfields as real types. */ - -struct ieee_type -{ - /* Type. */ - debug_type type; - /* Slot if this is type is referenced before it is defined. */ - debug_type *pslot; - /* Slots for arguments if we make indirect types for them. */ - debug_type *arg_slots; - /* If this is a bitfield, this is the size in bits. If this is not - a bitfield, this is zero. */ - unsigned long bitsize; -}; - -/* This structure holds all the type information. */ - -struct ieee_types -{ - /* Number of slots allocated. */ - unsigned int alloc; - /* Types. */ - struct ieee_type *types; - /* Builtin types. */ -#define BUILTIN_TYPE_COUNT (60) - debug_type builtins[BUILTIN_TYPE_COUNT]; -}; - -/* This structure holds a linked last of structs with their tag names, - so that we can convert them to C++ classes if necessary. */ - -struct ieee_tag -{ - /* Next tag. */ - struct ieee_tag *next; - /* This tag name. */ - const char *name; - /* The type of the tag. */ - debug_type type; - /* The tagged type is an indirect type pointing at this slot. */ - debug_type slot; - /* This is an array of slots used when a field type is converted - into a indirect type, in case it needs to be later converted into - a reference type. */ - debug_type *fslots; -}; - -/* This structure holds the information we pass around to the parsing - functions. */ - -struct ieee_info -{ - /* The debugging handle. */ - void *dhandle; - /* The BFD. */ - bfd *abfd; - /* The start of the bytes to be parsed. */ - const bfd_byte *bytes; - /* The end of the bytes to be parsed. */ - const bfd_byte *pend; - /* The block stack. */ - struct ieee_blockstack blockstack; - /* Whether we have seen a BB1 or BB2. */ - bfd_boolean saw_filename; - /* The variables. */ - struct ieee_vars vars; - /* The global variables, after a global typedef block. */ - struct ieee_vars *global_vars; - /* The types. */ - struct ieee_types types; - /* The global types, after a global typedef block. */ - struct ieee_types *global_types; - /* The list of tagged structs. */ - struct ieee_tag *tags; -}; - -/* Basic builtin types, not including the pointers. */ - -enum builtin_types -{ - builtin_unknown = 0, - builtin_void = 1, - builtin_signed_char = 2, - builtin_unsigned_char = 3, - builtin_signed_short_int = 4, - builtin_unsigned_short_int = 5, - builtin_signed_long = 6, - builtin_unsigned_long = 7, - builtin_signed_long_long = 8, - builtin_unsigned_long_long = 9, - builtin_float = 10, - builtin_double = 11, - builtin_long_double = 12, - builtin_long_long_double = 13, - builtin_quoted_string = 14, - builtin_instruction_address = 15, - builtin_int = 16, - builtin_unsigned = 17, - builtin_unsigned_int = 18, - builtin_char = 19, - builtin_long = 20, - builtin_short = 21, - builtin_unsigned_short = 22, - builtin_short_int = 23, - builtin_signed_short = 24, - builtin_bcd_float = 25 -}; - -/* These are the values found in the derivation flags of a 'b' - component record of a 'T' type extension record in a C++ pmisc - record. These are bitmasks. */ - -/* Set for a private base class, clear for a public base class. - Protected base classes are not supported. */ -#define BASEFLAGS_PRIVATE (0x1) -/* Set for a virtual base class. */ -#define BASEFLAGS_VIRTUAL (0x2) -/* Set for a friend class, clear for a base class. */ -#define BASEFLAGS_FRIEND (0x10) - -/* These are the values found in the specs flags of a 'd', 'm', or 'v' - component record of a 'T' type extension record in a C++ pmisc - record. The same flags are used for a 'M' record in a C++ pmisc - record. */ - -/* The lower two bits hold visibility information. */ -#define CXXFLAGS_VISIBILITY (0x3) -/* This value in the lower two bits indicates a public member. */ -#define CXXFLAGS_VISIBILITY_PUBLIC (0x0) -/* This value in the lower two bits indicates a private member. */ -#define CXXFLAGS_VISIBILITY_PRIVATE (0x1) -/* This value in the lower two bits indicates a protected member. */ -#define CXXFLAGS_VISIBILITY_PROTECTED (0x2) -/* Set for a static member. */ -#define CXXFLAGS_STATIC (0x4) -/* Set for a virtual override. */ -#define CXXFLAGS_OVERRIDE (0x8) -/* Set for a friend function. */ -#define CXXFLAGS_FRIEND (0x10) -/* Set for a const function. */ -#define CXXFLAGS_CONST (0x20) -/* Set for a volatile function. */ -#define CXXFLAGS_VOLATILE (0x40) -/* Set for an overloaded function. */ -#define CXXFLAGS_OVERLOADED (0x80) -/* Set for an operator function. */ -#define CXXFLAGS_OPERATOR (0x100) -/* Set for a constructor or destructor. */ -#define CXXFLAGS_CTORDTOR (0x400) -/* Set for a constructor. */ -#define CXXFLAGS_CTOR (0x200) -/* Set for an inline function. */ -#define CXXFLAGS_INLINE (0x800) - -/* Local functions. */ - -static void ieee_error (struct ieee_info *, const bfd_byte *, const char *); -static void ieee_eof (struct ieee_info *); -static char *savestring (const char *, unsigned long); -static bfd_boolean ieee_read_number - (struct ieee_info *, const bfd_byte **, bfd_vma *); -static bfd_boolean ieee_read_optional_number - (struct ieee_info *, const bfd_byte **, bfd_vma *, bfd_boolean *); -static bfd_boolean ieee_read_id - (struct ieee_info *, const bfd_byte **, const char **, unsigned long *); -static bfd_boolean ieee_read_optional_id - (struct ieee_info *, const bfd_byte **, const char **, unsigned long *, - bfd_boolean *); -static bfd_boolean ieee_read_expression - (struct ieee_info *, const bfd_byte **, bfd_vma *); -static debug_type ieee_builtin_type - (struct ieee_info *, const bfd_byte *, unsigned int); -static bfd_boolean ieee_alloc_type - (struct ieee_info *, unsigned int, bfd_boolean); -static bfd_boolean ieee_read_type_index - (struct ieee_info *, const bfd_byte **, debug_type *); -static int ieee_regno_to_genreg (bfd *, int); -static int ieee_genreg_to_regno (bfd *, int); -static bfd_boolean parse_ieee_bb (struct ieee_info *, const bfd_byte **); -static bfd_boolean parse_ieee_be (struct ieee_info *, const bfd_byte **); -static bfd_boolean parse_ieee_nn (struct ieee_info *, const bfd_byte **); -static bfd_boolean parse_ieee_ty (struct ieee_info *, const bfd_byte **); -static bfd_boolean parse_ieee_atn (struct ieee_info *, const bfd_byte **); -static bfd_boolean ieee_read_cxx_misc - (struct ieee_info *, const bfd_byte **, unsigned long); -static bfd_boolean ieee_read_cxx_class - (struct ieee_info *, const bfd_byte **, unsigned long); -static bfd_boolean ieee_read_cxx_defaults - (struct ieee_info *, const bfd_byte **, unsigned long); -static bfd_boolean ieee_read_reference - (struct ieee_info *, const bfd_byte **); -static bfd_boolean ieee_require_asn - (struct ieee_info *, const bfd_byte **, bfd_vma *); -static bfd_boolean ieee_require_atn65 - (struct ieee_info *, const bfd_byte **, const char **, unsigned long *); - -/* Report an error in the IEEE debugging information. */ - -static void -ieee_error (struct ieee_info *info, const bfd_byte *p, const char *s) -{ - if (p != NULL) - fprintf (stderr, "%s: 0x%lx: %s (0x%x)\n", bfd_get_filename (info->abfd), - (unsigned long) (p - info->bytes), s, *p); - else - fprintf (stderr, "%s: %s\n", bfd_get_filename (info->abfd), s); -} - -/* Report an unexpected EOF in the IEEE debugging information. */ - -static void -ieee_eof (struct ieee_info *info) -{ - ieee_error (info, (const bfd_byte *) NULL, - _("unexpected end of debugging information")); -} - -/* Save a string in memory. */ - -static char * -savestring (const char *start, unsigned long len) -{ - char *ret; - - ret = (char *) xmalloc (len + 1); - memcpy (ret, start, len); - ret[len] = '\0'; - return ret; -} - -/* Read a number which must be present in an IEEE file. */ - -static bfd_boolean -ieee_read_number (struct ieee_info *info, const bfd_byte **pp, bfd_vma *pv) -{ - return ieee_read_optional_number (info, pp, pv, (bfd_boolean *) NULL); -} - -/* Read a number in an IEEE file. If ppresent is not NULL, the number - need not be there. */ - -static bfd_boolean -ieee_read_optional_number (struct ieee_info *info, const bfd_byte **pp, - bfd_vma *pv, bfd_boolean *ppresent) -{ - ieee_record_enum_type b; - - if (*pp >= info->pend) - { - if (ppresent != NULL) - { - *ppresent = FALSE; - return TRUE; - } - ieee_eof (info); - return FALSE; - } - - b = (ieee_record_enum_type) **pp; - ++*pp; - - if (b <= ieee_number_end_enum) - { - *pv = (bfd_vma) b; - if (ppresent != NULL) - *ppresent = TRUE; - return TRUE; - } - - if (b >= ieee_number_repeat_start_enum && b <= ieee_number_repeat_end_enum) - { - unsigned int i; - - i = (int) b - (int) ieee_number_repeat_start_enum; - if (*pp + i - 1 >= info->pend) - { - ieee_eof (info); - return FALSE; - } - - *pv = 0; - for (; i > 0; i--) - { - *pv <<= 8; - *pv += **pp; - ++*pp; - } - - if (ppresent != NULL) - *ppresent = TRUE; - - return TRUE; - } - - if (ppresent != NULL) - { - --*pp; - *ppresent = FALSE; - return TRUE; - } - - ieee_error (info, *pp - 1, _("invalid number")); - return FALSE; -} - -/* Read a required string from an IEEE file. */ - -static bfd_boolean -ieee_read_id (struct ieee_info *info, const bfd_byte **pp, - const char **pname, unsigned long *pnamlen) -{ - return ieee_read_optional_id (info, pp, pname, pnamlen, (bfd_boolean *) NULL); -} - -/* Read a string from an IEEE file. If ppresent is not NULL, the - string is optional. */ - -static bfd_boolean -ieee_read_optional_id (struct ieee_info *info, const bfd_byte **pp, - const char **pname, unsigned long *pnamlen, - bfd_boolean *ppresent) -{ - bfd_byte b; - unsigned long len; - - if (*pp >= info->pend) - { - ieee_eof (info); - return FALSE; - } - - b = **pp; - ++*pp; - - if (b <= 0x7f) - len = b; - else if ((ieee_record_enum_type) b == ieee_extension_length_1_enum) - { - len = **pp; - ++*pp; - } - else if ((ieee_record_enum_type) b == ieee_extension_length_2_enum) - { - len = (**pp << 8) + (*pp)[1]; - *pp += 2; - } - else - { - if (ppresent != NULL) - { - --*pp; - *ppresent = FALSE; - return TRUE; - } - ieee_error (info, *pp - 1, _("invalid string length")); - return FALSE; - } - - if ((unsigned long) (info->pend - *pp) < len) - { - ieee_eof (info); - return FALSE; - } - - *pname = (const char *) *pp; - *pnamlen = len; - *pp += len; - - if (ppresent != NULL) - *ppresent = TRUE; - - return TRUE; -} - -/* Read an expression from an IEEE file. Since this code is only used - to parse debugging information, I haven't bothered to write a full - blown IEEE expression parser. I've only thrown in the things I've - seen in debugging information. This can be easily extended if - necessary. */ - -static bfd_boolean -ieee_read_expression (struct ieee_info *info, const bfd_byte **pp, - bfd_vma *pv) -{ - const bfd_byte *expr_start; -#define EXPR_STACK_SIZE (10) - bfd_vma expr_stack[EXPR_STACK_SIZE]; - bfd_vma *esp; - - expr_start = *pp; - - esp = expr_stack; - - while (1) - { - const bfd_byte *start; - bfd_vma val; - bfd_boolean present; - ieee_record_enum_type c; - - start = *pp; - - if (! ieee_read_optional_number (info, pp, &val, &present)) - return FALSE; - - if (present) - { - if (esp - expr_stack >= EXPR_STACK_SIZE) - { - ieee_error (info, start, _("expression stack overflow")); - return FALSE; - } - *esp++ = val; - continue; - } - - c = (ieee_record_enum_type) **pp; - - if (c >= ieee_module_beginning_enum) - break; - - ++*pp; - - if (c == ieee_comma) - break; - - switch (c) - { - default: - ieee_error (info, start, _("unsupported IEEE expression operator")); - break; - - case ieee_variable_R_enum: - { - bfd_vma indx; - asection *s; - - if (! ieee_read_number (info, pp, &indx)) - return FALSE; - for (s = info->abfd->sections; s != NULL; s = s->next) - if ((bfd_vma) s->target_index == indx) - break; - if (s == NULL) - { - ieee_error (info, start, _("unknown section")); - return FALSE; - } - - if (esp - expr_stack >= EXPR_STACK_SIZE) - { - ieee_error (info, start, _("expression stack overflow")); - return FALSE; - } - - *esp++ = bfd_get_section_vma (info->abfd, s); - } - break; - - case ieee_function_plus_enum: - case ieee_function_minus_enum: - { - bfd_vma v1, v2; - - if (esp - expr_stack < 2) - { - ieee_error (info, start, _("expression stack underflow")); - return FALSE; - } - - v1 = *--esp; - v2 = *--esp; - *esp++ = v1 + v2; - } - break; - } - } - - if (esp - 1 != expr_stack) - { - ieee_error (info, expr_start, _("expression stack mismatch")); - return FALSE; - } - - *pv = *--esp; - - return TRUE; -} - -/* Return an IEEE builtin type. */ - -static debug_type -ieee_builtin_type (struct ieee_info *info, const bfd_byte *p, - unsigned int indx) -{ - void *dhandle; - debug_type type; - const char *name; - - if (indx < BUILTIN_TYPE_COUNT - && info->types.builtins[indx] != DEBUG_TYPE_NULL) - return info->types.builtins[indx]; - - dhandle = info->dhandle; - - if (indx >= 32 && indx < 64) - { - type = debug_make_pointer_type (dhandle, - ieee_builtin_type (info, p, indx - 32)); - assert (indx < BUILTIN_TYPE_COUNT); - info->types.builtins[indx] = type; - return type; - } - - switch ((enum builtin_types) indx) - { - default: - ieee_error (info, p, _("unknown builtin type")); - return NULL; - - case builtin_unknown: - type = debug_make_void_type (dhandle); - name = NULL; - break; - - case builtin_void: - type = debug_make_void_type (dhandle); - name = "void"; - break; - - case builtin_signed_char: - type = debug_make_int_type (dhandle, 1, FALSE); - name = "signed char"; - break; - - case builtin_unsigned_char: - type = debug_make_int_type (dhandle, 1, TRUE); - name = "unsigned char"; - break; - - case builtin_signed_short_int: - type = debug_make_int_type (dhandle, 2, FALSE); - name = "signed short int"; - break; - - case builtin_unsigned_short_int: - type = debug_make_int_type (dhandle, 2, TRUE); - name = "unsigned short int"; - break; - - case builtin_signed_long: - type = debug_make_int_type (dhandle, 4, FALSE); - name = "signed long"; - break; - - case builtin_unsigned_long: - type = debug_make_int_type (dhandle, 4, TRUE); - name = "unsigned long"; - break; - - case builtin_signed_long_long: - type = debug_make_int_type (dhandle, 8, FALSE); - name = "signed long long"; - break; - - case builtin_unsigned_long_long: - type = debug_make_int_type (dhandle, 8, TRUE); - name = "unsigned long long"; - break; - - case builtin_float: - type = debug_make_float_type (dhandle, 4); - name = "float"; - break; - - case builtin_double: - type = debug_make_float_type (dhandle, 8); - name = "double"; - break; - - case builtin_long_double: - /* FIXME: The size for this type should depend upon the - processor. */ - type = debug_make_float_type (dhandle, 12); - name = "long double"; - break; - - case builtin_long_long_double: - type = debug_make_float_type (dhandle, 16); - name = "long long double"; - break; - - case builtin_quoted_string: - type = debug_make_array_type (dhandle, - ieee_builtin_type (info, p, - ((unsigned int) - builtin_char)), - ieee_builtin_type (info, p, - ((unsigned int) - builtin_int)), - 0, -1, TRUE); - name = "QUOTED STRING"; - break; - - case builtin_instruction_address: - /* FIXME: This should be a code address. */ - type = debug_make_int_type (dhandle, 4, TRUE); - name = "instruction address"; - break; - - case builtin_int: - /* FIXME: The size for this type should depend upon the - processor. */ - type = debug_make_int_type (dhandle, 4, FALSE); - name = "int"; - break; - - case builtin_unsigned: - /* FIXME: The size for this type should depend upon the - processor. */ - type = debug_make_int_type (dhandle, 4, TRUE); - name = "unsigned"; - break; - - case builtin_unsigned_int: - /* FIXME: The size for this type should depend upon the - processor. */ - type = debug_make_int_type (dhandle, 4, TRUE); - name = "unsigned int"; - break; - - case builtin_char: - type = debug_make_int_type (dhandle, 1, FALSE); - name = "char"; - break; - - case builtin_long: - type = debug_make_int_type (dhandle, 4, FALSE); - name = "long"; - break; - - case builtin_short: - type = debug_make_int_type (dhandle, 2, FALSE); - name = "short"; - break; - - case builtin_unsigned_short: - type = debug_make_int_type (dhandle, 2, TRUE); - name = "unsigned short"; - break; - - case builtin_short_int: - type = debug_make_int_type (dhandle, 2, FALSE); - name = "short int"; - break; - - case builtin_signed_short: - type = debug_make_int_type (dhandle, 2, FALSE); - name = "signed short"; - break; - - case builtin_bcd_float: - ieee_error (info, p, _("BCD float type not supported")); - return DEBUG_TYPE_NULL; - } - - if (name != NULL) - type = debug_name_type (dhandle, name, type); - - assert (indx < BUILTIN_TYPE_COUNT); - - info->types.builtins[indx] = type; - - return type; -} - -/* Allocate more space in the type table. If ref is TRUE, this is a - reference to the type; if it is not already defined, we should set - up an indirect type. */ - -static bfd_boolean -ieee_alloc_type (struct ieee_info *info, unsigned int indx, bfd_boolean ref) -{ - unsigned int nalloc; - register struct ieee_type *t; - struct ieee_type *tend; - - if (indx >= info->types.alloc) - { - nalloc = info->types.alloc; - if (nalloc == 0) - nalloc = 4; - while (indx >= nalloc) - nalloc *= 2; - - info->types.types = ((struct ieee_type *) - xrealloc (info->types.types, - nalloc * sizeof *info->types.types)); - - memset (info->types.types + info->types.alloc, 0, - (nalloc - info->types.alloc) * sizeof *info->types.types); - - tend = info->types.types + nalloc; - for (t = info->types.types + info->types.alloc; t < tend; t++) - t->type = DEBUG_TYPE_NULL; - - info->types.alloc = nalloc; - } - - if (ref) - { - t = info->types.types + indx; - if (t->type == NULL) - { - t->pslot = (debug_type *) xmalloc (sizeof *t->pslot); - *t->pslot = DEBUG_TYPE_NULL; - t->type = debug_make_indirect_type (info->dhandle, t->pslot, - (const char *) NULL); - if (t->type == NULL) - return FALSE; - } - } - - return TRUE; -} - -/* Read a type index and return the corresponding type. */ - -static bfd_boolean -ieee_read_type_index (struct ieee_info *info, const bfd_byte **pp, - debug_type *ptype) -{ - const bfd_byte *start; - bfd_vma indx; - - start = *pp; - - if (! ieee_read_number (info, pp, &indx)) - return FALSE; - - if (indx < 256) - { - *ptype = ieee_builtin_type (info, start, indx); - if (*ptype == NULL) - return FALSE; - return TRUE; - } - - indx -= 256; - if (! ieee_alloc_type (info, indx, TRUE)) - return FALSE; - - *ptype = info->types.types[indx].type; - - return TRUE; -} - -/* Parse IEEE debugging information for a file. This is passed the - bytes which compose the Debug Information Part of an IEEE file. */ - -bfd_boolean -parse_ieee (void *dhandle, bfd *abfd, const bfd_byte *bytes, bfd_size_type len) -{ - struct ieee_info info; - unsigned int i; - const bfd_byte *p, *pend; - - info.dhandle = dhandle; - info.abfd = abfd; - info.bytes = bytes; - info.pend = bytes + len; - info.blockstack.bsp = info.blockstack.stack; - info.saw_filename = FALSE; - info.vars.alloc = 0; - info.vars.vars = NULL; - info.global_vars = NULL; - info.types.alloc = 0; - info.types.types = NULL; - info.global_types = NULL; - info.tags = NULL; - for (i = 0; i < BUILTIN_TYPE_COUNT; i++) - info.types.builtins[i] = DEBUG_TYPE_NULL; - - p = bytes; - pend = info.pend; - while (p < pend) - { - const bfd_byte *record_start; - ieee_record_enum_type c; - - record_start = p; - - c = (ieee_record_enum_type) *p++; - - if (c == ieee_at_record_enum) - c = (ieee_record_enum_type) (((unsigned int) c << 8) | *p++); - - if (c <= ieee_number_repeat_end_enum) - { - ieee_error (&info, record_start, _("unexpected number")); - return FALSE; - } - - switch (c) - { - default: - ieee_error (&info, record_start, _("unexpected record type")); - return FALSE; - - case ieee_bb_record_enum: - if (! parse_ieee_bb (&info, &p)) - return FALSE; - break; - - case ieee_be_record_enum: - if (! parse_ieee_be (&info, &p)) - return FALSE; - break; - - case ieee_nn_record: - if (! parse_ieee_nn (&info, &p)) - return FALSE; - break; - - case ieee_ty_record_enum: - if (! parse_ieee_ty (&info, &p)) - return FALSE; - break; - - case ieee_atn_record_enum: - if (! parse_ieee_atn (&info, &p)) - return FALSE; - break; - } - } - - if (info.blockstack.bsp != info.blockstack.stack) - { - ieee_error (&info, (const bfd_byte *) NULL, - _("blocks left on stack at end")); - return FALSE; - } - - return TRUE; -} - -/* Handle an IEEE BB record. */ - -static bfd_boolean -parse_ieee_bb (struct ieee_info *info, const bfd_byte **pp) -{ - const bfd_byte *block_start; - bfd_byte b; - bfd_vma size; - const char *name; - unsigned long namlen; - char *namcopy = NULL; - unsigned int fnindx; - bfd_boolean skip; - - block_start = *pp; - - b = **pp; - ++*pp; - - if (! ieee_read_number (info, pp, &size) - || ! ieee_read_id (info, pp, &name, &namlen)) - return FALSE; - - fnindx = (unsigned int) -1; - skip = FALSE; - - switch (b) - { - case 1: - /* BB1: Type definitions local to a module. */ - namcopy = savestring (name, namlen); - if (namcopy == NULL) - return FALSE; - if (! debug_set_filename (info->dhandle, namcopy)) - return FALSE; - info->saw_filename = TRUE; - - /* Discard any variables or types we may have seen before. */ - if (info->vars.vars != NULL) - free (info->vars.vars); - info->vars.vars = NULL; - info->vars.alloc = 0; - if (info->types.types != NULL) - free (info->types.types); - info->types.types = NULL; - info->types.alloc = 0; - - /* Initialize the types to the global types. */ - if (info->global_types != NULL) - { - info->types.alloc = info->global_types->alloc; - info->types.types = ((struct ieee_type *) - xmalloc (info->types.alloc - * sizeof (*info->types.types))); - memcpy (info->types.types, info->global_types->types, - info->types.alloc * sizeof (*info->types.types)); - } - - break; - - case 2: - /* BB2: Global type definitions. The name is supposed to be - empty, but we don't check. */ - if (! debug_set_filename (info->dhandle, "*global*")) - return FALSE; - info->saw_filename = TRUE; - break; - - case 3: - /* BB3: High level module block begin. We don't have to do - anything here. The name is supposed to be the same as for - the BB1, but we don't check. */ - break; - - case 4: - /* BB4: Global function. */ - { - bfd_vma stackspace, typindx, offset; - debug_type return_type; - - if (! ieee_read_number (info, pp, &stackspace) - || ! ieee_read_number (info, pp, &typindx) - || ! ieee_read_expression (info, pp, &offset)) - return FALSE; - - /* We have no way to record the stack space. FIXME. */ - - if (typindx < 256) - { - return_type = ieee_builtin_type (info, block_start, typindx); - if (return_type == DEBUG_TYPE_NULL) - return FALSE; - } - else - { - typindx -= 256; - if (! ieee_alloc_type (info, typindx, TRUE)) - return FALSE; - fnindx = typindx; - return_type = info->types.types[typindx].type; - if (debug_get_type_kind (info->dhandle, return_type) - == DEBUG_KIND_FUNCTION) - return_type = debug_get_return_type (info->dhandle, - return_type); - } - - namcopy = savestring (name, namlen); - if (namcopy == NULL) - return FALSE; - if (! debug_record_function (info->dhandle, namcopy, return_type, - TRUE, offset)) - return FALSE; - } - break; - - case 5: - /* BB5: File name for source line numbers. */ - { - unsigned int i; - - /* We ignore the date and time. FIXME. */ - for (i = 0; i < 6; i++) - { - bfd_vma ignore; - bfd_boolean present; - - if (! ieee_read_optional_number (info, pp, &ignore, &present)) - return FALSE; - if (! present) - break; - } - - if (! info->saw_filename) - { - namcopy = savestring (name, namlen); - if (namcopy == NULL) - return FALSE; - if (! debug_set_filename (info->dhandle, namcopy)) - return FALSE; - info->saw_filename = TRUE; - } - - namcopy = savestring (name, namlen); - if (namcopy == NULL) - return FALSE; - if (! debug_start_source (info->dhandle, namcopy)) - return FALSE; - } - break; - - case 6: - /* BB6: Local function or block. */ - { - bfd_vma stackspace, typindx, offset; - - if (! ieee_read_number (info, pp, &stackspace) - || ! ieee_read_number (info, pp, &typindx) - || ! ieee_read_expression (info, pp, &offset)) - return FALSE; - - /* We have no way to record the stack space. FIXME. */ - - if (namlen == 0) - { - if (! debug_start_block (info->dhandle, offset)) - return FALSE; - /* Change b to indicate that this is a block - rather than a function. */ - b = 0x86; - } - else - { - /* The MRI C++ compiler will output a fake function named - __XRYCPP to hold C++ debugging information. We skip - that function. This is not crucial, but it makes - converting from IEEE to other debug formats work - better. */ - if (strncmp (name, "__XRYCPP", namlen) == 0) - skip = TRUE; - else - { - debug_type return_type; - - if (typindx < 256) - { - return_type = ieee_builtin_type (info, block_start, - typindx); - if (return_type == NULL) - return FALSE; - } - else - { - typindx -= 256; - if (! ieee_alloc_type (info, typindx, TRUE)) - return FALSE; - fnindx = typindx; - return_type = info->types.types[typindx].type; - if (debug_get_type_kind (info->dhandle, return_type) - == DEBUG_KIND_FUNCTION) - return_type = debug_get_return_type (info->dhandle, - return_type); - } - - namcopy = savestring (name, namlen); - if (namcopy == NULL) - return FALSE; - if (! debug_record_function (info->dhandle, namcopy, - return_type, FALSE, offset)) - return FALSE; - } - } - } - break; - - case 10: - /* BB10: Assembler module scope. In the normal case, we - completely ignore all this information. FIXME. */ - { - const char *inam, *vstr; - unsigned long inamlen, vstrlen; - bfd_vma tool_type; - bfd_boolean present; - unsigned int i; - - if (! info->saw_filename) - { - namcopy = savestring (name, namlen); - if (namcopy == NULL) - return FALSE; - if (! debug_set_filename (info->dhandle, namcopy)) - return FALSE; - info->saw_filename = TRUE; - } - - if (! ieee_read_id (info, pp, &inam, &inamlen) - || ! ieee_read_number (info, pp, &tool_type) - || ! ieee_read_optional_id (info, pp, &vstr, &vstrlen, &present)) - return FALSE; - for (i = 0; i < 6; i++) - { - bfd_vma ignore; - - if (! ieee_read_optional_number (info, pp, &ignore, &present)) - return FALSE; - if (! present) - break; - } - } - break; - - case 11: - /* BB11: Module section. We completely ignore all this - information. FIXME. */ - { - bfd_vma sectype, secindx, offset, map; - bfd_boolean present; - - if (! ieee_read_number (info, pp, §ype) - || ! ieee_read_number (info, pp, &secindx) - || ! ieee_read_expression (info, pp, &offset) - || ! ieee_read_optional_number (info, pp, &map, &present)) - return FALSE; - } - break; - - default: - ieee_error (info, block_start, _("unknown BB type")); - return FALSE; - } - - - /* Push this block on the block stack. */ - - if (info->blockstack.bsp >= info->blockstack.stack + BLOCKSTACK_SIZE) - { - ieee_error (info, (const bfd_byte *) NULL, _("stack overflow")); - return FALSE; - } - - info->blockstack.bsp->kind = b; - if (b == 5) - info->blockstack.bsp->filename = namcopy; - info->blockstack.bsp->fnindx = fnindx; - info->blockstack.bsp->skip = skip; - ++info->blockstack.bsp; - - return TRUE; -} - -/* Handle an IEEE BE record. */ - -static bfd_boolean -parse_ieee_be (struct ieee_info *info, const bfd_byte **pp) -{ - bfd_vma offset; - - if (info->blockstack.bsp <= info->blockstack.stack) - { - ieee_error (info, *pp, _("stack underflow")); - return FALSE; - } - --info->blockstack.bsp; - - switch (info->blockstack.bsp->kind) - { - case 2: - /* When we end the global typedefs block, we copy out the - contents of info->vars. This is because the variable indices - may be reused in the local blocks. However, we need to - preserve them so that we can locate a function returning a - reference variable whose type is named in the global typedef - block. */ - info->global_vars = ((struct ieee_vars *) - xmalloc (sizeof *info->global_vars)); - info->global_vars->alloc = info->vars.alloc; - info->global_vars->vars = ((struct ieee_var *) - xmalloc (info->vars.alloc - * sizeof (*info->vars.vars))); - memcpy (info->global_vars->vars, info->vars.vars, - info->vars.alloc * sizeof (*info->vars.vars)); - - /* We also copy out the non builtin parts of info->types, since - the types are discarded when we start a new block. */ - info->global_types = ((struct ieee_types *) - xmalloc (sizeof *info->global_types)); - info->global_types->alloc = info->types.alloc; - info->global_types->types = ((struct ieee_type *) - xmalloc (info->types.alloc - * sizeof (*info->types.types))); - memcpy (info->global_types->types, info->types.types, - info->types.alloc * sizeof (*info->types.types)); - memset (info->global_types->builtins, 0, - sizeof (info->global_types->builtins)); - - break; - - case 4: - case 6: - if (! ieee_read_expression (info, pp, &offset)) - return FALSE; - if (! info->blockstack.bsp->skip) - { - if (! debug_end_function (info->dhandle, offset + 1)) - return FALSE; - } - break; - - case 0x86: - /* This is BE6 when BB6 started a block rather than a local - function. */ - if (! ieee_read_expression (info, pp, &offset)) - return FALSE; - if (! debug_end_block (info->dhandle, offset + 1)) - return FALSE; - break; - - case 5: - /* When we end a BB5, we look up the stack for the last BB5, if - there is one, so that we can call debug_start_source. */ - if (info->blockstack.bsp > info->blockstack.stack) - { - struct ieee_block *bl; - - bl = info->blockstack.bsp; - do - { - --bl; - if (bl->kind == 5) - { - if (! debug_start_source (info->dhandle, bl->filename)) - return FALSE; - break; - } - } - while (bl != info->blockstack.stack); - } - break; - - case 11: - if (! ieee_read_expression (info, pp, &offset)) - return FALSE; - /* We just ignore the module size. FIXME. */ - break; - - default: - /* Other block types do not have any trailing information. */ - break; - } - - return TRUE; -} - -/* Parse an NN record. */ - -static bfd_boolean -parse_ieee_nn (struct ieee_info *info, const bfd_byte **pp) -{ - const bfd_byte *nn_start; - bfd_vma varindx; - const char *name; - unsigned long namlen; - - nn_start = *pp; - - if (! ieee_read_number (info, pp, &varindx) - || ! ieee_read_id (info, pp, &name, &namlen)) - return FALSE; - - if (varindx < 32) - { - ieee_error (info, nn_start, _("illegal variable index")); - return FALSE; - } - varindx -= 32; - - if (varindx >= info->vars.alloc) - { - unsigned int alloc; - - alloc = info->vars.alloc; - if (alloc == 0) - alloc = 4; - while (varindx >= alloc) - alloc *= 2; - info->vars.vars = ((struct ieee_var *) - xrealloc (info->vars.vars, - alloc * sizeof *info->vars.vars)); - memset (info->vars.vars + info->vars.alloc, 0, - (alloc - info->vars.alloc) * sizeof *info->vars.vars); - info->vars.alloc = alloc; - } - - info->vars.vars[varindx].name = name; - info->vars.vars[varindx].namlen = namlen; - - return TRUE; -} - -/* Parse a TY record. */ - -static bfd_boolean -parse_ieee_ty (struct ieee_info *info, const bfd_byte **pp) -{ - const bfd_byte *ty_start, *ty_var_start, *ty_code_start; - bfd_vma typeindx, varindx, tc; - void *dhandle; - bfd_boolean tag, typdef; - debug_type *arg_slots; - unsigned long type_bitsize; - debug_type type; - - ty_start = *pp; - - if (! ieee_read_number (info, pp, &typeindx)) - return FALSE; - - if (typeindx < 256) - { - ieee_error (info, ty_start, _("illegal type index")); - return FALSE; - } - - typeindx -= 256; - if (! ieee_alloc_type (info, typeindx, FALSE)) - return FALSE; - - if (**pp != 0xce) - { - ieee_error (info, *pp, _("unknown TY code")); - return FALSE; - } - ++*pp; - - ty_var_start = *pp; - - if (! ieee_read_number (info, pp, &varindx)) - return FALSE; - - if (varindx < 32) - { - ieee_error (info, ty_var_start, _("illegal variable index")); - return FALSE; - } - varindx -= 32; - - if (varindx >= info->vars.alloc || info->vars.vars[varindx].name == NULL) - { - ieee_error (info, ty_var_start, _("undefined variable in TY")); - return FALSE; - } - - ty_code_start = *pp; - - if (! ieee_read_number (info, pp, &tc)) - return FALSE; - - dhandle = info->dhandle; - - tag = FALSE; - typdef = FALSE; - arg_slots = NULL; - type_bitsize = 0; - switch (tc) - { - default: - ieee_error (info, ty_code_start, _("unknown TY code")); - return FALSE; - - case '!': - /* Unknown type, with size. We treat it as int. FIXME. */ - { - bfd_vma size; - - if (! ieee_read_number (info, pp, &size)) - return FALSE; - type = debug_make_int_type (dhandle, size, FALSE); - } - break; - - case 'A': /* Array. */ - case 'a': /* FORTRAN array in column/row order. FIXME: Not - distinguished from normal array. */ - { - debug_type ele_type; - bfd_vma lower, upper; - - if (! ieee_read_type_index (info, pp, &ele_type) - || ! ieee_read_number (info, pp, &lower) - || ! ieee_read_number (info, pp, &upper)) - return FALSE; - type = debug_make_array_type (dhandle, ele_type, - ieee_builtin_type (info, ty_code_start, - ((unsigned int) - builtin_int)), - (bfd_signed_vma) lower, - (bfd_signed_vma) upper, - FALSE); - } - break; - - case 'E': - /* Simple enumeration. */ - { - bfd_vma size; - unsigned int alloc; - const char **names; - unsigned int c; - bfd_signed_vma *vals; - unsigned int i; - - if (! ieee_read_number (info, pp, &size)) - return FALSE; - /* FIXME: we ignore the enumeration size. */ - - alloc = 10; - names = (const char **) xmalloc (alloc * sizeof *names); - memset (names, 0, alloc * sizeof *names); - c = 0; - while (1) - { - const char *name; - unsigned long namlen; - bfd_boolean present; - - if (! ieee_read_optional_id (info, pp, &name, &namlen, &present)) - return FALSE; - if (! present) - break; - - if (c + 1 >= alloc) - { - alloc += 10; - names = ((const char **) - xrealloc (names, alloc * sizeof *names)); - } - - names[c] = savestring (name, namlen); - if (names[c] == NULL) - return FALSE; - ++c; - } - - names[c] = NULL; - - vals = (bfd_signed_vma *) xmalloc (c * sizeof *vals); - for (i = 0; i < c; i++) - vals[i] = i; - - type = debug_make_enum_type (dhandle, names, vals); - tag = TRUE; - } - break; - - case 'G': - /* Struct with bit fields. */ - { - bfd_vma size; - unsigned int alloc; - debug_field *fields; - unsigned int c; - - if (! ieee_read_number (info, pp, &size)) - return FALSE; - - alloc = 10; - fields = (debug_field *) xmalloc (alloc * sizeof *fields); - c = 0; - while (1) - { - const char *name; - unsigned long namlen; - bfd_boolean present; - debug_type ftype; - bfd_vma bitpos, bitsize; - - if (! ieee_read_optional_id (info, pp, &name, &namlen, &present)) - return FALSE; - if (! present) - break; - if (! ieee_read_type_index (info, pp, &ftype) - || ! ieee_read_number (info, pp, &bitpos) - || ! ieee_read_number (info, pp, &bitsize)) - return FALSE; - - if (c + 1 >= alloc) - { - alloc += 10; - fields = ((debug_field *) - xrealloc (fields, alloc * sizeof *fields)); - } - - fields[c] = debug_make_field (dhandle, savestring (name, namlen), - ftype, bitpos, bitsize, - DEBUG_VISIBILITY_PUBLIC); - if (fields[c] == NULL) - return FALSE; - ++c; - } - - fields[c] = NULL; - - type = debug_make_struct_type (dhandle, TRUE, size, fields); - tag = TRUE; - } - break; - - case 'N': - /* Enumeration. */ - { - unsigned int alloc; - const char **names; - bfd_signed_vma *vals; - unsigned int c; - - alloc = 10; - names = (const char **) xmalloc (alloc * sizeof *names); - vals = (bfd_signed_vma *) xmalloc (alloc * sizeof *names); - c = 0; - while (1) - { - const char *name; - unsigned long namlen; - bfd_boolean present; - bfd_vma val; - - if (! ieee_read_optional_id (info, pp, &name, &namlen, &present)) - return FALSE; - if (! present) - break; - if (! ieee_read_number (info, pp, &val)) - return FALSE; - - /* If the length of the name is zero, then the value is - actually the size of the enum. We ignore this - information. FIXME. */ - if (namlen == 0) - continue; - - if (c + 1 >= alloc) - { - alloc += 10; - names = ((const char **) - xrealloc (names, alloc * sizeof *names)); - vals = ((bfd_signed_vma *) - xrealloc (vals, alloc * sizeof *vals)); - } - - names[c] = savestring (name, namlen); - if (names[c] == NULL) - return FALSE; - vals[c] = (bfd_signed_vma) val; - ++c; - } - - names[c] = NULL; - - type = debug_make_enum_type (dhandle, names, vals); - tag = TRUE; - } - break; - - case 'O': /* Small pointer. We don't distinguish small and large - pointers. FIXME. */ - case 'P': /* Large pointer. */ - { - debug_type t; - - if (! ieee_read_type_index (info, pp, &t)) - return FALSE; - type = debug_make_pointer_type (dhandle, t); - } - break; - - case 'R': - /* Range. */ - { - bfd_vma low, high, signedp, size; - - if (! ieee_read_number (info, pp, &low) - || ! ieee_read_number (info, pp, &high) - || ! ieee_read_number (info, pp, &signedp) - || ! ieee_read_number (info, pp, &size)) - return FALSE; - - type = debug_make_range_type (dhandle, - debug_make_int_type (dhandle, size, - ! signedp), - (bfd_signed_vma) low, - (bfd_signed_vma) high); - } - break; - - case 'S': /* Struct. */ - case 'U': /* Union. */ - { - bfd_vma size; - unsigned int alloc; - debug_field *fields; - unsigned int c; - - if (! ieee_read_number (info, pp, &size)) - return FALSE; - - alloc = 10; - fields = (debug_field *) xmalloc (alloc * sizeof *fields); - c = 0; - while (1) - { - const char *name; - unsigned long namlen; - bfd_boolean present; - bfd_vma tindx; - bfd_vma offset; - debug_type ftype; - bfd_vma bitsize; - - if (! ieee_read_optional_id (info, pp, &name, &namlen, &present)) - return FALSE; - if (! present) - break; - if (! ieee_read_number (info, pp, &tindx) - || ! ieee_read_number (info, pp, &offset)) - return FALSE; - - if (tindx < 256) - { - ftype = ieee_builtin_type (info, ty_code_start, tindx); - bitsize = 0; - offset *= 8; - } - else - { - struct ieee_type *t; - - tindx -= 256; - if (! ieee_alloc_type (info, tindx, TRUE)) - return FALSE; - t = info->types.types + tindx; - ftype = t->type; - bitsize = t->bitsize; - if (bitsize == 0) - offset *= 8; - } - - if (c + 1 >= alloc) - { - alloc += 10; - fields = ((debug_field *) - xrealloc (fields, alloc * sizeof *fields)); - } - - fields[c] = debug_make_field (dhandle, savestring (name, namlen), - ftype, offset, bitsize, - DEBUG_VISIBILITY_PUBLIC); - if (fields[c] == NULL) - return FALSE; - ++c; - } - - fields[c] = NULL; - - type = debug_make_struct_type (dhandle, tc == 'S', size, fields); - tag = TRUE; - } - break; - - case 'T': - /* Typedef. */ - if (! ieee_read_type_index (info, pp, &type)) - return FALSE; - typdef = TRUE; - break; - - case 'X': - /* Procedure. FIXME: This is an extern declaration, which we - have no way of representing. */ - { - bfd_vma attr; - debug_type rtype; - bfd_vma nargs; - bfd_boolean present; - struct ieee_var *pv; - - /* FIXME: We ignore the attribute and the argument names. */ - - if (! ieee_read_number (info, pp, &attr) - || ! ieee_read_type_index (info, pp, &rtype) - || ! ieee_read_number (info, pp, &nargs)) - return FALSE; - do - { - const char *name; - unsigned long namlen; - - if (! ieee_read_optional_id (info, pp, &name, &namlen, &present)) - return FALSE; - } - while (present); - - pv = info->vars.vars + varindx; - pv->kind = IEEE_EXTERNAL; - if (pv->namlen > 0 - && debug_get_type_kind (dhandle, rtype) == DEBUG_KIND_POINTER) - { - /* Set up the return type as an indirect type pointing to - the variable slot, so that we can change it to a - reference later if appropriate. */ - pv->pslot = (debug_type *) xmalloc (sizeof *pv->pslot); - *pv->pslot = rtype; - rtype = debug_make_indirect_type (dhandle, pv->pslot, - (const char *) NULL); - } - - type = debug_make_function_type (dhandle, rtype, (debug_type *) NULL, - FALSE); - } - break; - - case 'V': - case 'v': - /* Void. This is not documented, but the MRI compiler emits it. */ - type = debug_make_void_type (dhandle); - break; - - case 'Z': - /* Array with 0 lower bound. */ - { - debug_type etype; - bfd_vma high; - - if (! ieee_read_type_index (info, pp, &etype) - || ! ieee_read_number (info, pp, &high)) - return FALSE; - - type = debug_make_array_type (dhandle, etype, - ieee_builtin_type (info, ty_code_start, - ((unsigned int) - builtin_int)), - 0, (bfd_signed_vma) high, FALSE); - } - break; - - case 'c': /* Complex. */ - case 'd': /* Double complex. */ - { - const char *name; - unsigned long namlen; - - /* FIXME: I don't know what the name means. */ - - if (! ieee_read_id (info, pp, &name, &namlen)) - return FALSE; - - type = debug_make_complex_type (dhandle, tc == 'c' ? 4 : 8); - } - break; - - case 'f': - /* Pascal file name. FIXME. */ - ieee_error (info, ty_code_start, _("Pascal file name not supported")); - return FALSE; - - case 'g': - /* Bitfield type. */ - { - bfd_vma signedp, bitsize, dummy; - const bfd_byte *hold; - bfd_boolean present; - - if (! ieee_read_number (info, pp, &signedp) - || ! ieee_read_number (info, pp, &bitsize)) - return FALSE; - - /* I think the documentation says that there is a type index, - but some actual files do not have one. */ - hold = *pp; - if (! ieee_read_optional_number (info, pp, &dummy, &present)) - return FALSE; - if (! present) - { - /* FIXME: This is just a guess. */ - type = debug_make_int_type (dhandle, 4, - signedp ? FALSE : TRUE); - } - else - { - *pp = hold; - if (! ieee_read_type_index (info, pp, &type)) - return FALSE; - } - type_bitsize = bitsize; - } - break; - - case 'n': - /* Qualifier. */ - { - bfd_vma kind; - debug_type t; - - if (! ieee_read_number (info, pp, &kind) - || ! ieee_read_type_index (info, pp, &t)) - return FALSE; - - switch (kind) - { - default: - ieee_error (info, ty_start, _("unsupported qualifier")); - return FALSE; - - case 1: - type = debug_make_const_type (dhandle, t); - break; - - case 2: - type = debug_make_volatile_type (dhandle, t); - break; - } - } - break; - - case 's': - /* Set. */ - { - bfd_vma size; - debug_type etype; - - if (! ieee_read_number (info, pp, &size) - || ! ieee_read_type_index (info, pp, &etype)) - return FALSE; - - /* FIXME: We ignore the size. */ - - type = debug_make_set_type (dhandle, etype, FALSE); - } - break; - - case 'x': - /* Procedure with compiler dependencies. */ - { - struct ieee_var *pv; - bfd_vma attr, frame_type, push_mask, nargs, level, father; - debug_type rtype; - debug_type *arg_types; - bfd_boolean varargs; - bfd_boolean present; - - /* FIXME: We ignore some of this information. */ - - pv = info->vars.vars + varindx; - - if (! ieee_read_number (info, pp, &attr) - || ! ieee_read_number (info, pp, &frame_type) - || ! ieee_read_number (info, pp, &push_mask) - || ! ieee_read_type_index (info, pp, &rtype) - || ! ieee_read_number (info, pp, &nargs)) - return FALSE; - if (nargs == (bfd_vma) -1) - { - arg_types = NULL; - varargs = FALSE; - } - else - { - unsigned int i; - - arg_types = ((debug_type *) - xmalloc ((nargs + 1) * sizeof *arg_types)); - for (i = 0; i < nargs; i++) - if (! ieee_read_type_index (info, pp, arg_types + i)) - return FALSE; - - /* If the last type is pointer to void, this is really a - varargs function. */ - varargs = FALSE; - if (nargs > 0) - { - debug_type last; - - last = arg_types[nargs - 1]; - if (debug_get_type_kind (dhandle, last) == DEBUG_KIND_POINTER - && (debug_get_type_kind (dhandle, - debug_get_target_type (dhandle, - last)) - == DEBUG_KIND_VOID)) - { - --nargs; - varargs = TRUE; - } - } - - /* If there are any pointer arguments, turn them into - indirect types in case we later need to convert them to - reference types. */ - for (i = 0; i < nargs; i++) - { - if (debug_get_type_kind (dhandle, arg_types[i]) - == DEBUG_KIND_POINTER) - { - if (arg_slots == NULL) - { - arg_slots = ((debug_type *) - xmalloc (nargs * sizeof *arg_slots)); - memset (arg_slots, 0, nargs * sizeof *arg_slots); - } - arg_slots[i] = arg_types[i]; - arg_types[i] = - debug_make_indirect_type (dhandle, - arg_slots + i, - (const char *) NULL); - } - } - - arg_types[nargs] = DEBUG_TYPE_NULL; - } - if (! ieee_read_number (info, pp, &level) - || ! ieee_read_optional_number (info, pp, &father, &present)) - return FALSE; - - /* We can't distinguish between a global function and a static - function. */ - pv->kind = IEEE_FUNCTION; - - if (pv->namlen > 0 - && debug_get_type_kind (dhandle, rtype) == DEBUG_KIND_POINTER) - { - /* Set up the return type as an indirect type pointing to - the variable slot, so that we can change it to a - reference later if appropriate. */ - pv->pslot = (debug_type *) xmalloc (sizeof *pv->pslot); - *pv->pslot = rtype; - rtype = debug_make_indirect_type (dhandle, pv->pslot, - (const char *) NULL); - } - - type = debug_make_function_type (dhandle, rtype, arg_types, varargs); - } - break; - } - - /* Record the type in the table. */ - - if (type == DEBUG_TYPE_NULL) - return FALSE; - - info->vars.vars[varindx].type = type; - - if ((tag || typdef) - && info->vars.vars[varindx].namlen > 0) - { - const char *name; - - name = savestring (info->vars.vars[varindx].name, - info->vars.vars[varindx].namlen); - if (typdef) - type = debug_name_type (dhandle, name, type); - else if (tc == 'E' || tc == 'N') - type = debug_tag_type (dhandle, name, type); - else - { - struct ieee_tag *it; - - /* We must allocate all struct tags as indirect types, so - that if we later see a definition of the tag as a C++ - record we can update the indirect slot and automatically - change all the existing references. */ - it = (struct ieee_tag *) xmalloc (sizeof *it); - memset (it, 0, sizeof *it); - it->next = info->tags; - info->tags = it; - it->name = name; - it->slot = type; - - type = debug_make_indirect_type (dhandle, &it->slot, name); - type = debug_tag_type (dhandle, name, type); - - it->type = type; - } - if (type == NULL) - return FALSE; - } - - info->types.types[typeindx].type = type; - info->types.types[typeindx].arg_slots = arg_slots; - info->types.types[typeindx].bitsize = type_bitsize; - - /* We may have already allocated type as an indirect type pointing - to slot. It does no harm to replace the indirect type with the - real type. Filling in slot as well handles the indirect types - which are already hanging around. */ - if (info->types.types[typeindx].pslot != NULL) - *info->types.types[typeindx].pslot = type; - - return TRUE; -} - -/* Parse an ATN record. */ - -static bfd_boolean -parse_ieee_atn (struct ieee_info *info, const bfd_byte **pp) -{ - const bfd_byte *atn_start, *atn_code_start; - bfd_vma varindx; - struct ieee_var *pvar; - debug_type type; - bfd_vma atn_code; - void *dhandle; - bfd_vma v, v2, v3, v4, v5; - const char *name; - unsigned long namlen; - char *namcopy; - bfd_boolean present; - int blocktype; - - atn_start = *pp; - - if (! ieee_read_number (info, pp, &varindx) - || ! ieee_read_type_index (info, pp, &type)) - return FALSE; - - atn_code_start = *pp; - - if (! ieee_read_number (info, pp, &atn_code)) - return FALSE; - - if (varindx == 0) - { - pvar = NULL; - name = ""; - namlen = 0; - } - else if (varindx < 32) - { - /* The MRI compiler reportedly sometimes emits variable lifetime - information for a register. We just ignore it. */ - if (atn_code == 9) - return ieee_read_number (info, pp, &v); - - ieee_error (info, atn_start, _("illegal variable index")); - return FALSE; - } - else - { - varindx -= 32; - if (varindx >= info->vars.alloc - || info->vars.vars[varindx].name == NULL) - { - /* The MRI compiler or linker sometimes omits the NN record - for a pmisc record. */ - if (atn_code == 62) - { - if (varindx >= info->vars.alloc) - { - unsigned int alloc; - - alloc = info->vars.alloc; - if (alloc == 0) - alloc = 4; - while (varindx >= alloc) - alloc *= 2; - info->vars.vars = ((struct ieee_var *) - xrealloc (info->vars.vars, - (alloc - * sizeof *info->vars.vars))); - memset (info->vars.vars + info->vars.alloc, 0, - ((alloc - info->vars.alloc) - * sizeof *info->vars.vars)); - info->vars.alloc = alloc; - } - - pvar = info->vars.vars + varindx; - pvar->name = ""; - pvar->namlen = 0; - } - else - { - ieee_error (info, atn_start, _("undefined variable in ATN")); - return FALSE; - } - } - - pvar = info->vars.vars + varindx; - - pvar->type = type; - - name = pvar->name; - namlen = pvar->namlen; - } - - dhandle = info->dhandle; - - /* If we are going to call debug_record_variable with a pointer - type, change the type to an indirect type so that we can later - change it to a reference type if we encounter a C++ pmisc 'R' - record. */ - if (pvar != NULL - && type != DEBUG_TYPE_NULL - && debug_get_type_kind (dhandle, type) == DEBUG_KIND_POINTER) - { - switch (atn_code) - { - case 1: - case 2: - case 3: - case 5: - case 8: - case 10: - pvar->pslot = (debug_type *) xmalloc (sizeof *pvar->pslot); - *pvar->pslot = type; - type = debug_make_indirect_type (dhandle, pvar->pslot, - (const char *) NULL); - pvar->type = type; - break; - } - } - - switch (atn_code) - { - default: - ieee_error (info, atn_code_start, _("unknown ATN type")); - return FALSE; - - case 1: - /* Automatic variable. */ - if (! ieee_read_number (info, pp, &v)) - return FALSE; - namcopy = savestring (name, namlen); - if (type == NULL) - type = debug_make_void_type (dhandle); - if (pvar != NULL) - pvar->kind = IEEE_LOCAL; - return debug_record_variable (dhandle, namcopy, type, DEBUG_LOCAL, v); - - case 2: - /* Register variable. */ - if (! ieee_read_number (info, pp, &v)) - return FALSE; - namcopy = savestring (name, namlen); - if (type == NULL) - type = debug_make_void_type (dhandle); - if (pvar != NULL) - pvar->kind = IEEE_LOCAL; - return debug_record_variable (dhandle, namcopy, type, DEBUG_REGISTER, - ieee_regno_to_genreg (info->abfd, v)); - - case 3: - /* Static variable. */ - if (! ieee_require_asn (info, pp, &v)) - return FALSE; - namcopy = savestring (name, namlen); - if (type == NULL) - type = debug_make_void_type (dhandle); - if (info->blockstack.bsp <= info->blockstack.stack) - blocktype = 0; - else - blocktype = info->blockstack.bsp[-1].kind; - if (pvar != NULL) - { - if (blocktype == 4 || blocktype == 6) - pvar->kind = IEEE_LOCAL; - else - pvar->kind = IEEE_STATIC; - } - return debug_record_variable (dhandle, namcopy, type, - (blocktype == 4 || blocktype == 6 - ? DEBUG_LOCAL_STATIC - : DEBUG_STATIC), - v); - - case 4: - /* External function. We don't currently record these. FIXME. */ - if (pvar != NULL) - pvar->kind = IEEE_EXTERNAL; - return TRUE; - - case 5: - /* External variable. We don't currently record these. FIXME. */ - if (pvar != NULL) - pvar->kind = IEEE_EXTERNAL; - return TRUE; - - case 7: - if (! ieee_read_number (info, pp, &v) - || ! ieee_read_number (info, pp, &v2) - || ! ieee_read_optional_number (info, pp, &v3, &present)) - return FALSE; - if (present) - { - if (! ieee_read_optional_number (info, pp, &v4, &present)) - return FALSE; - } - - /* We just ignore the two optional fields in v3 and v4, since - they are not defined. */ - - if (! ieee_require_asn (info, pp, &v3)) - return FALSE; - - /* We have no way to record the column number. FIXME. */ - - return debug_record_line (dhandle, v, v3); - - case 8: - /* Global variable. */ - if (! ieee_require_asn (info, pp, &v)) - return FALSE; - namcopy = savestring (name, namlen); - if (type == NULL) - type = debug_make_void_type (dhandle); - if (pvar != NULL) - pvar->kind = IEEE_GLOBAL; - return debug_record_variable (dhandle, namcopy, type, DEBUG_GLOBAL, v); - - case 9: - /* Variable lifetime information. */ - if (! ieee_read_number (info, pp, &v)) - return FALSE; - - /* We have no way to record this information. FIXME. */ - return TRUE; - - case 10: - /* Locked register. The spec says that there are two required - fields, but at least on occasion the MRI compiler only emits - one. */ - if (! ieee_read_number (info, pp, &v) - || ! ieee_read_optional_number (info, pp, &v2, &present)) - return FALSE; - - /* I think this means a variable that is both in a register and - a frame slot. We ignore the frame slot. FIXME. */ - - namcopy = savestring (name, namlen); - if (type == NULL) - type = debug_make_void_type (dhandle); - if (pvar != NULL) - pvar->kind = IEEE_LOCAL; - return debug_record_variable (dhandle, namcopy, type, DEBUG_REGISTER, v); - - case 11: - /* Reserved for FORTRAN common. */ - ieee_error (info, atn_code_start, _("unsupported ATN11")); - - /* Return TRUE to keep going. */ - return TRUE; - - case 12: - /* Based variable. */ - v3 = 0; - v4 = 0x80; - v5 = 0; - if (! ieee_read_number (info, pp, &v) - || ! ieee_read_number (info, pp, &v2) - || ! ieee_read_optional_number (info, pp, &v3, &present)) - return FALSE; - if (present) - { - if (! ieee_read_optional_number (info, pp, &v4, &present)) - return FALSE; - if (present) - { - if (! ieee_read_optional_number (info, pp, &v5, &present)) - return FALSE; - } - } - - /* We have no way to record this information. FIXME. */ - - ieee_error (info, atn_code_start, _("unsupported ATN12")); - - /* Return TRUE to keep going. */ - return TRUE; - - case 16: - /* Constant. The description of this that I have is ambiguous, - so I'm not going to try to implement it. */ - if (! ieee_read_number (info, pp, &v) - || ! ieee_read_optional_number (info, pp, &v2, &present)) - return FALSE; - if (present) - { - if (! ieee_read_optional_number (info, pp, &v2, &present)) - return FALSE; - if (present) - { - if (! ieee_read_optional_id (info, pp, &name, &namlen, &present)) - return FALSE; - } - } - - if ((ieee_record_enum_type) **pp == ieee_e2_first_byte_enum) - { - if (! ieee_require_asn (info, pp, &v3)) - return FALSE; - } - - return TRUE; - - case 19: - /* Static variable from assembler. */ - v2 = 0; - if (! ieee_read_number (info, pp, &v) - || ! ieee_read_optional_number (info, pp, &v2, &present) - || ! ieee_require_asn (info, pp, &v3)) - return FALSE; - namcopy = savestring (name, namlen); - /* We don't really handle this correctly. FIXME. */ - return debug_record_variable (dhandle, namcopy, - debug_make_void_type (dhandle), - v2 != 0 ? DEBUG_GLOBAL : DEBUG_STATIC, - v3); - - case 62: - /* Procedure miscellaneous information. */ - case 63: - /* Variable miscellaneous information. */ - case 64: - /* Module miscellaneous information. */ - if (! ieee_read_number (info, pp, &v) - || ! ieee_read_number (info, pp, &v2) - || ! ieee_read_optional_id (info, pp, &name, &namlen, &present)) - return FALSE; - - if (atn_code == 62 && v == 80) - { - if (present) - { - ieee_error (info, atn_code_start, - _("unexpected string in C++ misc")); - return FALSE; - } - return ieee_read_cxx_misc (info, pp, v2); - } - - /* We just ignore all of this stuff. FIXME. */ - - for (; v2 > 0; --v2) - { - switch ((ieee_record_enum_type) **pp) - { - default: - ieee_error (info, *pp, _("bad misc record")); - return FALSE; - - case ieee_at_record_enum: - if (! ieee_require_atn65 (info, pp, &name, &namlen)) - return FALSE; - break; - - case ieee_e2_first_byte_enum: - if (! ieee_require_asn (info, pp, &v3)) - return FALSE; - break; - } - } - - return TRUE; - } - - /*NOTREACHED*/ -} - -/* Handle C++ debugging miscellaneous records. This is called for - procedure miscellaneous records of type 80. */ - -static bfd_boolean -ieee_read_cxx_misc (struct ieee_info *info, const bfd_byte **pp, - unsigned long count) -{ - const bfd_byte *start; - bfd_vma category; - - start = *pp; - - /* Get the category of C++ misc record. */ - if (! ieee_require_asn (info, pp, &category)) - return FALSE; - --count; - - switch (category) - { - default: - ieee_error (info, start, _("unrecognized C++ misc record")); - return FALSE; - - case 'T': - if (! ieee_read_cxx_class (info, pp, count)) - return FALSE; - break; - - case 'M': - { - bfd_vma flags; - const char *name; - unsigned long namlen; - - /* The IEEE spec indicates that the 'M' record only has a - flags field. The MRI compiler also emits the name of the - function. */ - - if (! ieee_require_asn (info, pp, &flags)) - return FALSE; - if (*pp < info->pend - && (ieee_record_enum_type) **pp == ieee_at_record_enum) - { - if (! ieee_require_atn65 (info, pp, &name, &namlen)) - return FALSE; - } - - /* This is emitted for method functions, but I don't think we - care very much. It might help if it told us useful - information like the class with which this function is - associated, but it doesn't, so it isn't helpful. */ - } - break; - - case 'B': - if (! ieee_read_cxx_defaults (info, pp, count)) - return FALSE; - break; - - case 'z': - { - const char *name, *mangled, *cxx_class; - unsigned long namlen, mangledlen, classlen; - bfd_vma control; - - /* Pointer to member. */ - - if (! ieee_require_atn65 (info, pp, &name, &namlen) - || ! ieee_require_atn65 (info, pp, &mangled, &mangledlen) - || ! ieee_require_atn65 (info, pp, &cxx_class, &classlen) - || ! ieee_require_asn (info, pp, &control)) - return FALSE; - - /* FIXME: We should now track down name and change its type. */ - } - break; - - case 'R': - if (! ieee_read_reference (info, pp)) - return FALSE; - break; - } - - return TRUE; -} - -/* Read a C++ class definition. This is a pmisc type 80 record of - category 'T'. */ - -static bfd_boolean -ieee_read_cxx_class (struct ieee_info *info, const bfd_byte **pp, - unsigned long count) -{ - const bfd_byte *start; - bfd_vma cxx_class; - const char *tag; - unsigned long taglen; - struct ieee_tag *it; - void *dhandle; - debug_field *fields; - unsigned int field_count, field_alloc; - debug_baseclass *baseclasses; - unsigned int baseclasses_count, baseclasses_alloc; - const debug_field *structfields; - struct ieee_method - { - const char *name; - unsigned long namlen; - debug_method_variant *variants; - unsigned count; - unsigned int alloc; - } *methods; - unsigned int methods_count, methods_alloc; - debug_type vptrbase; - bfd_boolean ownvptr; - debug_method *dmethods; - - start = *pp; - - if (! ieee_require_asn (info, pp, &cxx_class)) - return FALSE; - --count; - - if (! ieee_require_atn65 (info, pp, &tag, &taglen)) - return FALSE; - --count; - - /* Find the C struct with this name. */ - for (it = info->tags; it != NULL; it = it->next) - if (it->name[0] == tag[0] - && strncmp (it->name, tag, taglen) == 0 - && strlen (it->name) == taglen) - break; - if (it == NULL) - { - ieee_error (info, start, _("undefined C++ object")); - return FALSE; - } - - dhandle = info->dhandle; - - fields = NULL; - field_count = 0; - field_alloc = 0; - baseclasses = NULL; - baseclasses_count = 0; - baseclasses_alloc = 0; - methods = NULL; - methods_count = 0; - methods_alloc = 0; - vptrbase = DEBUG_TYPE_NULL; - ownvptr = FALSE; - - structfields = debug_get_fields (dhandle, it->type); - - while (count > 0) - { - bfd_vma id; - const bfd_byte *spec_start; - - spec_start = *pp; - - if (! ieee_require_asn (info, pp, &id)) - return FALSE; - --count; - - switch (id) - { - default: - ieee_error (info, spec_start, _("unrecognized C++ object spec")); - return FALSE; - - case 'b': - { - bfd_vma flags, cinline; - const char *base, *fieldname; - unsigned long baselen, fieldlen; - char *basecopy; - debug_type basetype; - bfd_vma bitpos; - bfd_boolean virtualp; - enum debug_visibility visibility; - debug_baseclass baseclass; - - /* This represents a base or friend class. */ - - if (! ieee_require_asn (info, pp, &flags) - || ! ieee_require_atn65 (info, pp, &base, &baselen) - || ! ieee_require_asn (info, pp, &cinline) - || ! ieee_require_atn65 (info, pp, &fieldname, &fieldlen)) - return FALSE; - count -= 4; - - /* We have no way of recording friend information, so we - just ignore it. */ - if ((flags & BASEFLAGS_FRIEND) != 0) - break; - - /* I assume that either all of the members of the - baseclass are included in the object, starting at the - beginning of the object, or that none of them are - included. */ - - if ((fieldlen == 0) == (cinline == 0)) - { - ieee_error (info, start, _("unsupported C++ object type")); - return FALSE; - } - - basecopy = savestring (base, baselen); - basetype = debug_find_tagged_type (dhandle, basecopy, - DEBUG_KIND_ILLEGAL); - free (basecopy); - if (basetype == DEBUG_TYPE_NULL) - { - ieee_error (info, start, _("C++ base class not defined")); - return FALSE; - } - - if (fieldlen == 0) - bitpos = 0; - else - { - const debug_field *pf; - - if (structfields == NULL) - { - ieee_error (info, start, _("C++ object has no fields")); - return FALSE; - } - - for (pf = structfields; *pf != DEBUG_FIELD_NULL; pf++) - { - const char *fname; - - fname = debug_get_field_name (dhandle, *pf); - if (fname == NULL) - return FALSE; - if (fname[0] == fieldname[0] - && strncmp (fname, fieldname, fieldlen) == 0 - && strlen (fname) == fieldlen) - break; - } - if (*pf == DEBUG_FIELD_NULL) - { - ieee_error (info, start, - _("C++ base class not found in container")); - return FALSE; - } - - bitpos = debug_get_field_bitpos (dhandle, *pf); - } - - if ((flags & BASEFLAGS_VIRTUAL) != 0) - virtualp = TRUE; - else - virtualp = FALSE; - if ((flags & BASEFLAGS_PRIVATE) != 0) - visibility = DEBUG_VISIBILITY_PRIVATE; - else - visibility = DEBUG_VISIBILITY_PUBLIC; - - baseclass = debug_make_baseclass (dhandle, basetype, bitpos, - virtualp, visibility); - if (baseclass == DEBUG_BASECLASS_NULL) - return FALSE; - - if (baseclasses_count + 1 >= baseclasses_alloc) - { - baseclasses_alloc += 10; - baseclasses = ((debug_baseclass *) - xrealloc (baseclasses, - (baseclasses_alloc - * sizeof *baseclasses))); - } - - baseclasses[baseclasses_count] = baseclass; - ++baseclasses_count; - baseclasses[baseclasses_count] = DEBUG_BASECLASS_NULL; - } - break; - - case 'd': - { - bfd_vma flags; - const char *fieldname, *mangledname; - unsigned long fieldlen, mangledlen; - char *fieldcopy; - bfd_boolean staticp; - debug_type ftype; - const debug_field *pf = NULL; - enum debug_visibility visibility; - debug_field field; - - /* This represents a data member. */ - - if (! ieee_require_asn (info, pp, &flags) - || ! ieee_require_atn65 (info, pp, &fieldname, &fieldlen) - || ! ieee_require_atn65 (info, pp, &mangledname, &mangledlen)) - return FALSE; - count -= 3; - - fieldcopy = savestring (fieldname, fieldlen); - - staticp = (flags & CXXFLAGS_STATIC) != 0 ? TRUE : FALSE; - - if (staticp) - { - struct ieee_var *pv, *pvend; - - /* See if we can find a definition for this variable. */ - pv = info->vars.vars; - pvend = pv + info->vars.alloc; - for (; pv < pvend; pv++) - if (pv->namlen == mangledlen - && strncmp (pv->name, mangledname, mangledlen) == 0) - break; - if (pv < pvend) - ftype = pv->type; - else - { - /* This can happen if the variable is never used. */ - ftype = ieee_builtin_type (info, start, - (unsigned int) builtin_void); - } - } - else - { - unsigned int findx; - - if (structfields == NULL) - { - ieee_error (info, start, _("C++ object has no fields")); - return FALSE; - } - - for (pf = structfields, findx = 0; - *pf != DEBUG_FIELD_NULL; - pf++, findx++) - { - const char *fname; - - fname = debug_get_field_name (dhandle, *pf); - if (fname == NULL) - return FALSE; - if (fname[0] == mangledname[0] - && strncmp (fname, mangledname, mangledlen) == 0 - && strlen (fname) == mangledlen) - break; - } - if (*pf == DEBUG_FIELD_NULL) - { - ieee_error (info, start, - _("C++ data member not found in container")); - return FALSE; - } - - ftype = debug_get_field_type (dhandle, *pf); - - if (debug_get_type_kind (dhandle, ftype) == DEBUG_KIND_POINTER) - { - /* We might need to convert this field into a - reference type later on, so make it an indirect - type. */ - if (it->fslots == NULL) - { - unsigned int fcnt; - const debug_field *pfcnt; - - fcnt = 0; - for (pfcnt = structfields; - *pfcnt != DEBUG_FIELD_NULL; - pfcnt++) - ++fcnt; - it->fslots = ((debug_type *) - xmalloc (fcnt * sizeof *it->fslots)); - memset (it->fslots, 0, - fcnt * sizeof *it->fslots); - } - - if (ftype == DEBUG_TYPE_NULL) - return FALSE; - it->fslots[findx] = ftype; - ftype = debug_make_indirect_type (dhandle, - it->fslots + findx, - (const char *) NULL); - } - } - if (ftype == DEBUG_TYPE_NULL) - return FALSE; - - switch (flags & CXXFLAGS_VISIBILITY) - { - default: - ieee_error (info, start, _("unknown C++ visibility")); - return FALSE; - - case CXXFLAGS_VISIBILITY_PUBLIC: - visibility = DEBUG_VISIBILITY_PUBLIC; - break; - - case CXXFLAGS_VISIBILITY_PRIVATE: - visibility = DEBUG_VISIBILITY_PRIVATE; - break; - - case CXXFLAGS_VISIBILITY_PROTECTED: - visibility = DEBUG_VISIBILITY_PROTECTED; - break; - } - - if (staticp) - { - char *mangledcopy; - - mangledcopy = savestring (mangledname, mangledlen); - - field = debug_make_static_member (dhandle, fieldcopy, - ftype, mangledcopy, - visibility); - } - else - { - bfd_vma bitpos, bitsize; - - bitpos = debug_get_field_bitpos (dhandle, *pf); - bitsize = debug_get_field_bitsize (dhandle, *pf); - if (bitpos == (bfd_vma) -1 || bitsize == (bfd_vma) -1) - { - ieee_error (info, start, _("bad C++ field bit pos or size")); - return FALSE; - } - field = debug_make_field (dhandle, fieldcopy, ftype, bitpos, - bitsize, visibility); - } - - if (field == DEBUG_FIELD_NULL) - return FALSE; - - if (field_count + 1 >= field_alloc) - { - field_alloc += 10; - fields = ((debug_field *) - xrealloc (fields, field_alloc * sizeof *fields)); - } - - fields[field_count] = field; - ++field_count; - fields[field_count] = DEBUG_FIELD_NULL; - } - break; - - case 'm': - case 'v': - { - bfd_vma flags, voffset, control; - const char *name, *mangled; - unsigned long namlen, mangledlen; - struct ieee_var *pv, *pvend; - debug_type type; - enum debug_visibility visibility; - bfd_boolean constp, volatilep; - char *mangledcopy; - debug_method_variant mv; - struct ieee_method *meth; - unsigned int im; - - if (! ieee_require_asn (info, pp, &flags) - || ! ieee_require_atn65 (info, pp, &name, &namlen) - || ! ieee_require_atn65 (info, pp, &mangled, &mangledlen)) - return FALSE; - count -= 3; - if (id != 'v') - voffset = 0; - else - { - if (! ieee_require_asn (info, pp, &voffset)) - return FALSE; - --count; - } - if (! ieee_require_asn (info, pp, &control)) - return FALSE; - --count; - - /* We just ignore the control information. */ - - /* We have no way to represent friend information, so we - just ignore it. */ - if ((flags & CXXFLAGS_FRIEND) != 0) - break; - - /* We should already have seen a type for the function. */ - pv = info->vars.vars; - pvend = pv + info->vars.alloc; - for (; pv < pvend; pv++) - if (pv->namlen == mangledlen - && strncmp (pv->name, mangled, mangledlen) == 0) - break; - - if (pv >= pvend) - { - /* We won't have type information for this function if - it is not included in this file. We don't try to - handle this case. FIXME. */ - type = (debug_make_function_type - (dhandle, - ieee_builtin_type (info, start, - (unsigned int) builtin_void), - (debug_type *) NULL, - FALSE)); - } - else - { - debug_type return_type; - const debug_type *arg_types; - bfd_boolean varargs = FALSE; - - if (debug_get_type_kind (dhandle, pv->type) - != DEBUG_KIND_FUNCTION) - { - ieee_error (info, start, - _("bad type for C++ method function")); - return FALSE; - } - - return_type = debug_get_return_type (dhandle, pv->type); - arg_types = debug_get_parameter_types (dhandle, pv->type, - &varargs); - if (return_type == DEBUG_TYPE_NULL || arg_types == NULL) - { - ieee_error (info, start, - _("no type information for C++ method function")); - return FALSE; - } - - type = debug_make_method_type (dhandle, return_type, it->type, - (debug_type *) arg_types, - varargs); - } - if (type == DEBUG_TYPE_NULL) - return FALSE; - - switch (flags & CXXFLAGS_VISIBILITY) - { - default: - ieee_error (info, start, _("unknown C++ visibility")); - return FALSE; - - case CXXFLAGS_VISIBILITY_PUBLIC: - visibility = DEBUG_VISIBILITY_PUBLIC; - break; - - case CXXFLAGS_VISIBILITY_PRIVATE: - visibility = DEBUG_VISIBILITY_PRIVATE; - break; - - case CXXFLAGS_VISIBILITY_PROTECTED: - visibility = DEBUG_VISIBILITY_PROTECTED; - break; - } - - constp = (flags & CXXFLAGS_CONST) != 0 ? TRUE : FALSE; - volatilep = (flags & CXXFLAGS_VOLATILE) != 0 ? TRUE : FALSE; - - mangledcopy = savestring (mangled, mangledlen); - - if ((flags & CXXFLAGS_STATIC) != 0) - { - if (id == 'v') - { - ieee_error (info, start, _("C++ static virtual method")); - return FALSE; - } - mv = debug_make_static_method_variant (dhandle, mangledcopy, - type, visibility, - constp, volatilep); - } - else - { - debug_type vcontext; - - if (id != 'v') - vcontext = DEBUG_TYPE_NULL; - else - { - /* FIXME: How can we calculate this correctly? */ - vcontext = it->type; - } - mv = debug_make_method_variant (dhandle, mangledcopy, type, - visibility, constp, - volatilep, voffset, - vcontext); - } - if (mv == DEBUG_METHOD_VARIANT_NULL) - return FALSE; - - for (meth = methods, im = 0; im < methods_count; meth++, im++) - if (meth->namlen == namlen - && strncmp (meth->name, name, namlen) == 0) - break; - if (im >= methods_count) - { - if (methods_count >= methods_alloc) - { - methods_alloc += 10; - methods = ((struct ieee_method *) - xrealloc (methods, - methods_alloc * sizeof *methods)); - } - methods[methods_count].name = name; - methods[methods_count].namlen = namlen; - methods[methods_count].variants = NULL; - methods[methods_count].count = 0; - methods[methods_count].alloc = 0; - meth = methods + methods_count; - ++methods_count; - } - - if (meth->count + 1 >= meth->alloc) - { - meth->alloc += 10; - meth->variants = ((debug_method_variant *) - xrealloc (meth->variants, - (meth->alloc - * sizeof *meth->variants))); - } - - meth->variants[meth->count] = mv; - ++meth->count; - meth->variants[meth->count] = DEBUG_METHOD_VARIANT_NULL; - } - break; - - case 'o': - { - bfd_vma spec; - - /* We have no way to store this information, so we just - ignore it. */ - if (! ieee_require_asn (info, pp, &spec)) - return FALSE; - --count; - if ((spec & 4) != 0) - { - const char *filename; - unsigned long filenamlen; - bfd_vma lineno; - - if (! ieee_require_atn65 (info, pp, &filename, &filenamlen) - || ! ieee_require_asn (info, pp, &lineno)) - return FALSE; - count -= 2; - } - else if ((spec & 8) != 0) - { - const char *mangled; - unsigned long mangledlen; - - if (! ieee_require_atn65 (info, pp, &mangled, &mangledlen)) - return FALSE; - --count; - } - else - { - ieee_error (info, start, - _("unrecognized C++ object overhead spec")); - return FALSE; - } - } - break; - - case 'z': - { - const char *vname, *base; - unsigned long vnamelen, baselen; - bfd_vma vsize, control; - - /* A virtual table pointer. */ - - if (! ieee_require_atn65 (info, pp, &vname, &vnamelen) - || ! ieee_require_asn (info, pp, &vsize) - || ! ieee_require_atn65 (info, pp, &base, &baselen) - || ! ieee_require_asn (info, pp, &control)) - return FALSE; - count -= 4; - - /* We just ignore the control number. We don't care what - the virtual table name is. We have no way to store the - virtual table size, and I don't think we care anyhow. */ - - /* FIXME: We can't handle multiple virtual table pointers. */ - - if (baselen == 0) - ownvptr = TRUE; - else - { - char *basecopy; - - basecopy = savestring (base, baselen); - vptrbase = debug_find_tagged_type (dhandle, basecopy, - DEBUG_KIND_ILLEGAL); - free (basecopy); - if (vptrbase == DEBUG_TYPE_NULL) - { - ieee_error (info, start, _("undefined C++ vtable")); - return FALSE; - } - } - } - break; - } - } - - /* Now that we have seen all the method variants, we can call - debug_make_method for each one. */ - - if (methods_count == 0) - dmethods = NULL; - else - { - unsigned int i; - - dmethods = ((debug_method *) - xmalloc ((methods_count + 1) * sizeof *dmethods)); - for (i = 0; i < methods_count; i++) - { - char *namcopy; - - namcopy = savestring (methods[i].name, methods[i].namlen); - dmethods[i] = debug_make_method (dhandle, namcopy, - methods[i].variants); - if (dmethods[i] == DEBUG_METHOD_NULL) - return FALSE; - } - dmethods[i] = DEBUG_METHOD_NULL; - free (methods); - } - - /* The struct type was created as an indirect type pointing at - it->slot. We update it->slot to automatically update all - references to this struct. */ - it->slot = debug_make_object_type (dhandle, - cxx_class != 'u', - debug_get_type_size (dhandle, - it->slot), - fields, baseclasses, dmethods, - vptrbase, ownvptr); - if (it->slot == DEBUG_TYPE_NULL) - return FALSE; - - return TRUE; -} - -/* Read C++ default argument value and reference type information. */ - -static bfd_boolean -ieee_read_cxx_defaults (struct ieee_info *info, const bfd_byte **pp, - unsigned long count) -{ - const bfd_byte *start; - const char *fnname; - unsigned long fnlen; - bfd_vma defcount; - - start = *pp; - - /* Giving the function name before the argument count is an addendum - to the spec. The function name is demangled, though, so this - record must always refer to the current function. */ - - if (info->blockstack.bsp <= info->blockstack.stack - || info->blockstack.bsp[-1].fnindx == (unsigned int) -1) - { - ieee_error (info, start, _("C++ default values not in a function")); - return FALSE; - } - - if (! ieee_require_atn65 (info, pp, &fnname, &fnlen) - || ! ieee_require_asn (info, pp, &defcount)) - return FALSE; - count -= 2; - - while (defcount-- > 0) - { - bfd_vma type, val; - const char *strval; - unsigned long strvallen; - - if (! ieee_require_asn (info, pp, &type)) - return FALSE; - --count; - - switch (type) - { - case 0: - case 4: - break; - - case 1: - case 2: - if (! ieee_require_asn (info, pp, &val)) - return FALSE; - --count; - break; - - case 3: - case 7: - if (! ieee_require_atn65 (info, pp, &strval, &strvallen)) - return FALSE; - --count; - break; - - default: - ieee_error (info, start, _("unrecognized C++ default type")); - return FALSE; - } - - /* We have no way to record the default argument values, so we - just ignore them. FIXME. */ - } - - /* Any remaining arguments are indices of parameters that are really - reference type. */ - if (count > 0) - { - void *dhandle; - debug_type *arg_slots; - - dhandle = info->dhandle; - arg_slots = info->types.types[info->blockstack.bsp[-1].fnindx].arg_slots; - while (count-- > 0) - { - bfd_vma indx; - debug_type target; - - if (! ieee_require_asn (info, pp, &indx)) - return FALSE; - /* The index is 1 based. */ - --indx; - if (arg_slots == NULL - || arg_slots[indx] == DEBUG_TYPE_NULL - || (debug_get_type_kind (dhandle, arg_slots[indx]) - != DEBUG_KIND_POINTER)) - { - ieee_error (info, start, _("reference parameter is not a pointer")); - return FALSE; - } - - target = debug_get_target_type (dhandle, arg_slots[indx]); - arg_slots[indx] = debug_make_reference_type (dhandle, target); - if (arg_slots[indx] == DEBUG_TYPE_NULL) - return FALSE; - } - } - - return TRUE; -} - -/* Read a C++ reference definition. */ - -static bfd_boolean -ieee_read_reference (struct ieee_info *info, const bfd_byte **pp) -{ - const bfd_byte *start; - bfd_vma flags; - const char *cxx_class, *name; - unsigned long classlen, namlen; - debug_type *pslot; - debug_type target; - - start = *pp; - - if (! ieee_require_asn (info, pp, &flags)) - return FALSE; - - /* Giving the class name before the member name is in an addendum to - the spec. */ - if (flags == 3) - { - if (! ieee_require_atn65 (info, pp, &cxx_class, &classlen)) - return FALSE; - } - - if (! ieee_require_atn65 (info, pp, &name, &namlen)) - return FALSE; - - pslot = NULL; - if (flags != 3) - { - int pass; - - /* We search from the last variable indices to the first in - hopes of finding local variables correctly. We search the - local variables on the first pass, and the global variables - on the second. FIXME: This probably won't work in all cases. - On the other hand, I don't know what will. */ - for (pass = 0; pass < 2; pass++) - { - struct ieee_vars *vars; - int i; - struct ieee_var *pv = NULL; - - if (pass == 0) - vars = &info->vars; - else - { - vars = info->global_vars; - if (vars == NULL) - break; - } - - for (i = (int) vars->alloc - 1; i >= 0; i--) - { - bfd_boolean found; - - pv = vars->vars + i; - - if (pv->pslot == NULL - || pv->namlen != namlen - || strncmp (pv->name, name, namlen) != 0) - continue; - - found = FALSE; - switch (flags) - { - default: - ieee_error (info, start, - _("unrecognized C++ reference type")); - return FALSE; - - case 0: - /* Global variable or function. */ - if (pv->kind == IEEE_GLOBAL - || pv->kind == IEEE_EXTERNAL - || pv->kind == IEEE_FUNCTION) - found = TRUE; - break; - - case 1: - /* Global static variable or function. */ - if (pv->kind == IEEE_STATIC - || pv->kind == IEEE_FUNCTION) - found = TRUE; - break; - - case 2: - /* Local variable. */ - if (pv->kind == IEEE_LOCAL) - found = TRUE; - break; - } - - if (found) - break; - } - - if (i >= 0) - { - pslot = pv->pslot; - break; - } - } - } - else - { - struct ieee_tag *it; - - for (it = info->tags; it != NULL; it = it->next) - { - if (it->name[0] == cxx_class[0] - && strncmp (it->name, cxx_class, classlen) == 0 - && strlen (it->name) == classlen) - { - if (it->fslots != NULL) - { - const debug_field *pf; - unsigned int findx; - - pf = debug_get_fields (info->dhandle, it->type); - if (pf == NULL) - { - ieee_error (info, start, - "C++ reference in class with no fields"); - return FALSE; - } - - for (findx = 0; *pf != DEBUG_FIELD_NULL; pf++, findx++) - { - const char *fname; - - fname = debug_get_field_name (info->dhandle, *pf); - if (fname == NULL) - return FALSE; - if (strncmp (fname, name, namlen) == 0 - && strlen (fname) == namlen) - { - pslot = it->fslots + findx; - break; - } - } - } - - break; - } - } - } - - if (pslot == NULL) - { - ieee_error (info, start, _("C++ reference not found")); - return FALSE; - } - - /* We allocated the type of the object as an indirect type pointing - to *pslot, which we can now update to be a reference type. */ - if (debug_get_type_kind (info->dhandle, *pslot) != DEBUG_KIND_POINTER) - { - ieee_error (info, start, _("C++ reference is not pointer")); - return FALSE; - } - - target = debug_get_target_type (info->dhandle, *pslot); - *pslot = debug_make_reference_type (info->dhandle, target); - if (*pslot == DEBUG_TYPE_NULL) - return FALSE; - - return TRUE; -} - -/* Require an ASN record. */ - -static bfd_boolean -ieee_require_asn (struct ieee_info *info, const bfd_byte **pp, bfd_vma *pv) -{ - const bfd_byte *start; - ieee_record_enum_type c; - bfd_vma varindx; - - start = *pp; - - c = (ieee_record_enum_type) **pp; - if (c != ieee_e2_first_byte_enum) - { - ieee_error (info, start, _("missing required ASN")); - return FALSE; - } - ++*pp; - - c = (ieee_record_enum_type) (((unsigned int) c << 8) | **pp); - if (c != ieee_asn_record_enum) - { - ieee_error (info, start, _("missing required ASN")); - return FALSE; - } - ++*pp; - - /* Just ignore the variable index. */ - if (! ieee_read_number (info, pp, &varindx)) - return FALSE; - - return ieee_read_expression (info, pp, pv); -} - -/* Require an ATN65 record. */ - -static bfd_boolean -ieee_require_atn65 (struct ieee_info *info, const bfd_byte **pp, - const char **pname, unsigned long *pnamlen) -{ - const bfd_byte *start; - ieee_record_enum_type c; - bfd_vma name_indx, type_indx, atn_code; - - start = *pp; - - c = (ieee_record_enum_type) **pp; - if (c != ieee_at_record_enum) - { - ieee_error (info, start, _("missing required ATN65")); - return FALSE; - } - ++*pp; - - c = (ieee_record_enum_type) (((unsigned int) c << 8) | **pp); - if (c != ieee_atn_record_enum) - { - ieee_error (info, start, _("missing required ATN65")); - return FALSE; - } - ++*pp; - - if (! ieee_read_number (info, pp, &name_indx) - || ! ieee_read_number (info, pp, &type_indx) - || ! ieee_read_number (info, pp, &atn_code)) - return FALSE; - - /* Just ignore name_indx. */ - - if (type_indx != 0 || atn_code != 65) - { - ieee_error (info, start, _("bad ATN65 record")); - return FALSE; - } - - return ieee_read_id (info, pp, pname, pnamlen); -} - -/* Convert a register number in IEEE debugging information into a - generic register number. */ - -static int -ieee_regno_to_genreg (bfd *abfd, int r) -{ - switch (bfd_get_arch (abfd)) - { - case bfd_arch_m68k: - /* For some reasons stabs adds 2 to the floating point register - numbers. */ - if (r >= 16) - r += 2; - break; - - default: - break; - } - - return r; -} - -/* Convert a generic register number to an IEEE specific one. */ - -static int -ieee_genreg_to_regno (bfd *abfd, int r) -{ - switch (bfd_get_arch (abfd)) - { - case bfd_arch_m68k: - /* For some reason stabs add 2 to the floating point register - numbers. */ - if (r >= 18) - r -= 2; - break; - - default: - break; - } - - return r; -} - -/* These routines build IEEE debugging information out of the generic - debugging information. */ - -/* We build the IEEE debugging information byte by byte. Rather than - waste time copying data around, we use a linked list of buffers to - hold the data. */ - -#define IEEE_BUFSIZE (490) - -struct ieee_buf -{ - /* Next buffer. */ - struct ieee_buf *next; - /* Number of data bytes in this buffer. */ - unsigned int c; - /* Bytes. */ - bfd_byte buf[IEEE_BUFSIZE]; -}; - -/* A list of buffers. */ - -struct ieee_buflist -{ - /* Head of list. */ - struct ieee_buf *head; - /* Tail--last buffer on list. */ - struct ieee_buf *tail; -}; - -/* In order to generate the BB11 blocks required by the HP emulator, - we keep track of ranges of addresses which correspond to a given - compilation unit. */ - -struct ieee_range -{ - /* Next range. */ - struct ieee_range *next; - /* Low address. */ - bfd_vma low; - /* High address. */ - bfd_vma high; -}; - -/* This structure holds information for a class on the type stack. */ - -struct ieee_type_class -{ - /* The name index in the debugging information. */ - unsigned int indx; - /* The pmisc records for the class. */ - struct ieee_buflist pmiscbuf; - /* The number of pmisc records. */ - unsigned int pmisccount; - /* The name of the class holding the virtual table, if not this - class. */ - const char *vclass; - /* Whether this class holds its own virtual table. */ - bfd_boolean ownvptr; - /* The largest virtual table offset seen so far. */ - bfd_vma voffset; - /* The current method. */ - const char *method; - /* Additional pmisc records used to record fields of reference type. */ - struct ieee_buflist refs; -}; - -/* This is how we store types for the writing routines. Most types - are simply represented by a type index. */ - -struct ieee_write_type -{ - /* Type index. */ - unsigned int indx; - /* The size of the type, if known. */ - unsigned int size; - /* The name of the type, if any. */ - const char *name; - /* If this is a function or method type, we build the type here, and - only add it to the output buffers if we need it. */ - struct ieee_buflist fndef; - /* If this is a struct, this is where the struct definition is - built. */ - struct ieee_buflist strdef; - /* If this is a class, this is where the class information is built. */ - struct ieee_type_class *classdef; - /* Whether the type is unsigned. */ - unsigned int unsignedp : 1; - /* Whether this is a reference type. */ - unsigned int referencep : 1; - /* Whether this is in the local type block. */ - unsigned int localp : 1; - /* Whether this is a duplicate struct definition which we are - ignoring. */ - unsigned int ignorep : 1; -}; - -/* This is the type stack used by the debug writing routines. FIXME: - We could generate more efficient output if we remembered when we - have output a particular type before. */ - -struct ieee_type_stack -{ - /* Next entry on stack. */ - struct ieee_type_stack *next; - /* Type information. */ - struct ieee_write_type type; -}; - -/* This is a list of associations between a name and some types. - These are used for typedefs and tags. */ - -struct ieee_name_type -{ - /* Next type for this name. */ - struct ieee_name_type *next; - /* ID number. For a typedef, this is the index of the type to which - this name is typedefed. */ - unsigned int id; - /* Type. */ - struct ieee_write_type type; - /* If this is a tag which has not yet been defined, this is the - kind. If the tag has been defined, this is DEBUG_KIND_ILLEGAL. */ - enum debug_type_kind kind; -}; - -/* We use a hash table to associate names and types. */ - -struct ieee_name_type_hash_table -{ - struct bfd_hash_table root; -}; - -struct ieee_name_type_hash_entry -{ - struct bfd_hash_entry root; - /* Information for this name. */ - struct ieee_name_type *types; -}; - -/* This is a list of enums. */ - -struct ieee_defined_enum -{ - /* Next enum. */ - struct ieee_defined_enum *next; - /* Type index. */ - unsigned int indx; - /* Whether this enum has been defined. */ - bfd_boolean defined; - /* Tag. */ - const char *tag; - /* Names. */ - const char **names; - /* Values. */ - bfd_signed_vma *vals; -}; - -/* We keep a list of modified versions of types, so that we don't - output them more than once. */ - -struct ieee_modified_type -{ - /* Pointer to this type. */ - unsigned int pointer; - /* Function with unknown arguments returning this type. */ - unsigned int function; - /* Const version of this type. */ - unsigned int const_qualified; - /* Volatile version of this type. */ - unsigned int volatile_qualified; - /* List of arrays of this type of various bounds. */ - struct ieee_modified_array_type *arrays; -}; - -/* A list of arrays bounds. */ - -struct ieee_modified_array_type -{ - /* Next array bounds. */ - struct ieee_modified_array_type *next; - /* Type index with these bounds. */ - unsigned int indx; - /* Low bound. */ - bfd_signed_vma low; - /* High bound. */ - bfd_signed_vma high; -}; - -/* This is a list of pending function parameter information. We don't - output them until we see the first block. */ - -struct ieee_pending_parm -{ - /* Next pending parameter. */ - struct ieee_pending_parm *next; - /* Name. */ - const char *name; - /* Type index. */ - unsigned int type; - /* Whether the type is a reference. */ - bfd_boolean referencep; - /* Kind. */ - enum debug_parm_kind kind; - /* Value. */ - bfd_vma val; -}; - -/* This is the handle passed down by debug_write. */ - -struct ieee_handle -{ - /* BFD we are writing to. */ - bfd *abfd; - /* Whether we got an error in a subroutine called via traverse or - map_over_sections. */ - bfd_boolean error; - /* Current data buffer list. */ - struct ieee_buflist *current; - /* Current data buffer. */ - struct ieee_buf *curbuf; - /* Filename of current compilation unit. */ - const char *filename; - /* Module name of current compilation unit. */ - const char *modname; - /* List of buffer for global types. */ - struct ieee_buflist global_types; - /* List of finished data buffers. */ - struct ieee_buflist data; - /* List of buffers for typedefs in the current compilation unit. */ - struct ieee_buflist types; - /* List of buffers for variables and functions in the current - compilation unit. */ - struct ieee_buflist vars; - /* List of buffers for C++ class definitions in the current - compilation unit. */ - struct ieee_buflist cxx; - /* List of buffers for line numbers in the current compilation unit. */ - struct ieee_buflist linenos; - /* Ranges for the current compilation unit. */ - struct ieee_range *ranges; - /* Ranges for all debugging information. */ - struct ieee_range *global_ranges; - /* Nested pending ranges. */ - struct ieee_range *pending_ranges; - /* Type stack. */ - struct ieee_type_stack *type_stack; - /* Next unallocated type index. */ - unsigned int type_indx; - /* Next unallocated name index. */ - unsigned int name_indx; - /* Typedefs. */ - struct ieee_name_type_hash_table typedefs; - /* Tags. */ - struct ieee_name_type_hash_table tags; - /* Enums. */ - struct ieee_defined_enum *enums; - /* Modified versions of types. */ - struct ieee_modified_type *modified; - /* Number of entries allocated in modified. */ - unsigned int modified_alloc; - /* 4 byte complex type. */ - unsigned int complex_float_index; - /* 8 byte complex type. */ - unsigned int complex_double_index; - /* The depth of block nesting. This is 0 outside a function, and 1 - just after start_function is called. */ - unsigned int block_depth; - /* The name of the current function. */ - const char *fnname; - /* List of buffers for the type of the function we are currently - writing out. */ - struct ieee_buflist fntype; - /* List of buffers for the parameters of the function we are - currently writing out. */ - struct ieee_buflist fnargs; - /* Number of arguments written to fnargs. */ - unsigned int fnargcount; - /* Pending function parameters. */ - struct ieee_pending_parm *pending_parms; - /* Current line number filename. */ - const char *lineno_filename; - /* Line number name index. */ - unsigned int lineno_name_indx; - /* Filename of pending line number. */ - const char *pending_lineno_filename; - /* Pending line number. */ - unsigned long pending_lineno; - /* Address of pending line number. */ - bfd_vma pending_lineno_addr; - /* Highest address seen at end of procedure. */ - bfd_vma highaddr; -}; - -static bfd_boolean ieee_init_buffer - (struct ieee_handle *, struct ieee_buflist *); -static bfd_boolean ieee_change_buffer - (struct ieee_handle *, struct ieee_buflist *); -static bfd_boolean ieee_append_buffer - (struct ieee_handle *, struct ieee_buflist *, struct ieee_buflist *); -static bfd_boolean ieee_real_write_byte (struct ieee_handle *, int); -static bfd_boolean ieee_write_2bytes (struct ieee_handle *, int); -static bfd_boolean ieee_write_number (struct ieee_handle *, bfd_vma); -static bfd_boolean ieee_write_id (struct ieee_handle *, const char *); -static bfd_boolean ieee_write_asn - (struct ieee_handle *, unsigned int, bfd_vma); -static bfd_boolean ieee_write_atn65 - (struct ieee_handle *, unsigned int, const char *); -static bfd_boolean ieee_push_type - (struct ieee_handle *, unsigned int, unsigned int, bfd_boolean, - bfd_boolean); -static unsigned int ieee_pop_type (struct ieee_handle *); -static void ieee_pop_unused_type (struct ieee_handle *); -static unsigned int ieee_pop_type_used (struct ieee_handle *, bfd_boolean); -static bfd_boolean ieee_add_range - (struct ieee_handle *, bfd_boolean, bfd_vma, bfd_vma); -static bfd_boolean ieee_start_range (struct ieee_handle *, bfd_vma); -static bfd_boolean ieee_end_range (struct ieee_handle *, bfd_vma); -static bfd_boolean ieee_define_type - (struct ieee_handle *, unsigned int, bfd_boolean, bfd_boolean); -static bfd_boolean ieee_define_named_type - (struct ieee_handle *, const char *, unsigned int, unsigned int, - bfd_boolean, bfd_boolean, struct ieee_buflist *); -static struct ieee_modified_type *ieee_get_modified_info - (struct ieee_handle *, unsigned int); -static struct bfd_hash_entry *ieee_name_type_newfunc - (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); -static bfd_boolean ieee_write_undefined_tag - (struct ieee_name_type_hash_entry *, void *); -static bfd_boolean ieee_finish_compilation_unit (struct ieee_handle *); -static void ieee_add_bb11_blocks (bfd *, asection *, void *); -static bfd_boolean ieee_add_bb11 - (struct ieee_handle *, asection *, bfd_vma, bfd_vma); -static bfd_boolean ieee_output_pending_parms (struct ieee_handle *); -static unsigned int ieee_vis_to_flags (enum debug_visibility); -static bfd_boolean ieee_class_method_var - (struct ieee_handle *, const char *, enum debug_visibility, bfd_boolean, - bfd_boolean, bfd_boolean, bfd_vma, bfd_boolean); - -static bfd_boolean ieee_start_compilation_unit (void *, const char *); -static bfd_boolean ieee_start_source (void *, const char *); -static bfd_boolean ieee_empty_type (void *); -static bfd_boolean ieee_void_type (void *); -static bfd_boolean ieee_int_type (void *, unsigned int, bfd_boolean); -static bfd_boolean ieee_float_type (void *, unsigned int); -static bfd_boolean ieee_complex_type (void *, unsigned int); -static bfd_boolean ieee_bool_type (void *, unsigned int); -static bfd_boolean ieee_enum_type - (void *, const char *, const char **, bfd_signed_vma *); -static bfd_boolean ieee_pointer_type (void *); -static bfd_boolean ieee_function_type (void *, int, bfd_boolean); -static bfd_boolean ieee_reference_type (void *); -static bfd_boolean ieee_range_type (void *, bfd_signed_vma, bfd_signed_vma); -static bfd_boolean ieee_array_type - (void *, bfd_signed_vma, bfd_signed_vma, bfd_boolean); -static bfd_boolean ieee_set_type (void *, bfd_boolean); -static bfd_boolean ieee_offset_type (void *); -static bfd_boolean ieee_method_type (void *, bfd_boolean, int, bfd_boolean); -static bfd_boolean ieee_const_type (void *); -static bfd_boolean ieee_volatile_type (void *); -static bfd_boolean ieee_start_struct_type - (void *, const char *, unsigned int, bfd_boolean, unsigned int); -static bfd_boolean ieee_struct_field - (void *, const char *, bfd_vma, bfd_vma, enum debug_visibility); -static bfd_boolean ieee_end_struct_type (void *); -static bfd_boolean ieee_start_class_type - (void *, const char *, unsigned int, bfd_boolean, unsigned int, bfd_boolean, - bfd_boolean); -static bfd_boolean ieee_class_static_member - (void *, const char *, const char *, enum debug_visibility); -static bfd_boolean ieee_class_baseclass - (void *, bfd_vma, bfd_boolean, enum debug_visibility); -static bfd_boolean ieee_class_start_method (void *, const char *); -static bfd_boolean ieee_class_method_variant - (void *, const char *, enum debug_visibility, bfd_boolean, bfd_boolean, - bfd_vma, bfd_boolean); -static bfd_boolean ieee_class_static_method_variant - (void *, const char *, enum debug_visibility, bfd_boolean, bfd_boolean); -static bfd_boolean ieee_class_end_method (void *); -static bfd_boolean ieee_end_class_type (void *); -static bfd_boolean ieee_typedef_type (void *, const char *); -static bfd_boolean ieee_tag_type - (void *, const char *, unsigned int, enum debug_type_kind); -static bfd_boolean ieee_typdef (void *, const char *); -static bfd_boolean ieee_tag (void *, const char *); -static bfd_boolean ieee_int_constant (void *, const char *, bfd_vma); -static bfd_boolean ieee_float_constant (void *, const char *, double); -static bfd_boolean ieee_typed_constant (void *, const char *, bfd_vma); -static bfd_boolean ieee_variable - (void *, const char *, enum debug_var_kind, bfd_vma); -static bfd_boolean ieee_start_function (void *, const char *, bfd_boolean); -static bfd_boolean ieee_function_parameter - (void *, const char *, enum debug_parm_kind, bfd_vma); -static bfd_boolean ieee_start_block (void *, bfd_vma); -static bfd_boolean ieee_end_block (void *, bfd_vma); -static bfd_boolean ieee_end_function (void *); -static bfd_boolean ieee_lineno (void *, const char *, unsigned long, bfd_vma); - -static const struct debug_write_fns ieee_fns = -{ - ieee_start_compilation_unit, - ieee_start_source, - ieee_empty_type, - ieee_void_type, - ieee_int_type, - ieee_float_type, - ieee_complex_type, - ieee_bool_type, - ieee_enum_type, - ieee_pointer_type, - ieee_function_type, - ieee_reference_type, - ieee_range_type, - ieee_array_type, - ieee_set_type, - ieee_offset_type, - ieee_method_type, - ieee_const_type, - ieee_volatile_type, - ieee_start_struct_type, - ieee_struct_field, - ieee_end_struct_type, - ieee_start_class_type, - ieee_class_static_member, - ieee_class_baseclass, - ieee_class_start_method, - ieee_class_method_variant, - ieee_class_static_method_variant, - ieee_class_end_method, - ieee_end_class_type, - ieee_typedef_type, - ieee_tag_type, - ieee_typdef, - ieee_tag, - ieee_int_constant, - ieee_float_constant, - ieee_typed_constant, - ieee_variable, - ieee_start_function, - ieee_function_parameter, - ieee_start_block, - ieee_end_block, - ieee_end_function, - ieee_lineno -}; - -/* Initialize a buffer to be empty. */ - -static bfd_boolean -ieee_init_buffer (struct ieee_handle *info ATTRIBUTE_UNUSED, - struct ieee_buflist *buflist) -{ - buflist->head = NULL; - buflist->tail = NULL; - return TRUE; -} - -/* See whether a buffer list has any data. */ - -#define ieee_buffer_emptyp(buflist) ((buflist)->head == NULL) - -/* Change the current buffer to a specified buffer chain. */ - -static bfd_boolean -ieee_change_buffer (struct ieee_handle *info, struct ieee_buflist *buflist) -{ - if (buflist->head == NULL) - { - struct ieee_buf *buf; - - buf = (struct ieee_buf *) xmalloc (sizeof *buf); - buf->next = NULL; - buf->c = 0; - buflist->head = buf; - buflist->tail = buf; - } - - info->current = buflist; - info->curbuf = buflist->tail; - - return TRUE; -} - -/* Append a buffer chain. */ - -static bfd_boolean -ieee_append_buffer (struct ieee_handle *info ATTRIBUTE_UNUSED, - struct ieee_buflist *mainbuf, - struct ieee_buflist *newbuf) -{ - if (newbuf->head != NULL) - { - if (mainbuf->head == NULL) - mainbuf->head = newbuf->head; - else - mainbuf->tail->next = newbuf->head; - mainbuf->tail = newbuf->tail; - } - return TRUE; -} - -/* Write a byte into the buffer. We use a macro for speed and a - function for the complex cases. */ - -#define ieee_write_byte(info, b) \ - ((info)->curbuf->c < IEEE_BUFSIZE \ - ? ((info)->curbuf->buf[(info)->curbuf->c++] = (b), TRUE) \ - : ieee_real_write_byte ((info), (b))) - -static bfd_boolean -ieee_real_write_byte (struct ieee_handle *info, int b) -{ - if (info->curbuf->c >= IEEE_BUFSIZE) - { - struct ieee_buf *n; - - n = (struct ieee_buf *) xmalloc (sizeof *n); - n->next = NULL; - n->c = 0; - if (info->current->head == NULL) - info->current->head = n; - else - info->current->tail->next = n; - info->current->tail = n; - info->curbuf = n; - } - - info->curbuf->buf[info->curbuf->c] = b; - ++info->curbuf->c; - - return TRUE; -} - -/* Write out two bytes. */ - -static bfd_boolean -ieee_write_2bytes (struct ieee_handle *info, int i) -{ - return (ieee_write_byte (info, i >> 8) - && ieee_write_byte (info, i & 0xff)); -} - -/* Write out an integer. */ - -static bfd_boolean -ieee_write_number (struct ieee_handle *info, bfd_vma v) -{ - bfd_vma t; - bfd_byte ab[20]; - bfd_byte *p; - unsigned int c; - - if (v <= (bfd_vma) ieee_number_end_enum) - return ieee_write_byte (info, (int) v); - - t = v; - p = ab + sizeof ab; - while (t != 0) - { - *--p = t & 0xff; - t >>= 8; - } - c = (ab + 20) - p; - - if (c > (unsigned int) (ieee_number_repeat_end_enum - - ieee_number_repeat_start_enum)) - { - fprintf (stderr, _("IEEE numeric overflow: 0x")); - fprintf_vma (stderr, v); - fprintf (stderr, "\n"); - return FALSE; - } - - if (! ieee_write_byte (info, (int) ieee_number_repeat_start_enum + c)) - return FALSE; - for (; c > 0; --c, ++p) - { - if (! ieee_write_byte (info, *p)) - return FALSE; - } - - return TRUE; -} - -/* Write out a string. */ - -static bfd_boolean -ieee_write_id (struct ieee_handle *info, const char *s) -{ - unsigned int len; - - len = strlen (s); - if (len <= 0x7f) - { - if (! ieee_write_byte (info, len)) - return FALSE; - } - else if (len <= 0xff) - { - if (! ieee_write_byte (info, (int) ieee_extension_length_1_enum) - || ! ieee_write_byte (info, len)) - return FALSE; - } - else if (len <= 0xffff) - { - if (! ieee_write_byte (info, (int) ieee_extension_length_2_enum) - || ! ieee_write_2bytes (info, len)) - return FALSE; - } - else - { - fprintf (stderr, _("IEEE string length overflow: %u\n"), len); - return FALSE; - } - - for (; *s != '\0'; s++) - if (! ieee_write_byte (info, *s)) - return FALSE; - - return TRUE; -} - -/* Write out an ASN record. */ - -static bfd_boolean -ieee_write_asn (struct ieee_handle *info, unsigned int indx, bfd_vma val) -{ - return (ieee_write_2bytes (info, (int) ieee_asn_record_enum) - && ieee_write_number (info, indx) - && ieee_write_number (info, val)); -} - -/* Write out an ATN65 record. */ - -static bfd_boolean -ieee_write_atn65 (struct ieee_handle *info, unsigned int indx, const char *s) -{ - return (ieee_write_2bytes (info, (int) ieee_atn_record_enum) - && ieee_write_number (info, indx) - && ieee_write_number (info, 0) - && ieee_write_number (info, 65) - && ieee_write_id (info, s)); -} - -/* Push a type index onto the type stack. */ - -static bfd_boolean -ieee_push_type (struct ieee_handle *info, unsigned int indx, - unsigned int size, bfd_boolean unsignedp, bfd_boolean localp) -{ - struct ieee_type_stack *ts; - - ts = (struct ieee_type_stack *) xmalloc (sizeof *ts); - memset (ts, 0, sizeof *ts); - - ts->type.indx = indx; - ts->type.size = size; - ts->type.unsignedp = unsignedp; - ts->type.localp = localp; - - ts->next = info->type_stack; - info->type_stack = ts; - - return TRUE; -} - -/* Pop a type index off the type stack. */ - -static unsigned int -ieee_pop_type (struct ieee_handle *info) -{ - return ieee_pop_type_used (info, TRUE); -} - -/* Pop an unused type index off the type stack. */ - -static void -ieee_pop_unused_type (struct ieee_handle *info) -{ - (void) ieee_pop_type_used (info, FALSE); -} - -/* Pop a used or unused type index off the type stack. */ - -static unsigned int -ieee_pop_type_used (struct ieee_handle *info, bfd_boolean used) -{ - struct ieee_type_stack *ts; - unsigned int ret; - - ts = info->type_stack; - assert (ts != NULL); - - /* If this is a function type, and we need it, we need to append the - actual definition to the typedef block now. */ - if (used && ! ieee_buffer_emptyp (&ts->type.fndef)) - { - struct ieee_buflist *buflist; - - if (ts->type.localp) - { - /* Make sure we have started the types block. */ - if (ieee_buffer_emptyp (&info->types)) - { - if (! ieee_change_buffer (info, &info->types) - || ! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 1) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, info->modname)) - return FALSE; - } - buflist = &info->types; - } - else - { - /* Make sure we started the global type block. */ - if (ieee_buffer_emptyp (&info->global_types)) - { - if (! ieee_change_buffer (info, &info->global_types) - || ! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 2) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, "")) - return FALSE; - } - buflist = &info->global_types; - } - - if (! ieee_append_buffer (info, buflist, &ts->type.fndef)) - return FALSE; - } - - ret = ts->type.indx; - info->type_stack = ts->next; - free (ts); - return ret; -} - -/* Add a range of bytes included in the current compilation unit. */ - -static bfd_boolean -ieee_add_range (struct ieee_handle *info, bfd_boolean global, bfd_vma low, - bfd_vma high) -{ - struct ieee_range **plist, *r, **pr; - - if (low == (bfd_vma) -1 || high == (bfd_vma) -1 || low == high) - return TRUE; - - if (global) - plist = &info->global_ranges; - else - plist = &info->ranges; - - for (r = *plist; r != NULL; r = r->next) - { - if (high >= r->low && low <= r->high) - { - /* The new range overlaps r. */ - if (low < r->low) - r->low = low; - if (high > r->high) - r->high = high; - pr = &r->next; - while (*pr != NULL && (*pr)->low <= r->high) - { - struct ieee_range *n; - - if ((*pr)->high > r->high) - r->high = (*pr)->high; - n = (*pr)->next; - free (*pr); - *pr = n; - } - return TRUE; - } - } - - r = (struct ieee_range *) xmalloc (sizeof *r); - memset (r, 0, sizeof *r); - - r->low = low; - r->high = high; - - /* Store the ranges sorted by address. */ - for (pr = plist; *pr != NULL; pr = &(*pr)->next) - if ((*pr)->low > high) - break; - r->next = *pr; - *pr = r; - - return TRUE; -} - -/* Start a new range for which we only have the low address. */ - -static bfd_boolean -ieee_start_range (struct ieee_handle *info, bfd_vma low) -{ - struct ieee_range *r; - - r = (struct ieee_range *) xmalloc (sizeof *r); - memset (r, 0, sizeof *r); - r->low = low; - r->next = info->pending_ranges; - info->pending_ranges = r; - return TRUE; -} - -/* Finish a range started by ieee_start_range. */ - -static bfd_boolean -ieee_end_range (struct ieee_handle *info, bfd_vma high) -{ - struct ieee_range *r; - bfd_vma low; - - assert (info->pending_ranges != NULL); - r = info->pending_ranges; - low = r->low; - info->pending_ranges = r->next; - free (r); - return ieee_add_range (info, FALSE, low, high); -} - -/* Start defining a type. */ - -static bfd_boolean -ieee_define_type (struct ieee_handle *info, unsigned int size, - bfd_boolean unsignedp, bfd_boolean localp) -{ - return ieee_define_named_type (info, (const char *) NULL, - (unsigned int) -1, size, unsignedp, - localp, (struct ieee_buflist *) NULL); -} - -/* Start defining a named type. */ - -static bfd_boolean -ieee_define_named_type (struct ieee_handle *info, const char *name, - unsigned int indx, unsigned int size, - bfd_boolean unsignedp, bfd_boolean localp, - struct ieee_buflist *buflist) -{ - unsigned int type_indx; - unsigned int name_indx; - - if (indx != (unsigned int) -1) - type_indx = indx; - else - { - type_indx = info->type_indx; - ++info->type_indx; - } - - name_indx = info->name_indx; - ++info->name_indx; - - if (name == NULL) - name = ""; - - /* If we were given a buffer, use it; otherwise, use either the - local or the global type information, and make sure that the type - block is started. */ - if (buflist != NULL) - { - if (! ieee_change_buffer (info, buflist)) - return FALSE; - } - else if (localp) - { - if (! ieee_buffer_emptyp (&info->types)) - { - if (! ieee_change_buffer (info, &info->types)) - return FALSE; - } - else - { - if (! ieee_change_buffer (info, &info->types) - || ! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 1) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, info->modname)) - return FALSE; - } - } - else - { - if (! ieee_buffer_emptyp (&info->global_types)) - { - if (! ieee_change_buffer (info, &info->global_types)) - return FALSE; - } - else - { - if (! ieee_change_buffer (info, &info->global_types) - || ! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 2) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, "")) - return FALSE; - } - } - - /* Push the new type on the type stack, write out an NN record, and - write out the start of a TY record. The caller will then finish - the TY record. */ - if (! ieee_push_type (info, type_indx, size, unsignedp, localp)) - return FALSE; - - return (ieee_write_byte (info, (int) ieee_nn_record) - && ieee_write_number (info, name_indx) - && ieee_write_id (info, name) - && ieee_write_byte (info, (int) ieee_ty_record_enum) - && ieee_write_number (info, type_indx) - && ieee_write_byte (info, 0xce) - && ieee_write_number (info, name_indx)); -} - -/* Get an entry to the list of modified versions of a type. */ - -static struct ieee_modified_type * -ieee_get_modified_info (struct ieee_handle *info, unsigned int indx) -{ - if (indx >= info->modified_alloc) - { - unsigned int nalloc; - - nalloc = info->modified_alloc; - if (nalloc == 0) - nalloc = 16; - while (indx >= nalloc) - nalloc *= 2; - info->modified = ((struct ieee_modified_type *) - xrealloc (info->modified, - nalloc * sizeof *info->modified)); - memset (info->modified + info->modified_alloc, 0, - (nalloc - info->modified_alloc) * sizeof *info->modified); - info->modified_alloc = nalloc; - } - - return info->modified + indx; -} - -/* Routines for the hash table mapping names to types. */ - -/* Initialize an entry in the hash table. */ - -static struct bfd_hash_entry * -ieee_name_type_newfunc (struct bfd_hash_entry *entry, - struct bfd_hash_table *table, const char *string) -{ - struct ieee_name_type_hash_entry *ret = - (struct ieee_name_type_hash_entry *) entry; - - /* Allocate the structure if it has not already been allocated by a - subclass. */ - if (ret == NULL) - ret = ((struct ieee_name_type_hash_entry *) - bfd_hash_allocate (table, sizeof *ret)); - if (ret == NULL) - return NULL; - - /* Call the allocation method of the superclass. */ - ret = ((struct ieee_name_type_hash_entry *) - bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string)); - if (ret) - { - /* Set local fields. */ - ret->types = NULL; - } - - return (struct bfd_hash_entry *) ret; -} - -/* Look up an entry in the hash table. */ - -#define ieee_name_type_hash_lookup(table, string, create, copy) \ - ((struct ieee_name_type_hash_entry *) \ - bfd_hash_lookup (&(table)->root, (string), (create), (copy))) - -/* Traverse the hash table. */ - -#define ieee_name_type_hash_traverse(table, func, info) \ - (bfd_hash_traverse \ - (&(table)->root, \ - (bfd_boolean (*) (struct bfd_hash_entry *, void *)) (func), \ - (info))) - -/* The general routine to write out IEEE debugging information. */ - -bfd_boolean -write_ieee_debugging_info (bfd *abfd, void *dhandle) -{ - struct ieee_handle info; - asection *s; - const char *err; - struct ieee_buf *b; - - memset (&info, 0, sizeof info); - info.abfd = abfd; - info.type_indx = 256; - info.name_indx = 32; - - if (!bfd_hash_table_init (&info.typedefs.root, ieee_name_type_newfunc, - sizeof (struct ieee_name_type_hash_entry)) - || !bfd_hash_table_init (&info.tags.root, ieee_name_type_newfunc, - sizeof (struct ieee_name_type_hash_entry))) - return FALSE; - - if (! ieee_init_buffer (&info, &info.global_types) - || ! ieee_init_buffer (&info, &info.data) - || ! ieee_init_buffer (&info, &info.types) - || ! ieee_init_buffer (&info, &info.vars) - || ! ieee_init_buffer (&info, &info.cxx) - || ! ieee_init_buffer (&info, &info.linenos) - || ! ieee_init_buffer (&info, &info.fntype) - || ! ieee_init_buffer (&info, &info.fnargs)) - return FALSE; - - if (! debug_write (dhandle, &ieee_fns, (void *) &info)) - return FALSE; - - if (info.filename != NULL) - { - if (! ieee_finish_compilation_unit (&info)) - return FALSE; - } - - /* Put any undefined tags in the global typedef information. */ - info.error = FALSE; - ieee_name_type_hash_traverse (&info.tags, - ieee_write_undefined_tag, - (void *) &info); - if (info.error) - return FALSE; - - /* Prepend the global typedef information to the other data. */ - if (! ieee_buffer_emptyp (&info.global_types)) - { - /* The HP debugger seems to have a bug in which it ignores the - last entry in the global types, so we add a dummy entry. */ - if (! ieee_change_buffer (&info, &info.global_types) - || ! ieee_write_byte (&info, (int) ieee_nn_record) - || ! ieee_write_number (&info, info.name_indx) - || ! ieee_write_id (&info, "") - || ! ieee_write_byte (&info, (int) ieee_ty_record_enum) - || ! ieee_write_number (&info, info.type_indx) - || ! ieee_write_byte (&info, 0xce) - || ! ieee_write_number (&info, info.name_indx) - || ! ieee_write_number (&info, 'P') - || ! ieee_write_number (&info, (int) builtin_void + 32) - || ! ieee_write_byte (&info, (int) ieee_be_record_enum)) - return FALSE; - - if (! ieee_append_buffer (&info, &info.global_types, &info.data)) - return FALSE; - info.data = info.global_types; - } - - /* Make sure that we have declare BB11 blocks for each range in the - file. They are added to info->vars. */ - info.error = FALSE; - if (! ieee_init_buffer (&info, &info.vars)) - return FALSE; - bfd_map_over_sections (abfd, ieee_add_bb11_blocks, (void *) &info); - if (info.error) - return FALSE; - if (! ieee_buffer_emptyp (&info.vars)) - { - if (! ieee_change_buffer (&info, &info.vars) - || ! ieee_write_byte (&info, (int) ieee_be_record_enum)) - return FALSE; - - if (! ieee_append_buffer (&info, &info.data, &info.vars)) - return FALSE; - } - - /* Now all the data is in info.data. Write it out to the BFD. We - normally would need to worry about whether all the other sections - are set up yet, but the IEEE backend will handle this particular - case correctly regardless. */ - if (ieee_buffer_emptyp (&info.data)) - { - /* There is no debugging information. */ - return TRUE; - } - err = NULL; - s = bfd_make_section_with_flags (abfd, ".debug", - SEC_DEBUGGING | SEC_HAS_CONTENTS); - if (s == NULL) - err = "bfd_make_section"; - if (err == NULL) - { - bfd_size_type size; - - size = 0; - for (b = info.data.head; b != NULL; b = b->next) - size += b->c; - if (! bfd_set_section_size (abfd, s, size)) - err = "bfd_set_section_size"; - } - if (err == NULL) - { - file_ptr offset; - - offset = 0; - for (b = info.data.head; b != NULL; b = b->next) - { - if (! bfd_set_section_contents (abfd, s, b->buf, offset, b->c)) - { - err = "bfd_set_section_contents"; - break; - } - offset += b->c; - } - } - - if (err != NULL) - { - fprintf (stderr, "%s: %s: %s\n", bfd_get_filename (abfd), err, - bfd_errmsg (bfd_get_error ())); - return FALSE; - } - - bfd_hash_table_free (&info.typedefs.root); - bfd_hash_table_free (&info.tags.root); - - return TRUE; -} - -/* Write out information for an undefined tag. This is called via - ieee_name_type_hash_traverse. */ - -static bfd_boolean -ieee_write_undefined_tag (struct ieee_name_type_hash_entry *h, void *p) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - struct ieee_name_type *nt; - - for (nt = h->types; nt != NULL; nt = nt->next) - { - unsigned int name_indx; - char code; - - if (nt->kind == DEBUG_KIND_ILLEGAL) - continue; - - if (ieee_buffer_emptyp (&info->global_types)) - { - if (! ieee_change_buffer (info, &info->global_types) - || ! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 2) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, "")) - { - info->error = TRUE; - return FALSE; - } - } - else - { - if (! ieee_change_buffer (info, &info->global_types)) - { - info->error = TRUE; - return FALSE; - } - } - - name_indx = info->name_indx; - ++info->name_indx; - if (! ieee_write_byte (info, (int) ieee_nn_record) - || ! ieee_write_number (info, name_indx) - || ! ieee_write_id (info, nt->type.name) - || ! ieee_write_byte (info, (int) ieee_ty_record_enum) - || ! ieee_write_number (info, nt->type.indx) - || ! ieee_write_byte (info, 0xce) - || ! ieee_write_number (info, name_indx)) - { - info->error = TRUE; - return FALSE; - } - - switch (nt->kind) - { - default: - abort (); - info->error = TRUE; - return FALSE; - case DEBUG_KIND_STRUCT: - case DEBUG_KIND_CLASS: - code = 'S'; - break; - case DEBUG_KIND_UNION: - case DEBUG_KIND_UNION_CLASS: - code = 'U'; - break; - case DEBUG_KIND_ENUM: - code = 'E'; - break; - } - if (! ieee_write_number (info, code) - || ! ieee_write_number (info, 0)) - { - info->error = TRUE; - return FALSE; - } - } - - return TRUE; -} - -/* Start writing out information for a compilation unit. */ - -static bfd_boolean -ieee_start_compilation_unit (void *p, const char *filename) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - const char *modname; -#ifdef HAVE_DOS_BASED_FILE_SYSTEM - const char *backslash; -#endif - char *c, *s; - - if (info->filename != NULL) - { - if (! ieee_finish_compilation_unit (info)) - return FALSE; - } - - info->filename = filename; - modname = strrchr (filename, '/'); -#ifdef HAVE_DOS_BASED_FILE_SYSTEM - /* We could have a mixed forward/back slash case. */ - backslash = strrchr (filename, '\\'); - if (modname == NULL || (backslash != NULL && backslash > modname)) - modname = backslash; -#endif - - if (modname != NULL) - ++modname; -#ifdef HAVE_DOS_BASED_FILE_SYSTEM - else if (filename[0] && filename[1] == ':') - modname = filename + 2; -#endif - else - modname = filename; - - c = xstrdup (modname); - s = strrchr (c, '.'); - if (s != NULL) - *s = '\0'; - info->modname = c; - - if (! ieee_init_buffer (info, &info->types) - || ! ieee_init_buffer (info, &info->vars) - || ! ieee_init_buffer (info, &info->cxx) - || ! ieee_init_buffer (info, &info->linenos)) - return FALSE; - info->ranges = NULL; - - /* Always include a BB1 and a BB3 block. That is what the output of - the MRI linker seems to look like. */ - if (! ieee_change_buffer (info, &info->types) - || ! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 1) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, info->modname)) - return FALSE; - - ++info->name_indx; - if (! ieee_change_buffer (info, &info->vars) - || ! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 3) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, info->modname)) - return FALSE; - - return TRUE; -} - -/* Finish up a compilation unit. */ - -static bfd_boolean -ieee_finish_compilation_unit (struct ieee_handle *info) -{ - struct ieee_range *r; - - if (! ieee_buffer_emptyp (&info->types)) - { - if (! ieee_change_buffer (info, &info->types) - || ! ieee_write_byte (info, (int) ieee_be_record_enum)) - return FALSE; - } - - if (! ieee_buffer_emptyp (&info->cxx)) - { - /* Append any C++ information to the global function and - variable information. */ - assert (! ieee_buffer_emptyp (&info->vars)); - if (! ieee_change_buffer (info, &info->vars)) - return FALSE; - - /* We put the pmisc records in a dummy procedure, just as the - MRI compiler does. */ - if (! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 6) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, "__XRYCPP") - || ! ieee_write_number (info, 0) - || ! ieee_write_number (info, 0) - || ! ieee_write_number (info, info->highaddr - 1) - || ! ieee_append_buffer (info, &info->vars, &info->cxx) - || ! ieee_change_buffer (info, &info->vars) - || ! ieee_write_byte (info, (int) ieee_be_record_enum) - || ! ieee_write_number (info, info->highaddr - 1)) - return FALSE; - } - - if (! ieee_buffer_emptyp (&info->vars)) - { - if (! ieee_change_buffer (info, &info->vars) - || ! ieee_write_byte (info, (int) ieee_be_record_enum)) - return FALSE; - } - - if (info->pending_lineno_filename != NULL) - { - /* Force out the pending line number. */ - if (! ieee_lineno ((void *) info, (const char *) NULL, 0, (bfd_vma) -1)) - return FALSE; - } - if (! ieee_buffer_emptyp (&info->linenos)) - { - if (! ieee_change_buffer (info, &info->linenos) - || ! ieee_write_byte (info, (int) ieee_be_record_enum)) - return FALSE; - if (filename_cmp (info->filename, info->lineno_filename) != 0) - { - /* We were not in the main file. We just closed the - included line number block, and now we must close the - main line number block. */ - if (! ieee_write_byte (info, (int) ieee_be_record_enum)) - return FALSE; - } - } - - if (! ieee_append_buffer (info, &info->data, &info->types) - || ! ieee_append_buffer (info, &info->data, &info->vars) - || ! ieee_append_buffer (info, &info->data, &info->linenos)) - return FALSE; - - /* Build BB10/BB11 blocks based on the ranges we recorded. */ - if (! ieee_change_buffer (info, &info->data)) - return FALSE; - - if (! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 10) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, info->modname) - || ! ieee_write_id (info, "") - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, "GNU objcopy")) - return FALSE; - - for (r = info->ranges; r != NULL; r = r->next) - { - bfd_vma low, high; - asection *s; - int kind; - - low = r->low; - high = r->high; - - /* Find the section corresponding to this range. */ - for (s = info->abfd->sections; s != NULL; s = s->next) - { - if (bfd_get_section_vma (info->abfd, s) <= low - && high <= (bfd_get_section_vma (info->abfd, s) - + bfd_section_size (info->abfd, s))) - break; - } - - if (s == NULL) - { - /* Just ignore this range. */ - continue; - } - - /* Coalesce ranges if it seems reasonable. */ - while (r->next != NULL - && high + 0x1000 >= r->next->low - && (r->next->high - <= (bfd_get_section_vma (info->abfd, s) - + bfd_section_size (info->abfd, s)))) - { - r = r->next; - high = r->high; - } - - if ((s->flags & SEC_CODE) != 0) - kind = 1; - else if ((s->flags & SEC_READONLY) != 0) - kind = 3; - else - kind = 2; - - if (! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 11) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, "") - || ! ieee_write_number (info, kind) - || ! ieee_write_number (info, s->index + IEEE_SECTION_NUMBER_BASE) - || ! ieee_write_number (info, low) - || ! ieee_write_byte (info, (int) ieee_be_record_enum) - || ! ieee_write_number (info, high - low)) - return FALSE; - - /* Add this range to the list of global ranges. */ - if (! ieee_add_range (info, TRUE, low, high)) - return FALSE; - } - - if (! ieee_write_byte (info, (int) ieee_be_record_enum)) - return FALSE; - - return TRUE; -} - -/* Add BB11 blocks describing each range that we have not already - described. */ - -static void -ieee_add_bb11_blocks (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *data) -{ - struct ieee_handle *info = (struct ieee_handle *) data; - bfd_vma low, high; - struct ieee_range *r; - - low = bfd_get_section_vma (abfd, sec); - high = low + bfd_section_size (abfd, sec); - - /* Find the first range at or after this section. The ranges are - sorted by address. */ - for (r = info->global_ranges; r != NULL; r = r->next) - if (r->high > low) - break; - - while (low < high) - { - if (r == NULL || r->low >= high) - { - if (! ieee_add_bb11 (info, sec, low, high)) - info->error = TRUE; - return; - } - - if (low < r->low - && r->low - low > 0x100) - { - if (! ieee_add_bb11 (info, sec, low, r->low)) - { - info->error = TRUE; - return; - } - } - low = r->high; - - r = r->next; - } -} - -/* Add a single BB11 block for a range. We add it to info->vars. */ - -static bfd_boolean -ieee_add_bb11 (struct ieee_handle *info, asection *sec, bfd_vma low, - bfd_vma high) -{ - int kind; - - if (! ieee_buffer_emptyp (&info->vars)) - { - if (! ieee_change_buffer (info, &info->vars)) - return FALSE; - } - else - { - const char *filename, *modname; -#ifdef HAVE_DOS_BASED_FILE_SYSTEM - const char *backslash; -#endif - char *c, *s; - - /* Start the enclosing BB10 block. */ - filename = bfd_get_filename (info->abfd); - modname = strrchr (filename, '/'); -#ifdef HAVE_DOS_BASED_FILE_SYSTEM - backslash = strrchr (filename, '\\'); - if (modname == NULL || (backslash != NULL && backslash > modname)) - modname = backslash; -#endif - - if (modname != NULL) - ++modname; -#ifdef HAVE_DOS_BASED_FILE_SYSTEM - else if (filename[0] && filename[1] == ':') - modname = filename + 2; -#endif - else - modname = filename; - - c = xstrdup (modname); - s = strrchr (c, '.'); - if (s != NULL) - *s = '\0'; - - if (! ieee_change_buffer (info, &info->vars) - || ! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 10) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, c) - || ! ieee_write_id (info, "") - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, "GNU objcopy")) - { - free (c); - return FALSE; - } - - free (c); - } - - if ((sec->flags & SEC_CODE) != 0) - kind = 1; - else if ((sec->flags & SEC_READONLY) != 0) - kind = 3; - else - kind = 2; - - if (! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 11) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, "") - || ! ieee_write_number (info, kind) - || ! ieee_write_number (info, sec->index + IEEE_SECTION_NUMBER_BASE) - || ! ieee_write_number (info, low) - || ! ieee_write_byte (info, (int) ieee_be_record_enum) - || ! ieee_write_number (info, high - low)) - return FALSE; - - return TRUE; -} - -/* Start recording information from a particular source file. This is - used to record which file defined which types, variables, etc. It - is not used for line numbers, since the lineno entry point passes - down the file name anyhow. IEEE debugging information doesn't seem - to store this information anywhere. */ - -static bfd_boolean -ieee_start_source (void *p ATTRIBUTE_UNUSED, - const char *filename ATTRIBUTE_UNUSED) -{ - return TRUE; -} - -/* Make an empty type. */ - -static bfd_boolean -ieee_empty_type (void *p) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - - return ieee_push_type (info, (int) builtin_unknown, 0, FALSE, FALSE); -} - -/* Make a void type. */ - -static bfd_boolean -ieee_void_type (void *p) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - - return ieee_push_type (info, (int) builtin_void, 0, FALSE, FALSE); -} - -/* Make an integer type. */ - -static bfd_boolean -ieee_int_type (void *p, unsigned int size, bfd_boolean unsignedp) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - unsigned int indx; - - switch (size) - { - case 1: - indx = (int) builtin_signed_char; - break; - case 2: - indx = (int) builtin_signed_short_int; - break; - case 4: - indx = (int) builtin_signed_long; - break; - case 8: - indx = (int) builtin_signed_long_long; - break; - default: - fprintf (stderr, _("IEEE unsupported integer type size %u\n"), size); - return FALSE; - } - - if (unsignedp) - ++indx; - - return ieee_push_type (info, indx, size, unsignedp, FALSE); -} - -/* Make a floating point type. */ - -static bfd_boolean -ieee_float_type (void *p, unsigned int size) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - unsigned int indx; - - switch (size) - { - case 4: - indx = (int) builtin_float; - break; - case 8: - indx = (int) builtin_double; - break; - case 12: - /* FIXME: This size really depends upon the processor. */ - indx = (int) builtin_long_double; - break; - case 16: - indx = (int) builtin_long_long_double; - break; - default: - fprintf (stderr, _("IEEE unsupported float type size %u\n"), size); - return FALSE; - } - - return ieee_push_type (info, indx, size, FALSE, FALSE); -} - -/* Make a complex type. */ - -static bfd_boolean -ieee_complex_type (void *p, unsigned int size) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - char code; - - switch (size) - { - case 4: - if (info->complex_float_index != 0) - return ieee_push_type (info, info->complex_float_index, size * 2, - FALSE, FALSE); - code = 'c'; - break; - case 12: - case 16: - /* These cases can be output by gcc -gstabs. Outputting the - wrong type is better than crashing. */ - case 8: - if (info->complex_double_index != 0) - return ieee_push_type (info, info->complex_double_index, size * 2, - FALSE, FALSE); - code = 'd'; - break; - default: - fprintf (stderr, _("IEEE unsupported complex type size %u\n"), size); - return FALSE; - } - - /* FIXME: I don't know what the string is for. */ - if (! ieee_define_type (info, size * 2, FALSE, FALSE) - || ! ieee_write_number (info, code) - || ! ieee_write_id (info, "")) - return FALSE; - - if (size == 4) - info->complex_float_index = info->type_stack->type.indx; - else - info->complex_double_index = info->type_stack->type.indx; - - return TRUE; -} - -/* Make a boolean type. IEEE doesn't support these, so we just make - an integer type instead. */ - -static bfd_boolean -ieee_bool_type (void *p, unsigned int size) -{ - return ieee_int_type (p, size, TRUE); -} - -/* Make an enumeration. */ - -static bfd_boolean -ieee_enum_type (void *p, const char *tag, const char **names, - bfd_signed_vma *vals) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - struct ieee_defined_enum *e; - bfd_boolean localp, simple; - unsigned int indx; - int i = 0; - - localp = FALSE; - indx = (unsigned int) -1; - for (e = info->enums; e != NULL; e = e->next) - { - if (tag == NULL) - { - if (e->tag != NULL) - continue; - } - else - { - if (e->tag == NULL - || tag[0] != e->tag[0] - || strcmp (tag, e->tag) != 0) - continue; - } - - if (! e->defined) - { - /* This enum tag has been seen but not defined. */ - indx = e->indx; - break; - } - - if (names != NULL && e->names != NULL) - { - for (i = 0; names[i] != NULL && e->names[i] != NULL; i++) - { - if (names[i][0] != e->names[i][0] - || vals[i] != e->vals[i] - || strcmp (names[i], e->names[i]) != 0) - break; - } - } - - if ((names == NULL && e->names == NULL) - || (names != NULL - && e->names != NULL - && names[i] == NULL - && e->names[i] == NULL)) - { - /* We've seen this enum before. */ - return ieee_push_type (info, e->indx, 0, TRUE, FALSE); - } - - if (tag != NULL) - { - /* We've already seen an enum of the same name, so we must make - sure to output this one locally. */ - localp = TRUE; - break; - } - } - - /* If this is a simple enumeration, in which the values start at 0 - and always increment by 1, we can use type E. Otherwise we must - use type N. */ - - simple = TRUE; - if (names != NULL) - { - for (i = 0; names[i] != NULL; i++) - { - if (vals[i] != i) - { - simple = FALSE; - break; - } - } - } - - if (! ieee_define_named_type (info, tag, indx, 0, TRUE, localp, - (struct ieee_buflist *) NULL) - || ! ieee_write_number (info, simple ? 'E' : 'N')) - return FALSE; - if (simple) - { - /* FIXME: This is supposed to be the enumeration size, but we - don't store that. */ - if (! ieee_write_number (info, 4)) - return FALSE; - } - if (names != NULL) - { - for (i = 0; names[i] != NULL; i++) - { - if (! ieee_write_id (info, names[i])) - return FALSE; - if (! simple) - { - if (! ieee_write_number (info, vals[i])) - return FALSE; - } - } - } - - if (! localp) - { - if (indx == (unsigned int) -1) - { - e = (struct ieee_defined_enum *) xmalloc (sizeof *e); - memset (e, 0, sizeof *e); - e->indx = info->type_stack->type.indx; - e->tag = tag; - - e->next = info->enums; - info->enums = e; - } - - e->names = names; - e->vals = vals; - e->defined = TRUE; - } - - return TRUE; -} - -/* Make a pointer type. */ - -static bfd_boolean -ieee_pointer_type (void *p) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - bfd_boolean localp; - unsigned int indx; - struct ieee_modified_type *m = NULL; - - localp = info->type_stack->type.localp; - indx = ieee_pop_type (info); - - /* A pointer to a simple builtin type can be obtained by adding 32. - FIXME: Will this be a short pointer, and will that matter? */ - if (indx < 32) - return ieee_push_type (info, indx + 32, 0, TRUE, FALSE); - - if (! localp) - { - m = ieee_get_modified_info ((struct ieee_handle *) p, indx); - if (m == NULL) - return FALSE; - - /* FIXME: The size should depend upon the architecture. */ - if (m->pointer > 0) - return ieee_push_type (info, m->pointer, 4, TRUE, FALSE); - } - - if (! ieee_define_type (info, 4, TRUE, localp) - || ! ieee_write_number (info, 'P') - || ! ieee_write_number (info, indx)) - return FALSE; - - if (! localp) - m->pointer = info->type_stack->type.indx; - - return TRUE; -} - -/* Make a function type. This will be called for a method, but we - don't want to actually add it to the type table in that case. We - handle this by defining the type in a private buffer, and only - adding that buffer to the typedef block if we are going to use it. */ - -static bfd_boolean -ieee_function_type (void *p, int argcount, bfd_boolean varargs) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - bfd_boolean localp; - unsigned int *args = NULL; - int i; - unsigned int retindx; - struct ieee_buflist fndef; - struct ieee_modified_type *m; - - localp = FALSE; - - if (argcount > 0) - { - args = (unsigned int *) xmalloc (argcount * sizeof *args); - for (i = argcount - 1; i >= 0; i--) - { - if (info->type_stack->type.localp) - localp = TRUE; - args[i] = ieee_pop_type (info); - } - } - else if (argcount < 0) - varargs = FALSE; - - if (info->type_stack->type.localp) - localp = TRUE; - retindx = ieee_pop_type (info); - - m = NULL; - if (argcount < 0 && ! localp) - { - m = ieee_get_modified_info ((struct ieee_handle *) p, retindx); - if (m == NULL) - return FALSE; - - if (m->function > 0) - return ieee_push_type (info, m->function, 0, TRUE, FALSE); - } - - /* An attribute of 0x41 means that the frame and push mask are - unknown. */ - if (! ieee_init_buffer (info, &fndef) - || ! ieee_define_named_type (info, (const char *) NULL, - (unsigned int) -1, 0, TRUE, localp, - &fndef) - || ! ieee_write_number (info, 'x') - || ! ieee_write_number (info, 0x41) - || ! ieee_write_number (info, 0) - || ! ieee_write_number (info, 0) - || ! ieee_write_number (info, retindx) - || ! ieee_write_number (info, (bfd_vma) argcount + (varargs ? 1 : 0))) - { - free (args); - return FALSE; - } - if (argcount > 0) - { - for (i = 0; i < argcount; i++) - if (! ieee_write_number (info, args[i])) - return FALSE; - free (args); - } - if (varargs) - { - /* A varargs function is represented by writing out the last - argument as type void *, although this makes little sense. */ - if (! ieee_write_number (info, (bfd_vma) builtin_void + 32)) - return FALSE; - } - - if (! ieee_write_number (info, 0)) - return FALSE; - - /* We wrote the information into fndef, in case we don't need it. - It will be appended to info->types by ieee_pop_type. */ - info->type_stack->type.fndef = fndef; - - if (m != NULL) - m->function = info->type_stack->type.indx; - - return TRUE; -} - -/* Make a reference type. */ - -static bfd_boolean -ieee_reference_type (void *p) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - - /* IEEE appears to record a normal pointer type, and then use a - pmisc record to indicate that it is really a reference. */ - - if (! ieee_pointer_type (p)) - return FALSE; - info->type_stack->type.referencep = TRUE; - return TRUE; -} - -/* Make a range type. */ - -static bfd_boolean -ieee_range_type (void *p, bfd_signed_vma low, bfd_signed_vma high) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - unsigned int size; - bfd_boolean unsignedp, localp; - - size = info->type_stack->type.size; - unsignedp = info->type_stack->type.unsignedp; - localp = info->type_stack->type.localp; - ieee_pop_unused_type (info); - return (ieee_define_type (info, size, unsignedp, localp) - && ieee_write_number (info, 'R') - && ieee_write_number (info, (bfd_vma) low) - && ieee_write_number (info, (bfd_vma) high) - && ieee_write_number (info, unsignedp ? 0 : 1) - && ieee_write_number (info, size)); -} - -/* Make an array type. */ - -static bfd_boolean -ieee_array_type (void *p, bfd_signed_vma low, bfd_signed_vma high, - bfd_boolean stringp ATTRIBUTE_UNUSED) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - unsigned int eleindx; - bfd_boolean localp; - unsigned int size; - struct ieee_modified_type *m = NULL; - struct ieee_modified_array_type *a; - - /* IEEE does not store the range, so we just ignore it. */ - ieee_pop_unused_type (info); - localp = info->type_stack->type.localp; - size = info->type_stack->type.size; - eleindx = ieee_pop_type (info); - - /* If we don't know the range, treat the size as exactly one - element. */ - if (low < high) - size *= (high - low) + 1; - - if (! localp) - { - m = ieee_get_modified_info (info, eleindx); - if (m == NULL) - return FALSE; - - for (a = m->arrays; a != NULL; a = a->next) - { - if (a->low == low && a->high == high) - return ieee_push_type (info, a->indx, size, FALSE, FALSE); - } - } - - if (! ieee_define_type (info, size, FALSE, localp) - || ! ieee_write_number (info, low == 0 ? 'Z' : 'C') - || ! ieee_write_number (info, eleindx)) - return FALSE; - if (low != 0) - { - if (! ieee_write_number (info, low)) - return FALSE; - } - - if (! ieee_write_number (info, high + 1)) - return FALSE; - - if (! localp) - { - a = (struct ieee_modified_array_type *) xmalloc (sizeof *a); - memset (a, 0, sizeof *a); - - a->indx = info->type_stack->type.indx; - a->low = low; - a->high = high; - - a->next = m->arrays; - m->arrays = a; - } - - return TRUE; -} - -/* Make a set type. */ - -static bfd_boolean -ieee_set_type (void *p, bfd_boolean bitstringp ATTRIBUTE_UNUSED) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - bfd_boolean localp; - unsigned int eleindx; - - localp = info->type_stack->type.localp; - eleindx = ieee_pop_type (info); - - /* FIXME: We don't know the size, so we just use 4. */ - - return (ieee_define_type (info, 0, TRUE, localp) - && ieee_write_number (info, 's') - && ieee_write_number (info, 4) - && ieee_write_number (info, eleindx)); -} - -/* Make an offset type. */ - -static bfd_boolean -ieee_offset_type (void *p) -{ - /* FIXME: The MRI C++ compiler does not appear to generate any - useful type information about an offset type. It just records a - pointer to member as an integer. The MRI/HP IEEE spec does - describe a pmisc record which can be used for a pointer to - member. Unfortunately, it does not describe the target type, - which seems pretty important. I'm going to punt this for now. */ - - return ieee_int_type (p, 4, TRUE); -} - -/* Make a method type. */ - -static bfd_boolean -ieee_method_type (void *p, bfd_boolean domain, int argcount, - bfd_boolean varargs) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - - /* FIXME: The MRI/HP IEEE spec defines a pmisc record to use for a - method, but the definition is incomplete. We just output an 'x' - type. */ - - if (domain) - ieee_pop_unused_type (info); - - return ieee_function_type (p, argcount, varargs); -} - -/* Make a const qualified type. */ - -static bfd_boolean -ieee_const_type (void *p) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - unsigned int size; - bfd_boolean unsignedp, localp; - unsigned int indx; - struct ieee_modified_type *m = NULL; - - size = info->type_stack->type.size; - unsignedp = info->type_stack->type.unsignedp; - localp = info->type_stack->type.localp; - indx = ieee_pop_type (info); - - if (! localp) - { - m = ieee_get_modified_info (info, indx); - if (m == NULL) - return FALSE; - - if (m->const_qualified > 0) - return ieee_push_type (info, m->const_qualified, size, unsignedp, - FALSE); - } - - if (! ieee_define_type (info, size, unsignedp, localp) - || ! ieee_write_number (info, 'n') - || ! ieee_write_number (info, 1) - || ! ieee_write_number (info, indx)) - return FALSE; - - if (! localp) - m->const_qualified = info->type_stack->type.indx; - - return TRUE; -} - -/* Make a volatile qualified type. */ - -static bfd_boolean -ieee_volatile_type (void *p) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - unsigned int size; - bfd_boolean unsignedp, localp; - unsigned int indx; - struct ieee_modified_type *m = NULL; - - size = info->type_stack->type.size; - unsignedp = info->type_stack->type.unsignedp; - localp = info->type_stack->type.localp; - indx = ieee_pop_type (info); - - if (! localp) - { - m = ieee_get_modified_info (info, indx); - if (m == NULL) - return FALSE; - - if (m->volatile_qualified > 0) - return ieee_push_type (info, m->volatile_qualified, size, unsignedp, - FALSE); - } - - if (! ieee_define_type (info, size, unsignedp, localp) - || ! ieee_write_number (info, 'n') - || ! ieee_write_number (info, 2) - || ! ieee_write_number (info, indx)) - return FALSE; - - if (! localp) - m->volatile_qualified = info->type_stack->type.indx; - - return TRUE; -} - -/* Convert an enum debug_visibility into a CXXFLAGS value. */ - -static unsigned int -ieee_vis_to_flags (enum debug_visibility visibility) -{ - switch (visibility) - { - default: - abort (); - case DEBUG_VISIBILITY_PUBLIC: - return CXXFLAGS_VISIBILITY_PUBLIC; - case DEBUG_VISIBILITY_PRIVATE: - return CXXFLAGS_VISIBILITY_PRIVATE; - case DEBUG_VISIBILITY_PROTECTED: - return CXXFLAGS_VISIBILITY_PROTECTED; - } - /*NOTREACHED*/ -} - -/* Start defining a struct type. We build it in the strdef field on - the stack, to avoid confusing type definitions required by the - fields with the struct type itself. */ - -static bfd_boolean -ieee_start_struct_type (void *p, const char *tag, unsigned int id, - bfd_boolean structp, unsigned int size) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - bfd_boolean localp, ignorep; - bfd_boolean copy; - char ab[20]; - const char *look; - struct ieee_name_type_hash_entry *h; - struct ieee_name_type *nt, *ntlook; - struct ieee_buflist strdef; - - localp = FALSE; - ignorep = FALSE; - - /* We need to create a tag for internal use even if we don't want - one for external use. This will let us refer to an anonymous - struct. */ - if (tag != NULL) - { - look = tag; - copy = FALSE; - } - else - { - sprintf (ab, "__anon%u", id); - look = ab; - copy = TRUE; - } - - /* If we already have references to the tag, we must use the - existing type index. */ - h = ieee_name_type_hash_lookup (&info->tags, look, TRUE, copy); - if (h == NULL) - return FALSE; - - nt = NULL; - for (ntlook = h->types; ntlook != NULL; ntlook = ntlook->next) - { - if (ntlook->id == id) - nt = ntlook; - else if (! ntlook->type.localp) - { - /* We are creating a duplicate definition of a globally - defined tag. Force it to be local to avoid - confusion. */ - localp = TRUE; - } - } - - if (nt != NULL) - { - assert (localp == nt->type.localp); - if (nt->kind == DEBUG_KIND_ILLEGAL && ! localp) - { - /* We've already seen a global definition of the type. - Ignore this new definition. */ - ignorep = TRUE; - } - } - else - { - nt = (struct ieee_name_type *) xmalloc (sizeof *nt); - memset (nt, 0, sizeof *nt); - nt->id = id; - nt->type.name = h->root.string; - nt->next = h->types; - h->types = nt; - nt->type.indx = info->type_indx; - ++info->type_indx; - } - - nt->kind = DEBUG_KIND_ILLEGAL; - - if (! ieee_init_buffer (info, &strdef) - || ! ieee_define_named_type (info, tag, nt->type.indx, size, TRUE, - localp, &strdef) - || ! ieee_write_number (info, structp ? 'S' : 'U') - || ! ieee_write_number (info, size)) - return FALSE; - - if (! ignorep) - { - const char *hold; - - /* We never want nt->type.name to be NULL. We want the rest of - the type to be the object set up on the type stack; it will - have a NULL name if tag is NULL. */ - hold = nt->type.name; - nt->type = info->type_stack->type; - nt->type.name = hold; - } - - info->type_stack->type.name = tag; - info->type_stack->type.strdef = strdef; - info->type_stack->type.ignorep = ignorep; - - return TRUE; -} - -/* Add a field to a struct. */ - -static bfd_boolean -ieee_struct_field (void *p, const char *name, bfd_vma bitpos, bfd_vma bitsize, - enum debug_visibility visibility) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - unsigned int size; - bfd_boolean unsignedp; - bfd_boolean referencep; - bfd_boolean localp; - unsigned int indx; - bfd_vma offset; - - assert (info->type_stack != NULL - && info->type_stack->next != NULL - && ! ieee_buffer_emptyp (&info->type_stack->next->type.strdef)); - - /* If we are ignoring this struct definition, just pop and ignore - the type. */ - if (info->type_stack->next->type.ignorep) - { - ieee_pop_unused_type (info); - return TRUE; - } - - size = info->type_stack->type.size; - unsignedp = info->type_stack->type.unsignedp; - referencep = info->type_stack->type.referencep; - localp = info->type_stack->type.localp; - indx = ieee_pop_type (info); - - if (localp) - info->type_stack->type.localp = TRUE; - - if (info->type_stack->type.classdef != NULL) - { - unsigned int flags; - unsigned int nindx; - - /* This is a class. We must add a description of this field to - the class records we are building. */ - - flags = ieee_vis_to_flags (visibility); - nindx = info->type_stack->type.classdef->indx; - if (! ieee_change_buffer (info, - &info->type_stack->type.classdef->pmiscbuf) - || ! ieee_write_asn (info, nindx, 'd') - || ! ieee_write_asn (info, nindx, flags) - || ! ieee_write_atn65 (info, nindx, name) - || ! ieee_write_atn65 (info, nindx, name)) - return FALSE; - info->type_stack->type.classdef->pmisccount += 4; - - if (referencep) - { - /* We need to output a record recording that this field is - really of reference type. We put this on the refs field - of classdef, so that it can be appended to the C++ - records after the class is defined. */ - - nindx = info->name_indx; - ++info->name_indx; - - if (! ieee_change_buffer (info, - &info->type_stack->type.classdef->refs) - || ! ieee_write_byte (info, (int) ieee_nn_record) - || ! ieee_write_number (info, nindx) - || ! ieee_write_id (info, "") - || ! ieee_write_2bytes (info, (int) ieee_atn_record_enum) - || ! ieee_write_number (info, nindx) - || ! ieee_write_number (info, 0) - || ! ieee_write_number (info, 62) - || ! ieee_write_number (info, 80) - || ! ieee_write_number (info, 4) - || ! ieee_write_asn (info, nindx, 'R') - || ! ieee_write_asn (info, nindx, 3) - || ! ieee_write_atn65 (info, nindx, info->type_stack->type.name) - || ! ieee_write_atn65 (info, nindx, name)) - return FALSE; - } - } - - /* If the bitsize doesn't match the expected size, we need to output - a bitfield type. */ - if (size == 0 || bitsize == 0 || bitsize == size * 8) - offset = bitpos / 8; - else - { - if (! ieee_define_type (info, 0, unsignedp, - info->type_stack->type.localp) - || ! ieee_write_number (info, 'g') - || ! ieee_write_number (info, unsignedp ? 0 : 1) - || ! ieee_write_number (info, bitsize) - || ! ieee_write_number (info, indx)) - return FALSE; - indx = ieee_pop_type (info); - offset = bitpos; - } - - /* Switch to the struct we are building in order to output this - field definition. */ - return (ieee_change_buffer (info, &info->type_stack->type.strdef) - && ieee_write_id (info, name) - && ieee_write_number (info, indx) - && ieee_write_number (info, offset)); -} - -/* Finish up a struct type. */ - -static bfd_boolean -ieee_end_struct_type (void *p) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - struct ieee_buflist *pb; - - assert (info->type_stack != NULL - && ! ieee_buffer_emptyp (&info->type_stack->type.strdef)); - - /* If we were ignoring this struct definition because it was a - duplicate definition, just through away whatever bytes we have - accumulated. Leave the type on the stack. */ - if (info->type_stack->type.ignorep) - return TRUE; - - /* If this is not a duplicate definition of this tag, then localp - will be FALSE, and we can put it in the global type block. - FIXME: We should avoid outputting duplicate definitions which are - the same. */ - if (! info->type_stack->type.localp) - { - /* Make sure we have started the global type block. */ - if (ieee_buffer_emptyp (&info->global_types)) - { - if (! ieee_change_buffer (info, &info->global_types) - || ! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 2) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, "")) - return FALSE; - } - pb = &info->global_types; - } - else - { - /* Make sure we have started the types block. */ - if (ieee_buffer_emptyp (&info->types)) - { - if (! ieee_change_buffer (info, &info->types) - || ! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 1) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, info->modname)) - return FALSE; - } - pb = &info->types; - } - - /* Append the struct definition to the types. */ - if (! ieee_append_buffer (info, pb, &info->type_stack->type.strdef) - || ! ieee_init_buffer (info, &info->type_stack->type.strdef)) - return FALSE; - - /* Leave the struct on the type stack. */ - - return TRUE; -} - -/* Start a class type. */ - -static bfd_boolean -ieee_start_class_type (void *p, const char *tag, unsigned int id, - bfd_boolean structp, unsigned int size, - bfd_boolean vptr, bfd_boolean ownvptr) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - const char *vclass; - struct ieee_buflist pmiscbuf; - unsigned int indx; - struct ieee_type_class *classdef; - - /* A C++ class is output as a C++ struct along with a set of pmisc - records describing the class. */ - - /* We need to have a name so that we can associate the struct and - the class. */ - if (tag == NULL) - { - char *t; - - t = (char *) xmalloc (20); - sprintf (t, "__anon%u", id); - tag = t; - } - - /* We can't write out the virtual table information until we have - finished the class, because we don't know the virtual table size. - We get the size from the largest voffset we see. */ - vclass = NULL; - if (vptr && ! ownvptr) - { - vclass = info->type_stack->type.name; - assert (vclass != NULL); - /* We don't call ieee_pop_unused_type, since the class should - get defined. */ - (void) ieee_pop_type (info); - } - - if (! ieee_start_struct_type (p, tag, id, structp, size)) - return FALSE; - - indx = info->name_indx; - ++info->name_indx; - - /* We write out pmisc records into the classdef field. We will - write out the pmisc start after we know the number of records we - need. */ - if (! ieee_init_buffer (info, &pmiscbuf) - || ! ieee_change_buffer (info, &pmiscbuf) - || ! ieee_write_asn (info, indx, 'T') - || ! ieee_write_asn (info, indx, structp ? 'o' : 'u') - || ! ieee_write_atn65 (info, indx, tag)) - return FALSE; - - classdef = (struct ieee_type_class *) xmalloc (sizeof *classdef); - memset (classdef, 0, sizeof *classdef); - - classdef->indx = indx; - classdef->pmiscbuf = pmiscbuf; - classdef->pmisccount = 3; - classdef->vclass = vclass; - classdef->ownvptr = ownvptr; - - info->type_stack->type.classdef = classdef; - - return TRUE; -} - -/* Add a static member to a class. */ - -static bfd_boolean -ieee_class_static_member (void *p, const char *name, const char *physname, - enum debug_visibility visibility) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - unsigned int flags; - unsigned int nindx; - - /* We don't care about the type. Hopefully there will be a call to - ieee_variable declaring the physical name and the type, since - that is where an IEEE consumer must get the type. */ - ieee_pop_unused_type (info); - - assert (info->type_stack != NULL - && info->type_stack->type.classdef != NULL); - - flags = ieee_vis_to_flags (visibility); - flags |= CXXFLAGS_STATIC; - - nindx = info->type_stack->type.classdef->indx; - - if (! ieee_change_buffer (info, &info->type_stack->type.classdef->pmiscbuf) - || ! ieee_write_asn (info, nindx, 'd') - || ! ieee_write_asn (info, nindx, flags) - || ! ieee_write_atn65 (info, nindx, name) - || ! ieee_write_atn65 (info, nindx, physname)) - return FALSE; - info->type_stack->type.classdef->pmisccount += 4; - - return TRUE; -} - -/* Add a base class to a class. */ - -static bfd_boolean -ieee_class_baseclass (void *p, bfd_vma bitpos, bfd_boolean is_virtual, - enum debug_visibility visibility) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - const char *bname; - bfd_boolean localp; - unsigned int bindx; - char *fname; - unsigned int flags; - unsigned int nindx; - - assert (info->type_stack != NULL - && info->type_stack->type.name != NULL - && info->type_stack->next != NULL - && info->type_stack->next->type.classdef != NULL - && ! ieee_buffer_emptyp (&info->type_stack->next->type.strdef)); - - bname = info->type_stack->type.name; - localp = info->type_stack->type.localp; - bindx = ieee_pop_type (info); - - /* We are currently defining both a struct and a class. We must - write out a field definition in the struct which holds the base - class. The stabs debugging reader will create a field named - _vb$CLASS for a virtual base class, so we just use that. FIXME: - we should not depend upon a detail of stabs debugging. */ - if (is_virtual) - { - fname = (char *) xmalloc (strlen (bname) + sizeof "_vb$"); - sprintf (fname, "_vb$%s", bname); - flags = BASEFLAGS_VIRTUAL; - } - else - { - if (localp) - info->type_stack->type.localp = TRUE; - - fname = (char *) xmalloc (strlen (bname) + sizeof "_b$"); - sprintf (fname, "_b$%s", bname); - - if (! ieee_change_buffer (info, &info->type_stack->type.strdef) - || ! ieee_write_id (info, fname) - || ! ieee_write_number (info, bindx) - || ! ieee_write_number (info, bitpos / 8)) - { - free (fname); - return FALSE; - } - flags = 0; - } - - if (visibility == DEBUG_VISIBILITY_PRIVATE) - flags |= BASEFLAGS_PRIVATE; - - nindx = info->type_stack->type.classdef->indx; - - if (! ieee_change_buffer (info, &info->type_stack->type.classdef->pmiscbuf) - || ! ieee_write_asn (info, nindx, 'b') - || ! ieee_write_asn (info, nindx, flags) - || ! ieee_write_atn65 (info, nindx, bname) - || ! ieee_write_asn (info, nindx, 0) - || ! ieee_write_atn65 (info, nindx, fname)) - { - free (fname); - return FALSE; - } - info->type_stack->type.classdef->pmisccount += 5; - - free (fname); - - return TRUE; -} - -/* Start building a method for a class. */ - -static bfd_boolean -ieee_class_start_method (void *p, const char *name) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - - assert (info->type_stack != NULL - && info->type_stack->type.classdef != NULL - && info->type_stack->type.classdef->method == NULL); - - info->type_stack->type.classdef->method = name; - - return TRUE; -} - -/* Define a new method variant, either static or not. */ - -static bfd_boolean -ieee_class_method_var (struct ieee_handle *info, const char *physname, - enum debug_visibility visibility, - bfd_boolean staticp, bfd_boolean constp, - bfd_boolean volatilep, bfd_vma voffset, - bfd_boolean context) -{ - unsigned int flags; - unsigned int nindx; - bfd_boolean is_virtual; - - /* We don't need the type of the method. An IEEE consumer which - wants the type must track down the function by the physical name - and get the type from that. */ - ieee_pop_unused_type (info); - - /* We don't use the context. FIXME: We probably ought to use it to - adjust the voffset somehow, but I don't really know how. */ - if (context) - ieee_pop_unused_type (info); - - assert (info->type_stack != NULL - && info->type_stack->type.classdef != NULL - && info->type_stack->type.classdef->method != NULL); - - flags = ieee_vis_to_flags (visibility); - - /* FIXME: We never set CXXFLAGS_OVERRIDE, CXXFLAGS_OPERATOR, - CXXFLAGS_CTORDTOR, CXXFLAGS_CTOR, or CXXFLAGS_INLINE. */ - - if (staticp) - flags |= CXXFLAGS_STATIC; - if (constp) - flags |= CXXFLAGS_CONST; - if (volatilep) - flags |= CXXFLAGS_VOLATILE; - - nindx = info->type_stack->type.classdef->indx; - - is_virtual = context || voffset > 0; - - if (! ieee_change_buffer (info, - &info->type_stack->type.classdef->pmiscbuf) - || ! ieee_write_asn (info, nindx, is_virtual ? 'v' : 'm') - || ! ieee_write_asn (info, nindx, flags) - || ! ieee_write_atn65 (info, nindx, - info->type_stack->type.classdef->method) - || ! ieee_write_atn65 (info, nindx, physname)) - return FALSE; - - if (is_virtual) - { - if (voffset > info->type_stack->type.classdef->voffset) - info->type_stack->type.classdef->voffset = voffset; - if (! ieee_write_asn (info, nindx, voffset)) - return FALSE; - ++info->type_stack->type.classdef->pmisccount; - } - - if (! ieee_write_asn (info, nindx, 0)) - return FALSE; - - info->type_stack->type.classdef->pmisccount += 5; - - return TRUE; -} - -/* Define a new method variant. */ - -static bfd_boolean -ieee_class_method_variant (void *p, const char *physname, - enum debug_visibility visibility, - bfd_boolean constp, bfd_boolean volatilep, - bfd_vma voffset, bfd_boolean context) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - - return ieee_class_method_var (info, physname, visibility, FALSE, constp, - volatilep, voffset, context); -} - -/* Define a new static method variant. */ - -static bfd_boolean -ieee_class_static_method_variant (void *p, const char *physname, - enum debug_visibility visibility, - bfd_boolean constp, bfd_boolean volatilep) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - - return ieee_class_method_var (info, physname, visibility, TRUE, constp, - volatilep, 0, FALSE); -} - -/* Finish up a method. */ - -static bfd_boolean -ieee_class_end_method (void *p) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - - assert (info->type_stack != NULL - && info->type_stack->type.classdef != NULL - && info->type_stack->type.classdef->method != NULL); - - info->type_stack->type.classdef->method = NULL; - - return TRUE; -} - -/* Finish up a class. */ - -static bfd_boolean -ieee_end_class_type (void *p) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - unsigned int nindx; - - assert (info->type_stack != NULL - && info->type_stack->type.classdef != NULL); - - /* If we were ignoring this class definition because it was a - duplicate definition, just through away whatever bytes we have - accumulated. Leave the type on the stack. */ - if (info->type_stack->type.ignorep) - return TRUE; - - nindx = info->type_stack->type.classdef->indx; - - /* If we have a virtual table, we can write out the information now. */ - if (info->type_stack->type.classdef->vclass != NULL - || info->type_stack->type.classdef->ownvptr) - { - if (! ieee_change_buffer (info, - &info->type_stack->type.classdef->pmiscbuf) - || ! ieee_write_asn (info, nindx, 'z') - || ! ieee_write_atn65 (info, nindx, "") - || ! ieee_write_asn (info, nindx, - info->type_stack->type.classdef->voffset)) - return FALSE; - if (info->type_stack->type.classdef->ownvptr) - { - if (! ieee_write_atn65 (info, nindx, "")) - return FALSE; - } - else - { - if (! ieee_write_atn65 (info, nindx, - info->type_stack->type.classdef->vclass)) - return FALSE; - } - if (! ieee_write_asn (info, nindx, 0)) - return FALSE; - info->type_stack->type.classdef->pmisccount += 5; - } - - /* Now that we know the number of pmisc records, we can write out - the atn62 which starts the pmisc records, and append them to the - C++ buffers. */ - - if (! ieee_change_buffer (info, &info->cxx) - || ! ieee_write_byte (info, (int) ieee_nn_record) - || ! ieee_write_number (info, nindx) - || ! ieee_write_id (info, "") - || ! ieee_write_2bytes (info, (int) ieee_atn_record_enum) - || ! ieee_write_number (info, nindx) - || ! ieee_write_number (info, 0) - || ! ieee_write_number (info, 62) - || ! ieee_write_number (info, 80) - || ! ieee_write_number (info, - info->type_stack->type.classdef->pmisccount)) - return FALSE; - - if (! ieee_append_buffer (info, &info->cxx, - &info->type_stack->type.classdef->pmiscbuf)) - return FALSE; - if (! ieee_buffer_emptyp (&info->type_stack->type.classdef->refs)) - { - if (! ieee_append_buffer (info, &info->cxx, - &info->type_stack->type.classdef->refs)) - return FALSE; - } - - return ieee_end_struct_type (p); -} - -/* Push a previously seen typedef onto the type stack. */ - -static bfd_boolean -ieee_typedef_type (void *p, const char *name) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - struct ieee_name_type_hash_entry *h; - struct ieee_name_type *nt; - - h = ieee_name_type_hash_lookup (&info->typedefs, name, FALSE, FALSE); - - /* h should never be NULL, since that would imply that the generic - debugging code has asked for a typedef which it has not yet - defined. */ - assert (h != NULL); - - /* We always use the most recently defined type for this name, which - will be the first one on the list. */ - - nt = h->types; - if (! ieee_push_type (info, nt->type.indx, nt->type.size, - nt->type.unsignedp, nt->type.localp)) - return FALSE; - - /* Copy over any other type information we may have. */ - info->type_stack->type = nt->type; - - return TRUE; -} - -/* Push a tagged type onto the type stack. */ - -static bfd_boolean -ieee_tag_type (void *p, const char *name, unsigned int id, - enum debug_type_kind kind) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - bfd_boolean localp; - bfd_boolean copy; - char ab[20]; - struct ieee_name_type_hash_entry *h; - struct ieee_name_type *nt; - - if (kind == DEBUG_KIND_ENUM) - { - struct ieee_defined_enum *e; - - if (name == NULL) - abort (); - for (e = info->enums; e != NULL; e = e->next) - if (e->tag != NULL && strcmp (e->tag, name) == 0) - return ieee_push_type (info, e->indx, 0, TRUE, FALSE); - - e = (struct ieee_defined_enum *) xmalloc (sizeof *e); - memset (e, 0, sizeof *e); - - e->indx = info->type_indx; - ++info->type_indx; - e->tag = name; - e->defined = FALSE; - - e->next = info->enums; - info->enums = e; - - return ieee_push_type (info, e->indx, 0, TRUE, FALSE); - } - - localp = FALSE; - - copy = FALSE; - if (name == NULL) - { - sprintf (ab, "__anon%u", id); - name = ab; - copy = TRUE; - } - - h = ieee_name_type_hash_lookup (&info->tags, name, TRUE, copy); - if (h == NULL) - return FALSE; - - for (nt = h->types; nt != NULL; nt = nt->next) - { - if (nt->id == id) - { - if (! ieee_push_type (info, nt->type.indx, nt->type.size, - nt->type.unsignedp, nt->type.localp)) - return FALSE; - /* Copy over any other type information we may have. */ - info->type_stack->type = nt->type; - return TRUE; - } - - if (! nt->type.localp) - { - /* This is a duplicate of a global type, so it must be - local. */ - localp = TRUE; - } - } - - nt = (struct ieee_name_type *) xmalloc (sizeof *nt); - memset (nt, 0, sizeof *nt); - - nt->id = id; - nt->type.name = h->root.string; - nt->type.indx = info->type_indx; - nt->type.localp = localp; - ++info->type_indx; - nt->kind = kind; - - nt->next = h->types; - h->types = nt; - - if (! ieee_push_type (info, nt->type.indx, 0, FALSE, localp)) - return FALSE; - - info->type_stack->type.name = h->root.string; - - return TRUE; -} - -/* Output a typedef. */ - -static bfd_boolean -ieee_typdef (void *p, const char *name) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - struct ieee_write_type type; - unsigned int indx; - bfd_boolean found; - bfd_boolean localp; - struct ieee_name_type_hash_entry *h; - struct ieee_name_type *nt; - - type = info->type_stack->type; - indx = type.indx; - - /* If this is a simple builtin type using a builtin name, we don't - want to output the typedef itself. We also want to change the - type index to correspond to the name being used. We recognize - names used in stabs debugging output even if they don't exactly - correspond to the names used for the IEEE builtin types. */ - found = FALSE; - if (indx <= (unsigned int) builtin_bcd_float) - { - switch ((enum builtin_types) indx) - { - default: - break; - - case builtin_void: - if (strcmp (name, "void") == 0) - found = TRUE; - break; - - case builtin_signed_char: - case builtin_char: - if (strcmp (name, "signed char") == 0) - { - indx = (unsigned int) builtin_signed_char; - found = TRUE; - } - else if (strcmp (name, "char") == 0) - { - indx = (unsigned int) builtin_char; - found = TRUE; - } - break; - - case builtin_unsigned_char: - if (strcmp (name, "unsigned char") == 0) - found = TRUE; - break; - - case builtin_signed_short_int: - case builtin_short: - case builtin_short_int: - case builtin_signed_short: - if (strcmp (name, "signed short int") == 0) - { - indx = (unsigned int) builtin_signed_short_int; - found = TRUE; - } - else if (strcmp (name, "short") == 0) - { - indx = (unsigned int) builtin_short; - found = TRUE; - } - else if (strcmp (name, "short int") == 0) - { - indx = (unsigned int) builtin_short_int; - found = TRUE; - } - else if (strcmp (name, "signed short") == 0) - { - indx = (unsigned int) builtin_signed_short; - found = TRUE; - } - break; - - case builtin_unsigned_short_int: - case builtin_unsigned_short: - if (strcmp (name, "unsigned short int") == 0 - || strcmp (name, "short unsigned int") == 0) - { - indx = builtin_unsigned_short_int; - found = TRUE; - } - else if (strcmp (name, "unsigned short") == 0) - { - indx = builtin_unsigned_short; - found = TRUE; - } - break; - - case builtin_signed_long: - case builtin_int: /* FIXME: Size depends upon architecture. */ - case builtin_long: - if (strcmp (name, "signed long") == 0) - { - indx = builtin_signed_long; - found = TRUE; - } - else if (strcmp (name, "int") == 0) - { - indx = builtin_int; - found = TRUE; - } - else if (strcmp (name, "long") == 0 - || strcmp (name, "long int") == 0) - { - indx = builtin_long; - found = TRUE; - } - break; - - case builtin_unsigned_long: - case builtin_unsigned: /* FIXME: Size depends upon architecture. */ - case builtin_unsigned_int: /* FIXME: Like builtin_unsigned. */ - if (strcmp (name, "unsigned long") == 0 - || strcmp (name, "long unsigned int") == 0) - { - indx = builtin_unsigned_long; - found = TRUE; - } - else if (strcmp (name, "unsigned") == 0) - { - indx = builtin_unsigned; - found = TRUE; - } - else if (strcmp (name, "unsigned int") == 0) - { - indx = builtin_unsigned_int; - found = TRUE; - } - break; - - case builtin_signed_long_long: - if (strcmp (name, "signed long long") == 0 - || strcmp (name, "long long int") == 0) - found = TRUE; - break; - - case builtin_unsigned_long_long: - if (strcmp (name, "unsigned long long") == 0 - || strcmp (name, "long long unsigned int") == 0) - found = TRUE; - break; - - case builtin_float: - if (strcmp (name, "float") == 0) - found = TRUE; - break; - - case builtin_double: - if (strcmp (name, "double") == 0) - found = TRUE; - break; - - case builtin_long_double: - if (strcmp (name, "long double") == 0) - found = TRUE; - break; - - case builtin_long_long_double: - if (strcmp (name, "long long double") == 0) - found = TRUE; - break; - } - - if (found) - type.indx = indx; - } - - h = ieee_name_type_hash_lookup (&info->typedefs, name, TRUE, FALSE); - if (h == NULL) - return FALSE; - - /* See if we have already defined this type with this name. */ - localp = type.localp; - for (nt = h->types; nt != NULL; nt = nt->next) - { - if (nt->id == indx) - { - /* If this is a global definition, then we don't need to - do anything here. */ - if (! nt->type.localp) - { - ieee_pop_unused_type (info); - return TRUE; - } - } - else - { - /* This is a duplicate definition, so make this one local. */ - localp = TRUE; - } - } - - /* We need to add a new typedef for this type. */ - - nt = (struct ieee_name_type *) xmalloc (sizeof *nt); - memset (nt, 0, sizeof *nt); - nt->id = indx; - nt->type = type; - nt->type.name = name; - nt->type.localp = localp; - nt->kind = DEBUG_KIND_ILLEGAL; - - nt->next = h->types; - h->types = nt; - - if (found) - { - /* This is one of the builtin typedefs, so we don't need to - actually define it. */ - ieee_pop_unused_type (info); - return TRUE; - } - - indx = ieee_pop_type (info); - - if (! ieee_define_named_type (info, name, (unsigned int) -1, type.size, - type.unsignedp, localp, - (struct ieee_buflist *) NULL) - || ! ieee_write_number (info, 'T') - || ! ieee_write_number (info, indx)) - return FALSE; - - /* Remove the type we just added to the type stack. This should not - be ieee_pop_unused_type, since the type is used, we just don't - need it now. */ - (void) ieee_pop_type (info); - - return TRUE; -} - -/* Output a tag for a type. We don't have to do anything here. */ - -static bfd_boolean -ieee_tag (void *p, const char *name ATTRIBUTE_UNUSED) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - - /* This should not be ieee_pop_unused_type, since we want the type - to be defined. */ - (void) ieee_pop_type (info); - return TRUE; -} - -/* Output an integer constant. */ - -static bfd_boolean -ieee_int_constant (void *p ATTRIBUTE_UNUSED, const char *name ATTRIBUTE_UNUSED, - bfd_vma val ATTRIBUTE_UNUSED) -{ - /* FIXME. */ - return TRUE; -} - -/* Output a floating point constant. */ - -static bfd_boolean -ieee_float_constant (void *p ATTRIBUTE_UNUSED, - const char *name ATTRIBUTE_UNUSED, - double val ATTRIBUTE_UNUSED) -{ - /* FIXME. */ - return TRUE; -} - -/* Output a typed constant. */ - -static bfd_boolean -ieee_typed_constant (void *p, const char *name ATTRIBUTE_UNUSED, - bfd_vma val ATTRIBUTE_UNUSED) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - - /* FIXME. */ - ieee_pop_unused_type (info); - return TRUE; -} - -/* Output a variable. */ - -static bfd_boolean -ieee_variable (void *p, const char *name, enum debug_var_kind kind, - bfd_vma val) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - unsigned int name_indx; - unsigned int size; - bfd_boolean referencep; - unsigned int type_indx; - bfd_boolean asn; - int refflag; - - size = info->type_stack->type.size; - referencep = info->type_stack->type.referencep; - type_indx = ieee_pop_type (info); - - assert (! ieee_buffer_emptyp (&info->vars)); - if (! ieee_change_buffer (info, &info->vars)) - return FALSE; - - name_indx = info->name_indx; - ++info->name_indx; - - /* Write out an NN and an ATN record for this variable. */ - if (! ieee_write_byte (info, (int) ieee_nn_record) - || ! ieee_write_number (info, name_indx) - || ! ieee_write_id (info, name) - || ! ieee_write_2bytes (info, (int) ieee_atn_record_enum) - || ! ieee_write_number (info, name_indx) - || ! ieee_write_number (info, type_indx)) - return FALSE; - switch (kind) - { - default: - abort (); - return FALSE; - case DEBUG_GLOBAL: - if (! ieee_write_number (info, 8) - || ! ieee_add_range (info, FALSE, val, val + size)) - return FALSE; - refflag = 0; - asn = TRUE; - break; - case DEBUG_STATIC: - if (! ieee_write_number (info, 3) - || ! ieee_add_range (info, FALSE, val, val + size)) - return FALSE; - refflag = 1; - asn = TRUE; - break; - case DEBUG_LOCAL_STATIC: - if (! ieee_write_number (info, 3) - || ! ieee_add_range (info, FALSE, val, val + size)) - return FALSE; - refflag = 2; - asn = TRUE; - break; - case DEBUG_LOCAL: - if (! ieee_write_number (info, 1) - || ! ieee_write_number (info, val)) - return FALSE; - refflag = 2; - asn = FALSE; - break; - case DEBUG_REGISTER: - if (! ieee_write_number (info, 2) - || ! ieee_write_number (info, - ieee_genreg_to_regno (info->abfd, val))) - return FALSE; - refflag = 2; - asn = FALSE; - break; - } - - if (asn) - { - if (! ieee_write_asn (info, name_indx, val)) - return FALSE; - } - - /* If this is really a reference type, then we just output it with - pointer type, and must now output a C++ record indicating that it - is really reference type. */ - if (referencep) - { - unsigned int nindx; - - nindx = info->name_indx; - ++info->name_indx; - - /* If this is a global variable, we want to output the misc - record in the C++ misc record block. Otherwise, we want to - output it just after the variable definition, which is where - the current buffer is. */ - if (refflag != 2) - { - if (! ieee_change_buffer (info, &info->cxx)) - return FALSE; - } - - if (! ieee_write_byte (info, (int) ieee_nn_record) - || ! ieee_write_number (info, nindx) - || ! ieee_write_id (info, "") - || ! ieee_write_2bytes (info, (int) ieee_atn_record_enum) - || ! ieee_write_number (info, nindx) - || ! ieee_write_number (info, 0) - || ! ieee_write_number (info, 62) - || ! ieee_write_number (info, 80) - || ! ieee_write_number (info, 3) - || ! ieee_write_asn (info, nindx, 'R') - || ! ieee_write_asn (info, nindx, refflag) - || ! ieee_write_atn65 (info, nindx, name)) - return FALSE; - } - - return TRUE; -} - -/* Start outputting information for a function. */ - -static bfd_boolean -ieee_start_function (void *p, const char *name, bfd_boolean global) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - bfd_boolean referencep; - unsigned int retindx, typeindx; - - referencep = info->type_stack->type.referencep; - retindx = ieee_pop_type (info); - - /* Besides recording a BB4 or BB6 block, we record the type of the - function in the BB1 typedef block. We can't write out the full - type until we have seen all the parameters, so we accumulate it - in info->fntype and info->fnargs. */ - if (! ieee_buffer_emptyp (&info->fntype)) - { - /* FIXME: This might happen someday if we support nested - functions. */ - abort (); - } - - info->fnname = name; - - /* An attribute of 0x40 means that the push mask is unknown. */ - if (! ieee_define_named_type (info, name, (unsigned int) -1, 0, FALSE, TRUE, - &info->fntype) - || ! ieee_write_number (info, 'x') - || ! ieee_write_number (info, 0x40) - || ! ieee_write_number (info, 0) - || ! ieee_write_number (info, 0) - || ! ieee_write_number (info, retindx)) - return FALSE; - - typeindx = ieee_pop_type (info); - - if (! ieee_init_buffer (info, &info->fnargs)) - return FALSE; - info->fnargcount = 0; - - /* If the function return value is actually a reference type, we - must add a record indicating that. */ - if (referencep) - { - unsigned int nindx; - - nindx = info->name_indx; - ++info->name_indx; - if (! ieee_change_buffer (info, &info->cxx) - || ! ieee_write_byte (info, (int) ieee_nn_record) - || ! ieee_write_number (info, nindx) - || ! ieee_write_id (info, "") - || ! ieee_write_2bytes (info, (int) ieee_atn_record_enum) - || ! ieee_write_number (info, nindx) - || ! ieee_write_number (info, 0) - || ! ieee_write_number (info, 62) - || ! ieee_write_number (info, 80) - || ! ieee_write_number (info, 3) - || ! ieee_write_asn (info, nindx, 'R') - || ! ieee_write_asn (info, nindx, global ? 0 : 1) - || ! ieee_write_atn65 (info, nindx, name)) - return FALSE; - } - - assert (! ieee_buffer_emptyp (&info->vars)); - if (! ieee_change_buffer (info, &info->vars)) - return FALSE; - - /* The address is written out as the first block. */ - - ++info->block_depth; - - return (ieee_write_byte (info, (int) ieee_bb_record_enum) - && ieee_write_byte (info, global ? 4 : 6) - && ieee_write_number (info, 0) - && ieee_write_id (info, name) - && ieee_write_number (info, 0) - && ieee_write_number (info, typeindx)); -} - -/* Add a function parameter. This will normally be called before the - first block, so we postpone them until we see the block. */ - -static bfd_boolean -ieee_function_parameter (void *p, const char *name, enum debug_parm_kind kind, - bfd_vma val) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - struct ieee_pending_parm *m, **pm; - - assert (info->block_depth == 1); - - m = (struct ieee_pending_parm *) xmalloc (sizeof *m); - memset (m, 0, sizeof *m); - - m->next = NULL; - m->name = name; - m->referencep = info->type_stack->type.referencep; - m->type = ieee_pop_type (info); - m->kind = kind; - m->val = val; - - for (pm = &info->pending_parms; *pm != NULL; pm = &(*pm)->next) - ; - *pm = m; - - /* Add the type to the fnargs list. */ - if (! ieee_change_buffer (info, &info->fnargs) - || ! ieee_write_number (info, m->type)) - return FALSE; - ++info->fnargcount; - - return TRUE; -} - -/* Output pending function parameters. */ - -static bfd_boolean -ieee_output_pending_parms (struct ieee_handle *info) -{ - struct ieee_pending_parm *m; - unsigned int refcount; - - refcount = 0; - for (m = info->pending_parms; m != NULL; m = m->next) - { - enum debug_var_kind vkind; - - switch (m->kind) - { - default: - abort (); - return FALSE; - case DEBUG_PARM_STACK: - case DEBUG_PARM_REFERENCE: - vkind = DEBUG_LOCAL; - break; - case DEBUG_PARM_REG: - case DEBUG_PARM_REF_REG: - vkind = DEBUG_REGISTER; - break; - } - - if (! ieee_push_type (info, m->type, 0, FALSE, FALSE)) - return FALSE; - info->type_stack->type.referencep = m->referencep; - if (m->referencep) - ++refcount; - if (! ieee_variable ((void *) info, m->name, vkind, m->val)) - return FALSE; - } - - /* If there are any reference parameters, we need to output a - miscellaneous record indicating them. */ - if (refcount > 0) - { - unsigned int nindx, varindx; - - /* FIXME: The MRI compiler outputs the demangled function name - here, but we are outputting the mangled name. */ - nindx = info->name_indx; - ++info->name_indx; - if (! ieee_change_buffer (info, &info->vars) - || ! ieee_write_byte (info, (int) ieee_nn_record) - || ! ieee_write_number (info, nindx) - || ! ieee_write_id (info, "") - || ! ieee_write_2bytes (info, (int) ieee_atn_record_enum) - || ! ieee_write_number (info, nindx) - || ! ieee_write_number (info, 0) - || ! ieee_write_number (info, 62) - || ! ieee_write_number (info, 80) - || ! ieee_write_number (info, refcount + 3) - || ! ieee_write_asn (info, nindx, 'B') - || ! ieee_write_atn65 (info, nindx, info->fnname) - || ! ieee_write_asn (info, nindx, 0)) - return FALSE; - for (m = info->pending_parms, varindx = 1; - m != NULL; - m = m->next, varindx++) - { - if (m->referencep) - { - if (! ieee_write_asn (info, nindx, varindx)) - return FALSE; - } - } - } - - m = info->pending_parms; - while (m != NULL) - { - struct ieee_pending_parm *next; - - next = m->next; - free (m); - m = next; - } - - info->pending_parms = NULL; - - return TRUE; -} - -/* Start a block. If this is the first block, we output the address - to finish the BB4 or BB6, and then output the function parameters. */ - -static bfd_boolean -ieee_start_block (void *p, bfd_vma addr) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - - if (! ieee_change_buffer (info, &info->vars)) - return FALSE; - - if (info->block_depth == 1) - { - if (! ieee_write_number (info, addr) - || ! ieee_output_pending_parms (info)) - return FALSE; - } - else - { - if (! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 6) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, "") - || ! ieee_write_number (info, 0) - || ! ieee_write_number (info, 0) - || ! ieee_write_number (info, addr)) - return FALSE; - } - - if (! ieee_start_range (info, addr)) - return FALSE; - - ++info->block_depth; - - return TRUE; -} - -/* End a block. */ - -static bfd_boolean -ieee_end_block (void *p, bfd_vma addr) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - - /* The address we are given is the end of the block, but IEEE seems - to want to the address of the last byte in the block, so we - subtract one. */ - if (! ieee_change_buffer (info, &info->vars) - || ! ieee_write_byte (info, (int) ieee_be_record_enum) - || ! ieee_write_number (info, addr - 1)) - return FALSE; - - if (! ieee_end_range (info, addr)) - return FALSE; - - --info->block_depth; - - if (addr > info->highaddr) - info->highaddr = addr; - - return TRUE; -} - -/* End a function. */ - -static bfd_boolean -ieee_end_function (void *p) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - - assert (info->block_depth == 1); - - --info->block_depth; - - /* Now we can finish up fntype, and add it to the typdef section. - At this point, fntype is the 'x' type up to the argument count, - and fnargs is the argument types. We must add the argument - count, and we must add the level. FIXME: We don't record varargs - functions correctly. In fact, stabs debugging does not give us - enough information to do so. */ - if (! ieee_change_buffer (info, &info->fntype) - || ! ieee_write_number (info, info->fnargcount) - || ! ieee_change_buffer (info, &info->fnargs) - || ! ieee_write_number (info, 0)) - return FALSE; - - /* Make sure the typdef block has been started. */ - if (ieee_buffer_emptyp (&info->types)) - { - if (! ieee_change_buffer (info, &info->types) - || ! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 1) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, info->modname)) - return FALSE; - } - - if (! ieee_append_buffer (info, &info->types, &info->fntype) - || ! ieee_append_buffer (info, &info->types, &info->fnargs)) - return FALSE; - - info->fnname = NULL; - if (! ieee_init_buffer (info, &info->fntype) - || ! ieee_init_buffer (info, &info->fnargs)) - return FALSE; - info->fnargcount = 0; - - return TRUE; -} - -/* Record line number information. */ - -static bfd_boolean -ieee_lineno (void *p, const char *filename, unsigned long lineno, bfd_vma addr) -{ - struct ieee_handle *info = (struct ieee_handle *) p; - - assert (info->filename != NULL); - - /* The HP simulator seems to get confused when more than one line is - listed for the same address, at least if they are in different - files. We handle this by always listing the last line for a - given address, since that seems to be the one that gdb uses. */ - if (info->pending_lineno_filename != NULL - && addr != info->pending_lineno_addr) - { - /* Make sure we have a line number block. */ - if (! ieee_buffer_emptyp (&info->linenos)) - { - if (! ieee_change_buffer (info, &info->linenos)) - return FALSE; - } - else - { - info->lineno_name_indx = info->name_indx; - ++info->name_indx; - if (! ieee_change_buffer (info, &info->linenos) - || ! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 5) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, info->filename) - || ! ieee_write_byte (info, (int) ieee_nn_record) - || ! ieee_write_number (info, info->lineno_name_indx) - || ! ieee_write_id (info, "")) - return FALSE; - info->lineno_filename = info->filename; - } - - if (filename_cmp (info->pending_lineno_filename, - info->lineno_filename) != 0) - { - if (filename_cmp (info->filename, info->lineno_filename) != 0) - { - /* We were not in the main file. Close the block for the - included file. */ - if (! ieee_write_byte (info, (int) ieee_be_record_enum)) - return FALSE; - if (filename_cmp (info->filename, - info->pending_lineno_filename) == 0) - { - /* We need a new NN record, and we aren't about to - output one. */ - info->lineno_name_indx = info->name_indx; - ++info->name_indx; - if (! ieee_write_byte (info, (int) ieee_nn_record) - || ! ieee_write_number (info, info->lineno_name_indx) - || ! ieee_write_id (info, "")) - return FALSE; - } - } - if (filename_cmp (info->filename, - info->pending_lineno_filename) != 0) - { - /* We are not changing to the main file. Open a block for - the new included file. */ - info->lineno_name_indx = info->name_indx; - ++info->name_indx; - if (! ieee_write_byte (info, (int) ieee_bb_record_enum) - || ! ieee_write_byte (info, 5) - || ! ieee_write_number (info, 0) - || ! ieee_write_id (info, info->pending_lineno_filename) - || ! ieee_write_byte (info, (int) ieee_nn_record) - || ! ieee_write_number (info, info->lineno_name_indx) - || ! ieee_write_id (info, "")) - return FALSE; - } - info->lineno_filename = info->pending_lineno_filename; - } - - if (! ieee_write_2bytes (info, (int) ieee_atn_record_enum) - || ! ieee_write_number (info, info->lineno_name_indx) - || ! ieee_write_number (info, 0) - || ! ieee_write_number (info, 7) - || ! ieee_write_number (info, info->pending_lineno) - || ! ieee_write_number (info, 0) - || ! ieee_write_asn (info, info->lineno_name_indx, - info->pending_lineno_addr)) - return FALSE; - } - - info->pending_lineno_filename = filename; - info->pending_lineno = lineno; - info->pending_lineno_addr = addr; - - return TRUE; -} diff --git a/binutils/makefile.vms b/binutils/makefile.vms index 088ac3b..7a0ba1a 100644 --- a/binutils/makefile.vms +++ b/binutils/makefile.vms @@ -36,7 +36,7 @@ LIBIBERTY = [-.libiberty]libiberty.olb/lib OPCODES_DEP = [-.opcodes]libopcodes.olb OPCODES = [-.opcodes]libopcodes.olb/lib -DEBUG_OBJS = rddbg.obj,debug.obj,stabs.obj,ieee.obj,rdcoff.obj,dwarf.obj,\ +DEBUG_OBJS = rddbg.obj,debug.obj,stabs.obj,rdcoff.obj,dwarf.obj,\ elfcomm.obj BULIBS = bucomm.obj,version.obj,filemode.obj diff --git a/binutils/objcopy.c b/binutils/objcopy.c index d0a152c..61c513b 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -4251,9 +4251,6 @@ write_debugging_info (bfd *obfd, void *dhandle, long *symcountp ATTRIBUTE_UNUSED, asymbol ***symppp ATTRIBUTE_UNUSED) { - if (bfd_get_flavour (obfd) == bfd_target_ieee_flavour) - return write_ieee_debugging_info (obfd, dhandle); - if (bfd_get_flavour (obfd) == bfd_target_coff_flavour || bfd_get_flavour (obfd) == bfd_target_elf_flavour) { diff --git a/binutils/objdump.c b/binutils/objdump.c index f4d05bb..aab2063 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -3646,8 +3646,8 @@ dump_bfd (bfd *abfd) exit_status = 1; } } - /* PR 6483: If there was no STABS or IEEE debug - info in the file, try DWARF instead. */ + /* PR 6483: If there was no STABS debug info in the file, try + DWARF instead. */ else if (! dump_dwarf_section_info) { dwarf_select_sections_all (); diff --git a/binutils/po/POTFILES.in b/binutils/po/POTFILES.in index 2795582..6910e93 100644 --- a/binutils/po/POTFILES.in +++ b/binutils/po/POTFILES.in @@ -26,8 +26,6 @@ elfedit.c emul_aix.c emul_vanilla.c filemode.c -ieee.c -ieee.c is-ranlib.c is-strip.c maybe-ranlib.c diff --git a/binutils/rddbg.c b/binutils/rddbg.c index 49972e6..4a690f6 100644 --- a/binutils/rddbg.c +++ b/binutils/rddbg.c @@ -35,7 +35,6 @@ static bfd_boolean read_section_stabs_debugging_info (bfd *, asymbol **, long, void *, bfd_boolean *); static bfd_boolean read_symbol_stabs_debugging_info (bfd *, asymbol **, long, void *, bfd_boolean *); -static bfd_boolean read_ieee_debugging_info (bfd *, void *, bfd_boolean *); static void save_stab (int, int, bfd_vma, const char *); static void stab_context (void); static void free_saved_stabs (void); @@ -64,12 +63,6 @@ read_debugging_info (bfd *abfd, asymbol **syms, long symcount, bfd_boolean no_me return NULL; } - if (bfd_get_flavour (abfd) == bfd_target_ieee_flavour) - { - if (! read_ieee_debugging_info (abfd, dhandle, &found)) - return NULL; - } - /* Try reading the COFF symbols if we didn't find any stabs in COFF sections. */ if (! found @@ -346,37 +339,6 @@ read_symbol_stabs_debugging_info (bfd *abfd, asymbol **syms, long symcount, return TRUE; } - -/* Read IEEE debugging information. */ - -static bfd_boolean -read_ieee_debugging_info (bfd *abfd, void *dhandle, bfd_boolean *pfound) -{ - asection *dsec; - bfd_size_type size; - bfd_byte *contents; - - /* The BFD backend puts the debugging information into a section - named .debug. */ - - dsec = bfd_get_section_by_name (abfd, ".debug"); - if (dsec == NULL) - return TRUE; - - size = bfd_section_size (abfd, dsec); - contents = (bfd_byte *) xmalloc (size); - if (! bfd_get_section_contents (abfd, dsec, contents, 0, size)) - return FALSE; - - if (! parse_ieee (dhandle, abfd, contents, size)) - return FALSE; - - free (contents); - - *pfound = TRUE; - - return TRUE; -} /* Record stabs strings, so that we can give some context for errors. */ diff --git a/gas/ChangeLog b/gas/ChangeLog index d54a09d..c60c86a 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,10 @@ 2018-04-16 Alan Modra + * app.c: Remove IEEE 695 support. + * symbols.c: Likewise. + +2018-04-16 Alan Modra + * Makefile.am: Remove netware support. * config/tc-i386.c: Likewise. * configure.tgt: Likewise. diff --git a/gas/app.c b/gas/app.c index 9cafff0..64541c4 100644 --- a/gas/app.c +++ b/gas/app.c @@ -1053,7 +1053,6 @@ do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen) PUT (ch); break; -#ifndef IEEE_STYLE case LEX_IS_ONECHAR_QUOTE: #ifdef H_TICK_HEX if (state == 9 && enable_h_tick_hex) @@ -1115,7 +1114,6 @@ do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen) out_string = out_buf; PUT (*out_string++); break; -#endif case LEX_IS_COLON: #ifdef KEEP_WHITE_AROUND_COLON diff --git a/gas/symbols.c b/gas/symbols.c index 08a708b..96bf963 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -1355,7 +1355,7 @@ resolve_symbol_value (symbolS *symp) operands must be absolute. We already handled the case of addition or subtraction of a constant above. This will probably need to be changed for an object file format which - supports arbitrary expressions, such as IEEE-695. */ + supports arbitrary expressions. */ if (!(seg_left == absolute_section && seg_right == absolute_section) && !(op == O_eq || op == O_ne) diff --git a/include/ChangeLog b/include/ChangeLog index f6d3b74..aaeb039 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,5 +1,9 @@ 2018-04-16 Alan Modra + * ieee.h: Delete. + +2018-04-16 Alan Modra + * aout/host.h: Remove newsos3 support. 2018-04-16 Alan Modra diff --git a/include/ieee.h b/include/ieee.h deleted file mode 100644 index d6ce46f..0000000 --- a/include/ieee.h +++ /dev/null @@ -1,165 +0,0 @@ -/* IEEE Standard 695-1980 "Universal Format for Object Modules" header file - - Copyright (C) 2001-2018 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street - Fifth Floor, - Boston, MA 02110-1301, USA. - - Contributed by Cygnus Support. */ - -#define N_W_VARIABLES 8 -#define Module_Beginning 0xe0 - -typedef struct ieee_module - { - char *processor; - char *module_name; - } -ieee_module_begin_type; - -#define Address_Descriptor 0xec -typedef struct ieee_address - { - bfd_vma number_of_bits_mau; - bfd_vma number_of_maus_in_address; - - unsigned char byte_order; -#define IEEE_LITTLE 0xcc -#define IEEE_BIG 0xcd - } -ieee_address_descriptor_type; - -typedef union ieee_w_variable - { - file_ptr offset[N_W_VARIABLES]; - - struct - { - file_ptr extension_record; - file_ptr environmental_record; - file_ptr section_part; - file_ptr external_part; - file_ptr debug_information_part; - file_ptr data_part; - file_ptr trailer_part; - file_ptr me_record; - } - r; - } -ieee_w_variable_type; - -typedef enum ieee_record - { - ieee_number_start_enum = 0x00, - ieee_number_end_enum=0x7f, - ieee_number_repeat_start_enum = 0x80, - ieee_number_repeat_end_enum = 0x88, - ieee_number_repeat_4_enum = 0x84, - ieee_number_repeat_3_enum = 0x83, - ieee_number_repeat_2_enum = 0x82, - ieee_number_repeat_1_enum = 0x81, - ieee_module_beginning_enum = 0xe0, - ieee_module_end_enum = 0xe1, - ieee_extension_length_1_enum = 0xde, - ieee_extension_length_2_enum = 0xdf, - ieee_section_type_enum = 0xe6, - ieee_section_alignment_enum = 0xe7, - ieee_external_symbol_enum = 0xe8, - ieee_comma = 0x90, - ieee_external_reference_enum = 0xe9, - ieee_set_current_section_enum = 0xe5, - ieee_address_descriptor_enum = 0xec, - ieee_load_constant_bytes_enum = 0xed, - ieee_load_with_relocation_enum = 0xe4, - - ieee_variable_A_enum = 0xc1, - ieee_variable_B_enum = 0xc2, - ieee_variable_C_enum = 0xc3, - ieee_variable_D_enum = 0xc4, - ieee_variable_E_enum = 0xc5, - ieee_variable_F_enum = 0xc6, - ieee_variable_G_enum = 0xc7, - ieee_variable_H_enum = 0xc8, - ieee_variable_I_enum = 0xc9, - ieee_variable_J_enum = 0xca, - ieee_variable_K_enum = 0xcb, - ieee_variable_L_enum = 0xcc, - ieee_variable_M_enum = 0xcd, - ieee_variable_N_enum = 0xce, - ieee_variable_O_enum = 0xcf, - ieee_variable_P_enum = 0xd0, - ieee_variable_Q_enum = 0xd1, - ieee_variable_R_enum = 0xd2, - ieee_variable_S_enum = 0xd3, - ieee_variable_T_enum = 0xd4, - ieee_variable_U_enum = 0xd5, - ieee_variable_V_enum = 0xd6, - ieee_variable_W_enum = 0xd7, - ieee_variable_X_enum = 0xd8, - ieee_variable_Y_enum = 0xd9, - ieee_variable_Z_enum = 0xda, - ieee_function_plus_enum = 0xa5, - ieee_function_minus_enum = 0xa6, - ieee_function_signed_open_b_enum = 0xba, - ieee_function_signed_close_b_enum = 0xbb, - - ieee_function_unsigned_open_b_enum = 0xbc, - ieee_function_unsigned_close_b_enum = 0xbd, - - ieee_function_either_open_b_enum = 0xbe, - ieee_function_either_close_b_enum = 0xbf, - ieee_record_seperator_enum = 0xdb, - - ieee_e2_first_byte_enum = 0xe2, - ieee_section_size_enum = 0xe2d3, - ieee_physical_region_size_enum = 0xe2c1, - ieee_region_base_address_enum = 0xe2c2, - ieee_mau_size_enum = 0xe2c6, - ieee_m_value_enum = 0xe2cd, - ieee_section_base_address_enum = 0xe2cc, - ieee_asn_record_enum = 0xe2ce, - ieee_section_offset_enum = 0xe2d2, - ieee_value_starting_address_enum = 0xe2c7, - ieee_assign_value_to_variable_enum = 0xe2d7, - ieee_set_current_pc_enum = 0xe2d0, - ieee_value_record_enum = 0xe2c9, - ieee_nn_record = 0xf0, - ieee_at_record_enum = 0xf1, - ieee_ty_record_enum = 0xf2, - ieee_attribute_record_enum = 0xf1c9, - ieee_atn_record_enum = 0xf1ce, - ieee_external_reference_info_record_enum = 0xf1d8, - ieee_weak_external_reference_enum= 0xf4, - ieee_repeat_data_enum = 0xf7, - ieee_bb_record_enum = 0xf8, - ieee_be_record_enum = 0xf9 - } -ieee_record_enum_type; - -typedef struct ieee_section - { - unsigned int section_index; - unsigned int section_type; - char * section_name; - unsigned int parent_section_index; - unsigned int sibling_section_index; - unsigned int context_index; - } -ieee_section_type; - -#define IEEE_REFERENCE_BASE 11 -#define IEEE_PUBLIC_BASE 32 -#define IEEE_SECTION_NUMBER_BASE 1 - diff --git a/ld/ChangeLog b/ld/ChangeLog index ee24342..7b75643 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,10 @@ 2018-04-16 Alan Modra + * ld.texinfo: Remove IEEE 695 support. + * mri.c: Likewise. + +2018-04-16 Alan Modra + * Makefile.am: Remove tandem support. * configure.tgt: Likewise. * emulparams/st2000.sh: Delete. diff --git a/ld/ld.texinfo b/ld/ld.texinfo index cd7aa6d..11193f8 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -8609,9 +8609,6 @@ language, but restricted to one of these output formats: S-records, if @var{output-format} is @samp{S} @item -IEEE, if @var{output-format} is @samp{IEEE} - -@item COFF (the @samp{coff-m68k} variant in BFD), if @var{output-format} is @samp{COFF} @end enumerate diff --git a/ld/mri.c b/ld/mri.c index 788ca4e..c07d358 100644 --- a/ld/mri.c +++ b/ld/mri.c @@ -285,9 +285,6 @@ mri_format (const char *name) if (strcmp (name, "S") == 0) lang_add_output_format ("srec", NULL, NULL, 1); - else if (strcmp (name, "IEEE") == 0) - lang_add_output_format ("ieee", NULL, NULL, 1); - else if (strcmp (name, "COFF") == 0) lang_add_output_format ("coff-m68k", NULL, NULL, 1); -- 2.7.4