eliminate most prototypes so ansidecl.h isn't needed before this file (incomplete)
[deliverable/binutils-gdb.git] / bfd / ieee.c
index 11214225ba4a9a8557e8ee20c6a2ed5b0caa8da1..f294088b0e0d46a7616c2348670becdfcaa2a2a1 100644 (file)
@@ -1,5 +1,5 @@
-/* bfd back-end for ieee-695 objects.
-   Copyright (C) 1990-1991 Free Software Foundation, Inc.
+/* BFD back-end for ieee-695 objects.
+   Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -18,6 +18,8 @@ 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., 675 Mass Ave, Cambridge, MA 02139, 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.  */
@@ -28,6 +30,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "ieee.h"
 #include "libieee.h"
 
+
+#include "obstack.h"
+#define obstack_chunk_alloc bfd_xmalloc
+#define obstack_chunk_free free
+
 /* Functions for writing to ieee files in the strange way that the
    standard requires. */
 
@@ -71,7 +78,7 @@ DEFUN(ieee_write_int,(abfd, value),
       bfd_vma value)
 {
   if (((unsigned)value) <= 127) {
-    ieee_write_byte(abfd, value);
+    ieee_write_byte(abfd, (bfd_byte)value);
   }
   else {
     unsigned int length;
@@ -88,16 +95,17 @@ DEFUN(ieee_write_int,(abfd, value),
     }
     else length = 1;
 
-    ieee_write_byte(abfd, (int)ieee_number_repeat_start_enum + length);
+    ieee_write_byte(abfd,
+                   (bfd_byte)((int)ieee_number_repeat_start_enum + length));
     switch (length) {
     case 4:
-      ieee_write_byte(abfd, value >> 24);
+      ieee_write_byte(abfd, (bfd_byte)(value >> 24));
     case 3:
-      ieee_write_byte(abfd, value >> 16);
+      ieee_write_byte(abfd, (bfd_byte)(value >> 16));
     case 2:
-      ieee_write_byte(abfd, value >> 8);
+      ieee_write_byte(abfd, (bfd_byte)(value >> 8));
     case 1:
-      ieee_write_byte(abfd, value);
+      ieee_write_byte(abfd, (bfd_byte)(value));
     }
   }
 }
@@ -109,16 +117,16 @@ DEFUN(ieee_write_id,(abfd, id),
 {
   size_t length = strlen(id);
   if (length >= 0 && length <= 127) {
-    ieee_write_byte(abfd, length);
+    ieee_write_byte(abfd, (bfd_byte)length);
   }
   else if (length < 255) {
     ieee_write_byte(abfd, ieee_extension_length_1_enum);
-    ieee_write_byte(abfd, length);
+    ieee_write_byte(abfd, (bfd_byte)length);
   }
   else if (length < 65535) {
     ieee_write_byte(abfd, ieee_extension_length_2_enum);
-    ieee_write_byte(abfd, length >> 8);
-    ieee_write_byte(abfd, length & 0xff);  
+    ieee_write_byte(abfd, (bfd_byte)(length >> 8));
+    ieee_write_byte(abfd, (bfd_byte)(length & 0xff));  
   }
   else {
     BFD_FAIL();
@@ -202,7 +210,7 @@ DEFUN(ieee_write_expression,(abfd, value, symbol, pcrel, index),
   
      
 
-  if (symbol->section == &bfd_com_section
+  if (bfd_is_com_section (symbol->section)
       || symbol->section == &bfd_und_section) 
   {
     /* Def of a common symbol */
@@ -215,7 +223,8 @@ DEFUN(ieee_write_expression,(abfd, value, symbol, pcrel, index),
     /* Ref to defined symbol - */
   
     ieee_write_byte(abfd, ieee_variable_R_enum);
-    ieee_write_byte(abfd, symbol->section->index + IEEE_SECTION_NUMBER_BASE);
+    ieee_write_byte(abfd, 
+       (bfd_byte) (symbol->section->index + IEEE_SECTION_NUMBER_BASE));
     term_count++;
     if (symbol->flags & BSF_GLOBAL) 
     {
@@ -228,8 +237,8 @@ DEFUN(ieee_write_expression,(abfd, value, symbol, pcrel, index),
       /* This is a reference to a defined local symbol, 
         We can easily do a local as a section+offset */
       ieee_write_byte(abfd, ieee_variable_R_enum); /* or L */
-      ieee_write_byte(abfd, symbol->section->index +
-                     IEEE_SECTION_NUMBER_BASE);
+      ieee_write_byte(abfd, 
+         (bfd_byte)(symbol->section->index + IEEE_SECTION_NUMBER_BASE));
       ieee_write_int(abfd, symbol->value);
       term_count++;
 
@@ -245,7 +254,7 @@ DEFUN(ieee_write_expression,(abfd, value, symbol, pcrel, index),
   if(pcrel) {
       /* subtract the pc from here by asking for PC of this section*/
       ieee_write_byte(abfd, ieee_variable_P_enum);
-      ieee_write_byte(abfd, index  +IEEE_SECTION_NUMBER_BASE);
+      ieee_write_byte(abfd, (bfd_byte)(index+IEEE_SECTION_NUMBER_BASE));
       ieee_write_byte(abfd, ieee_function_minus_enum);
     }
 
@@ -362,26 +371,29 @@ reloc_howto_type abs8_howto
 
 static 
 reloc_howto_type rel32_howto 
- = HOWTO(1,0,2,32,true,0,false,true,0,"rel32",true,0xffffffff, 0xffffffff,true);
+ = HOWTO(1,0,2,32,true,0,false,true,0,"rel32",true,0xffffffff,
+        0xffffffff,false);
+
 static
 reloc_howto_type rel16_howto 
- = HOWTO(1,0,1,16,true,0,false,true,0,"rel16",true,0x0000ffff, 0x0000ffff,true);
+ = HOWTO(1,0,1,16,true,0,false,true,0,"rel16",true,0x0000ffff, 0x0000ffff,false);
 
 static
 reloc_howto_type rel8_howto 
- = HOWTO(1,0,0,8,true,0,false,true,0,"rel8",true,0x000000ff, 0x000000ff,true);
+ = HOWTO(1,0,0,8,true,0,false,true,0,"rel8",true,0x000000ff, 0x000000ff,false);
 
 
 static ieee_symbol_index_type NOSYMBOL = {  0, 0};
 
 
 static void
-DEFUN(parse_expression,(ieee, value, symbol, pcrel, extra),
+DEFUN(parse_expression,(ieee, value, symbol, pcrel, extra, section),
       ieee_data_type *ieee AND
       bfd_vma *value AND
       ieee_symbol_index_type *symbol AND
       boolean *pcrel AND
-      unsigned int *extra)
+      unsigned int *extra AND
+      asection **section)
 
 {
 #define POS sp[1]
@@ -467,7 +479,7 @@ DEFUN(parse_expression,(ieee, value, symbol, pcrel, extra),
 
              POP(sy1, section1, value1);
              POP(sy2, section2, value2);
-             PUSH(sy1.letter ? sy1 : sy2, section1 ? section1: section2, value1+value2);
+             PUSH(sy1.letter ? sy1 : sy2, section1!=&bfd_abs_section ? section1: section2, value1+value2);
            }
          break;
        default: 
@@ -497,8 +509,9 @@ DEFUN(parse_expression,(ieee, value, symbol, pcrel, extra),
                }
              {
                asection *dummy;
-               
+
                POP(*symbol, dummy, *value);
+               if (section) *section = dummy;
              }
                
                loop = false;
@@ -517,26 +530,28 @@ DEFUN(parse_expression,(ieee, value, symbol, pcrel, extra),
 #define ieee_pos(abfd)   IEEE_DATA(abfd)->h.input_p -IEEE_DATA(abfd)->h.first_byte 
 
 static unsigned int last_index;
-
+static char last_type; /* is the index for an X or a D */
 static ieee_symbol_type *
 DEFUN(get_symbol,(abfd, 
                  ieee,  
                  last_symbol,
                  symbol_count,
-pptr,
-max_index
+                 pptr,
+                 max_index,
+                 this_type
                  ),
       bfd *abfd AND
       ieee_data_type *ieee AND
       ieee_symbol_type *last_symbol AND
       unsigned int *symbol_count AND
                  ieee_symbol_type *** pptr AND
-      unsigned int *max_index
+      unsigned int *max_index AND
+      char this_type
       )
 {
   /* Need a new symbol */
   unsigned int new_index = must_parse_int(&(ieee->h));
-  if (new_index != last_index) {
+  if (new_index != last_index || this_type != last_type) {
     ieee_symbol_type  *   new_symbol = (ieee_symbol_type *)bfd_alloc(ieee->h.abfd,
                                                                     sizeof(ieee_symbol_type));
 
@@ -548,6 +563,7 @@ max_index
     if (new_index > *max_index) {
       *max_index = new_index;
     }
+    last_type = this_type;
     return new_symbol;
   }
   return last_symbol;
@@ -574,9 +590,11 @@ DEFUN(ieee_slurp_external_symbols,(abfd),
     switch (this_byte(&(ieee->h))) {
     case ieee_nn_record:
       next_byte(&(ieee->h));
+
       symbol = get_symbol(abfd, ieee, symbol, &symbol_count,
                          &prev_symbols_ptr, 
-                         &ieee->external_symbol_max_index);
+                         &ieee->external_symbol_max_index,'D');
+
 
       symbol->symbol.the_bfd = abfd;
       symbol->symbol.name = read_id(&(ieee->h));
@@ -590,7 +608,7 @@ DEFUN(ieee_slurp_external_symbols,(abfd),
                                             
       symbol = get_symbol(abfd, ieee, symbol, &symbol_count,
                          &prev_symbols_ptr,
-                         &ieee->external_symbol_max_index);
+                         &ieee->external_symbol_max_index,'D');
 
 
       BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index);
@@ -639,10 +657,10 @@ DEFUN(ieee_slurp_external_symbols,(abfd),
          symbol_name_index = must_parse_int(&(ieee->h));
          parse_expression(ieee,
                           &symbol->symbol.value,
-                          &symbol->symbol.section,
                           &symbol_ignore, 
                           &pcrel_ignore, 
-                          &extra);
+                          &extra,
+                          &symbol->symbol.section);
 
            symbol->symbol.flags  = BSF_GLOBAL | BSF_EXPORT;
 
@@ -671,7 +689,7 @@ DEFUN(ieee_slurp_external_symbols,(abfd),
 
       symbol = get_symbol(abfd, ieee, symbol, &symbol_count,
                          &prev_reference_ptr,
-                         &ieee->external_reference_max_index);
+                         &ieee->external_reference_max_index,'X');
 
 
       symbol->symbol.the_bfd = abfd;
@@ -755,52 +773,53 @@ DEFUN(ieee_get_symtab,(abfd, location),
   ieee_symbol_type *symp;
   static bfd dummy_bfd;
   static asymbol empty_symbol =
-    { &dummy_bfd," ieee empty",(symvalue)0,BSF_DEBUGGING , &bfd_abs_section};
+    /* the_bfd, name, value, attr, section */
+    { &dummy_bfd, " ieee empty", (symvalue)0, BSF_DEBUGGING, &bfd_abs_section};
 
-if (abfd->symcount) {
+  if (abfd->symcount) 
+{
+    ieee_data_type *ieee = IEEE_DATA(abfd);
+    dummy_bfd.xvec= &ieee_vec;
+    ieee_slurp_symbol_table(abfd);
 
+    if (ieee->symbol_table_full == false) {
+      /* 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;
 
-  ieee_data_type *ieee = IEEE_DATA(abfd);
-  dummy_bfd.xvec= &ieee_vec;
-  ieee_slurp_symbol_table(abfd);
-
-  if (ieee->symbol_table_full == false) {
-    /* 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;
     }
-  }
 
+    /* The external refs are indexed in a bit */
+    ieee->external_reference_base_offset   =
+     -  ieee->external_reference_min_index +ieee->external_symbol_count ;
 
-  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;
+    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;
 
-  }
-
-  /* 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;
 
-  }
 
 
-
-  location[abfd->symcount] = (asymbol *)NULL;
-}
+  }
+  if (abfd->symcount) {
+   location[abfd->symcount] = (asymbol *)NULL;
+  }
   return abfd->symcount;
 }
 static asection *
@@ -810,7 +829,10 @@ DEFUN(get_section_entry,(abfd, ieee,index),
       unsigned int index)
 {
   if (ieee->section_table[index] == (asection *)NULL) {
-    asection *section = bfd_make_section(abfd, " tempname");
+    char *tmp = bfd_alloc(abfd,11);
+    asection *section;
+    sprintf(tmp," fsec%4d", index);
+    section = bfd_make_section(abfd, tmp);
     ieee->section_table[index] = section;
     section->flags = SEC_NO_FLAGS;
     section->target_index = index;
@@ -825,8 +847,8 @@ DEFUN(ieee_slurp_sections,(abfd),
 {
   ieee_data_type *ieee = IEEE_DATA(abfd);
   file_ptr offset = ieee->w.r.section_part;
-
   asection *section = (asection *)NULL;
+  char *name;
 
   if (offset != 0) {
     bfd_byte section_type[3];
@@ -850,7 +872,7 @@ DEFUN(ieee_slurp_sections,(abfd),
              section_type[1] = this_byte(&(ieee->h));
              section->flags = SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
              switch(section_type[1]) {
-             case 0xD3:
+             case 0xD3:                /* AS Absolute section attributes */
                next_byte(&(ieee->h));
                section_type[2] = this_byte(&(ieee->h));
                switch (section_type[2]) 
@@ -875,37 +897,39 @@ DEFUN(ieee_slurp_sections,(abfd),
                    }
              }
              break;
-           case 0xC3:
+           case 0xC3:          /* Named relocatable sections (type C) */
              section_type[1] = this_byte(&(ieee->h));
              section->flags = SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
              switch (section_type[1]) {
-             case 0xD0:
-               /* Normal code */
+             case 0xD0:        /* Normal code (CP) */
                next_byte(&(ieee->h));
                section->flags |= SEC_LOAD | SEC_CODE;
                break;
-             case 0xC4:
+             case 0xC4:        /* Normal data (CD) */
                next_byte(&(ieee->h));
                section->flags |= SEC_LOAD  | SEC_DATA;
-               /* Normal data */
                break;
-             case 0xD2:
+             case 0xD2:        /* Normal rom data (CR) */
                next_byte(&(ieee->h));
-               /* Normal rom data */
                section->flags |= SEC_LOAD | SEC_ROM | SEC_DATA;
                break;
              default:
                break;
              }
            }
-           section->name = read_id(&(ieee->h));
-             { bfd_vma parent, brother, context;
+
+           /* Read section name, use it if non empty. */
+           name = read_id (&ieee->h);
+           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:
@@ -981,14 +1005,15 @@ DEFUN(ieee_archive_p,(abfd),
 
   unsigned int i;
 uint8e_type buffer[512];
-
-  int buffer_offset = 0;
+  struct obstack ob;
+  file_ptr buffer_offset = 0;
   ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
   ieee_ar_data_type *ieee ;
   abfd->tdata.ieee_ar_data = (ieee_ar_data_type *)bfd_alloc(abfd, sizeof(ieee_ar_data_type));
   ieee=  IEEE_AR_DATA(abfd);
 
 
+
   bfd_read((PTR)buffer, 1, sizeof(buffer), abfd);
 
   ieee->h.first_byte = buffer;
@@ -1010,9 +1035,13 @@ uint8e_type buffer[512];
     return (bfd_target *)NULL;
   }
   /* Throw away the filename */
-  free( read_id(&(ieee->h)));
+  read_id(&(ieee->h));
   /* This must be an IEEE archive, so we'll buy some space to do
      things */
+
+  obstack_begin(&ob, 128);
+
+
   ieee->element_count = 0;
   ieee->element_index = 0;
 
@@ -1030,7 +1059,8 @@ uint8e_type buffer[512];
       t.file_offset = must_parse_int(&(ieee->h));
       t.abfd = (bfd *)NULL;
       ieee->element_count++;
-      bfd_alloc_grow(abfd, (PTR)&t, sizeof(t));
+
+      obstack_grow(&ob, (PTR)&t, sizeof(t));
 
       /* Make sure that we don't go over the end of the buffer */
 
@@ -1046,7 +1076,7 @@ uint8e_type buffer[512];
     else loop = false;
   }
 
-  ieee->elements = (ieee_ar_obstack_type *)bfd_alloc_finish(abfd);
+  ieee->elements = (ieee_ar_obstack_type *)obstack_finish(&ob);
 
   /* Now scan the area again, and replace BB offsets with file */
   /* offsets */
@@ -1070,6 +1100,7 @@ uint8e_type buffer[512];
     }
   }
 
+/*  abfd->has_armap = ;*/
   return abfd->xvec;
 
 }
@@ -1095,8 +1126,9 @@ DEFUN(ieee_object_p,(abfd),
   ieee_data_type *save = IEEE_DATA(abfd);
   abfd->tdata.ieee_data = 0;
   ieee_mkobject(abfd);
-  ieee = IEEE_DATA(abfd);
   
+  ieee = IEEE_DATA(abfd);
+  bfd_seek(abfd, (file_ptr) 0, SEEK_SET);
   /* Read the first few bytes in to see if it makes sense */
   bfd_read((PTR)buffer, 1, sizeof(buffer), abfd);
 
@@ -1161,7 +1193,6 @@ DEFUN(ieee_object_p,(abfd),
 
   }
   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
@@ -1169,7 +1200,7 @@ DEFUN(ieee_object_p,(abfd),
 
   IEEE_DATA(abfd)->h.first_byte = (uint8e_type *) bfd_alloc(ieee->h.abfd, ieee->w.r.me_record
                                            + 50);
-  bfd_seek(abfd, 0, 0);
+  bfd_seek(abfd, (file_ptr) 0, SEEK_SET);
   bfd_read((PTR)(IEEE_DATA(abfd)->h.first_byte), 1,   ieee->w.r.me_record+50,  abfd);
 
   ieee_slurp_sections(abfd);
@@ -1275,12 +1306,11 @@ asection *section;
                            r->next = (ieee_reloc_type *)NULL;
                            next_byte(&(ieee->h));
 /*                         abort();*/
-                           
+                           r->relent.sym_ptr_ptr = 0;
                            parse_expression(ieee,
                                             &r->relent.addend,
-                                            &section,
                                             &r->symbol,
-                                            &pcrel, &extra);
+                                            &pcrel, &extra, &section);
                            r->relent.address = current_map->pc;
                            s->reloc_count++;
 if (r->relent.sym_ptr_ptr == 0) {
@@ -1461,16 +1491,15 @@ DEFUN(ieee_slurp_section_data,(abfd),
              case ieee_set_current_pc_enum & 0xff:
                  {
                    bfd_vma value;
-                   asection *dsection;
                    ieee_symbol_index_type symbol;
                    unsigned int extra;
                    boolean pcrel;
                    next_byte(&(ieee->h));
                    must_parse_int(&(ieee->h)); /* Thow away section #*/
                    parse_expression(ieee, &value,
-                                     &dsection, 
                                     &symbol,
-                                    &pcrel, &extra);
+                                    &pcrel, &extra,
+                                    0);
                    current_map->pc = value;
                    BFD_ASSERT((unsigned)(value - s->vma) <= s->_raw_size);
                  }
@@ -1585,7 +1614,8 @@ DEFUN(ieee_canonicalize_reloc,(abfd, section, relptr, symbols),
        symbols + src->symbol.index +  ieee->external_reference_base_offset;
       break;
     case 0:
-      src->relent.sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+      src->relent.sym_ptr_ptr = 
+       src->relent.sym_ptr_ptr[0]->section->symbol_ptr_ptr;
       break;
     default:
 
@@ -1626,7 +1656,7 @@ DEFUN(ieee_write_section_part,(abfd),
       {
        
        ieee_write_byte(abfd, ieee_section_type_enum);
-       ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+       ieee_write_byte(abfd, (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE));
 
        if (abfd->flags & EXEC_P) 
        {
@@ -1666,18 +1696,19 @@ DEFUN(ieee_write_section_part,(abfd),
 #endif
        /* Alignment */
        ieee_write_byte(abfd, ieee_section_alignment_enum);
-       ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+       ieee_write_byte(abfd, (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE));
        ieee_write_int(abfd, 1 << s->alignment_power);
 
        /* Size */
        ieee_write_2bytes(abfd, ieee_section_size_enum);
-       ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+       ieee_write_byte(abfd, (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
        ieee_write_int(abfd, s->_raw_size);
        if (abfd->flags & EXEC_P) {
            /* Relocateable sections don't have asl records */
            /* Vma */
            ieee_write_2bytes(abfd, ieee_section_base_address_enum);
-           ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+           ieee_write_byte(abfd,
+               (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
            ieee_write_int(abfd, s->vma);
          }
       }
@@ -1707,10 +1738,10 @@ DEFUN(do_with_relocs,(abfd, s),
 
   /* Output the section preheader */
   ieee_write_byte(abfd, ieee_set_current_section_enum);
-  ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+  ieee_write_byte(abfd, (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
 
   ieee_write_twobyte(abfd, ieee_set_current_pc_enum);
-  ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+  ieee_write_byte(abfd, (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
   ieee_write_expression(abfd, 0, s->symbol, 0, 0);
 
   if (relocs_to_go == 0) 
@@ -1809,7 +1840,7 @@ DEFUN(do_with_relocs,(abfd, s),
                BFD_FAIL();
              }
              ieee_write_byte(abfd, ieee_function_either_open_b_enum);
-             abort();
+/*           abort();*/
            
              if (r->sym_ptr_ptr != (asymbol **)NULL) {
                ieee_write_expression(abfd, r->addend + ov,
@@ -1847,18 +1878,20 @@ DEFUN(do_as_repeat, (abfd, s),
       bfd *abfd AND
       asection *s)
 {
-  ieee_write_byte(abfd, ieee_set_current_section_enum);
-  ieee_write_byte(abfd, 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, s->index + IEEE_SECTION_NUMBER_BASE);
-  ieee_write_int(abfd,  s->vma );
-
-  ieee_write_byte(abfd,ieee_repeat_data_enum);
-  ieee_write_int(abfd, s->_raw_size);
-  ieee_write_byte(abfd, ieee_load_constant_bytes_enum);
-  ieee_write_byte(abfd, 1);
-  ieee_write_byte(abfd, 0);
+  if (s->_raw_size) {
+    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));
+    ieee_write_int(abfd,  s->vma );
+
+    ieee_write_byte(abfd,ieee_repeat_data_enum);
+    ieee_write_int(abfd, s->_raw_size);
+    ieee_write_byte(abfd, ieee_load_constant_bytes_enum);
+    ieee_write_byte(abfd, 1);
+    ieee_write_byte(abfd, 0);
+  }
 }
 
 static void 
@@ -2573,7 +2606,7 @@ DEFUN(ieee_write_external_part,(abfd),
        p->value = reference_index;
        reference_index++;
       }
-      else if(p->section == &bfd_com_section) {
+      else if (bfd_is_com_section (p->section)) {
        /* This is a weak reference */
        ieee_write_byte(abfd, ieee_external_reference_enum);
        ieee_write_int(abfd, reference_index);
@@ -2642,7 +2675,7 @@ DEFUN(ieee_write_external_part,(abfd),
 }
 
 
-CONST static unsigned char exten[] = 
+static CONST unsigned char exten[] = 
   {
     0xf0, 0x20, 0x00,                                  
     0xf1, 0xce, 0x20, 0x00, 37, 3, 3,  /* Set version 3 rev 3          */
@@ -2650,7 +2683,7 @@ CONST static unsigned char exten[] =
     0xf1, 0xce, 0x20, 0x00, 38         /* set object type relocateable to x */
   };
 
-CONST static unsigned char envi[] =
+static CONST unsigned char envi[] =
   {
     0xf0, 0x21, 0x00,
 
@@ -2691,31 +2724,23 @@ DEFUN(ieee_write_object_contents,(abfd),
   unsigned int i;
   file_ptr   old;
   /* Fast forward over the header area */
-  bfd_seek(abfd, 0, 0);
+  bfd_seek(abfd, (file_ptr) 0, SEEK_SET);
   ieee_write_byte(abfd, ieee_module_beginning_enum);
 
   ieee_write_id(abfd, bfd_printable_name(abfd));
   ieee_write_id(abfd, abfd->filename);
 
-
-
-
   /* Fast forward over the variable bits */    
-
-
-
   ieee_write_byte(abfd, ieee_address_descriptor_enum);
 
   /* Bits per MAU */
-  ieee_write_byte(abfd, bfd_arch_bits_per_byte(abfd));
+  ieee_write_byte(abfd, (bfd_byte) (bfd_arch_bits_per_byte(abfd)));
   /* MAU's per address */
-  ieee_write_byte(abfd, bfd_arch_bits_per_address(abfd)  /
-                 bfd_arch_bits_per_byte(abfd));
-
+  ieee_write_byte(abfd,
+   (bfd_byte) (bfd_arch_bits_per_address(abfd) / bfd_arch_bits_per_byte(abfd)));
 
   old = bfd_tell(abfd);
-  bfd_seek(abfd, 8 * N_W_VARIABLES, 1);
-
+  bfd_seek(abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR);
 
   ieee->w.r.extension_record = bfd_tell(abfd);
   bfd_write((char *)exten, 1, sizeof(exten), abfd);
@@ -2761,11 +2786,11 @@ DEFUN(ieee_write_object_contents,(abfd),
 
 
   /* Generate the header */
-  bfd_seek(abfd, old, false);
+  bfd_seek(abfd, old, SEEK_SET);
 
   for (i= 0; i < N_W_VARIABLES; i++) {
     ieee_write_2bytes(abfd,ieee_assign_value_to_variable_enum);
-    ieee_write_byte(abfd, i);
+    ieee_write_byte(abfd, (bfd_byte) i);
     ieee_write_int5_out(abfd, ieee->w.offset[i]);
   }
   return true;
@@ -2848,7 +2873,7 @@ ieee_generic_stat_arch_elt(abfd, buf)
 bfd *abfd;
 struct stat *buf;
 {
-  ieee_ar_data_type *ar = IEEE_AR_DATA(abfd);
+  ieee_ar_data_type *ar = abfd->my_archive->tdata.ieee_ar_data;
   if (ar == (ieee_ar_data_type *)NULL) {
     bfd_error = invalid_operation;
     return -1;
@@ -2856,7 +2881,7 @@ struct stat *buf;
   else {
     buf->st_size = 0x1;
     buf->st_mode = 0666;
-  return 0;
+    return !    ieee_object_p(abfd);
   }
 }
 static int 
@@ -2942,6 +2967,12 @@ DEFUN(ieee_bfd_debug_info_accumulate,(abfd, section),
 #define ieee_set_arch_mach bfd_default_set_arch_mach
 #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_seclet_link bfd_generic_seclet_link
+#define ieee_bfd_reloc_type_lookup \
+  ((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
+#define ieee_bfd_make_debug_symbol \
+  ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
+
 /*SUPPRESS 460 */
 bfd_target ieee_vec =
 {
@@ -2954,6 +2985,7 @@ bfd_target ieee_vec =
    HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
   ( SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
    |SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+   0,                          /* leading underscore */
   ' ',                         /* ar_pad_char */
   16,                          /* ar_max_namelen */
     1,                         /* minimum alignment */
@@ -2977,5 +3009,7 @@ _do_getb64, _do_putb64,  _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs
     _bfd_write_archive_contents,
     bfd_false,
   },
-  JUMP_TABLE(ieee)
+  JUMP_TABLE(ieee),
+  (PTR) 0
 };
+
This page took 0.032967 seconds and 4 git commands to generate.