Lint
[deliverable/binutils-gdb.git] / bfd / ieee.c
index b433027bc35463d5e490b7d87e33fa909fc6cffe..11214225ba4a9a8557e8ee20c6a2ed5b0caa8da1 100644 (file)
@@ -185,73 +185,81 @@ DEFUN(read_id,(ieee),
 }
 
 static void
-DEFUN(ieee_write_expression,(abfd, value, section, symbol, pcrel, index),
+DEFUN(ieee_write_expression,(abfd, value, symbol, pcrel, index),
       bfd*abfd AND
       bfd_vma value AND
-      asection *section AND
       asymbol *symbol AND
       boolean pcrel AND
     unsigned int index)
 {
-  unsigned int plus_count = 0;
-  if (value != 0)
-    ieee_write_int(abfd, value);
+  unsigned int term_count = 0;
 
-  if (section != (asection *)NULL) {
-    plus_count++;
-    ieee_write_byte(abfd, ieee_variable_R_enum);
-    ieee_write_byte(abfd, section->index  +IEEE_SECTION_NUMBER_BASE);
+  if (value != 0) 
+  {
+    ieee_write_int(abfd, value);
+    term_count++;
   }
+  
+     
 
-
-
-  if (symbol != (asymbol *)NULL) {
-    plus_count++;
-    if ((symbol->flags & BSF_UNDEFINED ) ||
-       (symbol->flags & BSF_FORT_COMM)) {
-      ieee_write_byte(abfd, ieee_variable_X_enum);
-      ieee_write_int(abfd, symbol->value);
-    }
-    else if (symbol->flags & BSF_GLOBAL) {
+  if (symbol->section == &bfd_com_section
+      || symbol->section == &bfd_und_section) 
+  {
+    /* Def of a common symbol */
+    ieee_write_byte(abfd, ieee_variable_X_enum);
+    ieee_write_int(abfd, symbol->value);
+    term_count++;
+  }
+  else  if (symbol->section != &bfd_abs_section) 
+  {
+    /* Ref to defined symbol - */
+  
+    ieee_write_byte(abfd, ieee_variable_R_enum);
+    ieee_write_byte(abfd, symbol->section->index + IEEE_SECTION_NUMBER_BASE);
+    term_count++;
+    if (symbol->flags & BSF_GLOBAL) 
+    {
       ieee_write_byte(abfd, ieee_variable_I_enum);
       ieee_write_int(abfd, symbol->value);
+      term_count++;
     }
-    else if (symbol->flags & BSF_LOCAL) {
+    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 (symbol->section != (asection *)NULL) {
-       /* If this symbol is not absolute, add the base of it */
-       ieee_write_byte(abfd, ieee_variable_R_enum); /* or L */
-       ieee_write_byte(abfd, symbol->section->index +
-                       IEEE_SECTION_NUMBER_BASE);
-       plus_count++;
-      }
-      
+      ieee_write_byte(abfd, ieee_variable_R_enum); /* or L */
+      ieee_write_byte(abfd, symbol->section->index +
+                     IEEE_SECTION_NUMBER_BASE);
       ieee_write_int(abfd, symbol->value);
-    }
-    else {
+      term_count++;
 
-      BFD_FAIL();
     }
+    else   {
+       BFD_FAIL();
+      }
+
   }
 
+  
   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, ieee_function_minus_enum);
+      /* 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, ieee_function_minus_enum);
+    }
+
+  if (term_count == 1) 
+  {
+    ieee_write_byte(abfd,0);
   }
+  else {    
+      while (term_count > 1) {
+         ieee_write_byte(abfd, ieee_function_plus_enum);
+         term_count--;
+       }
 
-  if (value != 0){
-    while (plus_count > 0) {
-      ieee_write_byte(abfd, ieee_function_plus_enum);
-      plus_count--;
     }
-  }
-  else {
-    if (!plus_count)
-      ieee_write_byte(abfd,0);
-  }
 
 }
 
@@ -262,7 +270,6 @@ DEFUN(ieee_write_expression,(abfd, value, section, symbol, pcrel, index),
 
 
 
-
 /*****************************************************************************/
 
 /*
@@ -369,10 +376,9 @@ static ieee_symbol_index_type NOSYMBOL = {  0, 0};
 
 
 static void
-DEFUN(parse_expression,(ieee, value, section, symbol, pcrel, extra),
+DEFUN(parse_expression,(ieee, value, symbol, pcrel, extra),
       ieee_data_type *ieee AND
       bfd_vma *value AND
-      asection **section AND
       ieee_symbol_index_type *symbol AND
       boolean *pcrel AND
       unsigned int *extra)
@@ -384,6 +390,7 @@ DEFUN(parse_expression,(ieee, value, section, symbol, pcrel, extra),
 #define INC sp++;
 #define DEC sp--;
 
+  
   boolean loop = true;
   ieee_value_type stack[10];
 
@@ -402,7 +409,7 @@ DEFUN(parse_expression,(ieee, value, section, symbol, pcrel, extra),
              next_byte(&(ieee->h));
              *pcrel = true;
              section_n  = must_parse_int(&(ieee->h));
-             PUSH(NOSYMBOL, 0,
+             PUSH(NOSYMBOL, &bfd_abs_section,
                   TOS.value = ieee->section_table[section_n]->vma +
                   ieee_per_section(ieee->section_table[section_n])->pc);
              break;
@@ -423,7 +430,7 @@ DEFUN(parse_expression,(ieee, value, section, symbol, pcrel, extra),
          next_byte(&(ieee->h));
          PUSH(NOSYMBOL,
               0,
-              ieee->section_table[must_parse_int(&(ieee->h))]->size);
+              ieee->section_table[must_parse_int(&(ieee->h))]->_raw_size);
          break;
          case ieee_variable_I_enum:
        case ieee_variable_X_enum:
@@ -434,7 +441,7 @@ DEFUN(parse_expression,(ieee, value, section, symbol, pcrel, extra),
              sy.index  = (int)(must_parse_int(&(ieee->h))) ;
              sy.letter = 'X';
 
-             PUSH(sy, 0, 0);
+             PUSH(sy, &bfd_und_section, 0);
            }   
          break;
        case ieee_function_minus_enum:
@@ -470,7 +477,7 @@ DEFUN(parse_expression,(ieee, value, section, symbol, pcrel, extra),
                         || this_byte(&(ieee->h)) > (int)ieee_variable_Z_enum);
              if (parse_int(&(ieee->h), &va)) 
                  {
-                   PUSH(NOSYMBOL,0, va);
+                   PUSH(NOSYMBOL, &bfd_abs_section, va);
                  }
              else {
                /* 
@@ -488,8 +495,12 @@ DEFUN(parse_expression,(ieee, value, section, symbol, pcrel, extra),
                  ieee_symbol_index_type sy1;
                  POP(sy1, section1, *extra);
                }
-
-               POP(*symbol, *section, *value);
+             {
+               asection *dummy;
+               
+               POP(*symbol, dummy, *value);
+             }
+               
                loop = false;
              }
            }
@@ -501,9 +512,9 @@ DEFUN(parse_expression,(ieee, value, section, symbol, pcrel, extra),
 
 
 #define ieee_seek(abfd, offset) \
-  ieee_data(abfd)->h.input_p = ieee_data(abfd)->h.first_byte + offset
+  IEEE_DATA(abfd)->h.input_p = IEEE_DATA(abfd)->h.first_byte + offset
 
-#define ieee_pos(abfd)   ieee_data(abfd)->h.input_p -ieee_data(abfd)->h.first_byte 
+#define ieee_pos(abfd)   IEEE_DATA(abfd)->h.input_p -IEEE_DATA(abfd)->h.first_byte 
 
 static unsigned int last_index;
 
@@ -545,7 +556,7 @@ static void
 DEFUN(ieee_slurp_external_symbols,(abfd),
       bfd *abfd)
 {
-  ieee_data_type *ieee = ieee_data(abfd);
+  ieee_data_type *ieee = IEEE_DATA(abfd);
   file_ptr offset = ieee->w.r.external_part;
 
 
@@ -632,12 +643,9 @@ DEFUN(ieee_slurp_external_symbols,(abfd),
                           &symbol_ignore, 
                           &pcrel_ignore, 
                           &extra);
-         if (symbol->symbol.section != (asection *)NULL) {
+
            symbol->symbol.flags  = BSF_GLOBAL | BSF_EXPORT;
-         }
-         else {
-           symbol->symbol.flags  = BSF_GLOBAL | BSF_EXPORT | BSF_ABSOLUTE;
-         }
+
        }
       break;
     case ieee_weak_external_reference_enum:
@@ -653,7 +661,7 @@ DEFUN(ieee_slurp_external_symbols,(abfd),
            value = 0;
          }
          /* This turns into a common */
-         symbol->symbol.flags = BSF_FORT_COMM;
+         symbol->symbol.section = &bfd_com_section;
          symbol->symbol.value = size;
        }
       break;
@@ -669,9 +677,9 @@ DEFUN(ieee_slurp_external_symbols,(abfd),
       symbol->symbol.the_bfd = abfd;
       symbol->symbol.name = read_id(&(ieee->h));
       symbol->symbol.udata = (PTR)NULL;
-      symbol->symbol.section = (asection *)NULL;
+      symbol->symbol.section = &bfd_und_section;
       symbol->symbol.value = (bfd_vma)0;
-      symbol->symbol.flags = BSF_UNDEFINED;
+      symbol->symbol.flags =  0;
 
       BFD_ASSERT (symbol->index >= ieee->external_reference_min_index);
       break;
@@ -717,9 +725,9 @@ static void
 DEFUN(ieee_slurp_symbol_table,(abfd),
       bfd *abfd)
 {
-  if (ieee_data(abfd)->read_symbols == false) {
+  if (IEEE_DATA(abfd)->read_symbols == false) {
     ieee_slurp_external_symbols(abfd);
-    ieee_data(abfd)->read_symbols= true;
+    IEEE_DATA(abfd)->read_symbols= true;
   }
 }
 
@@ -747,14 +755,14 @@ 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 | BSF_ABSOLUTE};
+    { &dummy_bfd," ieee empty",(symvalue)0,BSF_DEBUGGING , &bfd_abs_section};
 
 if (abfd->symcount) {
 
 
 
 
-  ieee_data_type *ieee = ieee_data(abfd);
+  ieee_data_type *ieee = IEEE_DATA(abfd);
   dummy_bfd.xvec= &ieee_vec;
   ieee_slurp_symbol_table(abfd);
 
@@ -769,7 +777,7 @@ if (abfd->symcount) {
 
 
   ieee->external_symbol_base_offset= -  ieee->external_symbol_min_index;
-  for (symp = ieee_data(abfd)->external_symbols;
+  for (symp = IEEE_DATA(abfd)->external_symbols;
        symp != (ieee_symbol_type *)NULL;
        symp = symp->next) {
     /* Place into table at correct index locations */
@@ -781,7 +789,7 @@ if (abfd->symcount) {
   ieee->external_reference_base_offset   =
     -  ieee->external_reference_min_index +ieee->external_symbol_count ;
 
-  for (symp = ieee_data(abfd)->external_reference;
+  for (symp = IEEE_DATA(abfd)->external_reference;
        symp != (ieee_symbol_type *)NULL;
        symp = symp->next) {
     location[symp->index + ieee->external_reference_base_offset] =
@@ -815,7 +823,7 @@ static void
 DEFUN(ieee_slurp_sections,(abfd),
       bfd *abfd)
 {
-  ieee_data_type *ieee = ieee_data(abfd);
+  ieee_data_type *ieee = IEEE_DATA(abfd);
   file_ptr offset = ieee->w.r.section_part;
 
   asection *section = (asection *)NULL;
@@ -923,11 +931,11 @@ DEFUN(ieee_slurp_sections,(abfd),
            switch (t) {
            case ieee_section_size_enum:
              section = ieee->section_table[must_parse_int(&(ieee->h))];
-             section->size = must_parse_int(&(ieee->h));
+             section->_raw_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));
+             section->_raw_size = must_parse_int(&(ieee->h));
              break;
            case ieee_region_base_address_enum:
              section = ieee->section_table[must_parse_int(&(ieee->h))];
@@ -975,10 +983,10 @@ DEFUN(ieee_archive_p,(abfd),
 uint8e_type buffer[512];
 
   int buffer_offset = 0;
-  ieee_ar_data_type *save = ieee_ar_data(abfd);
+  ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
   ieee_ar_data_type *ieee ;
-  set_tdata(abfd, bfd_alloc(abfd, sizeof(ieee_ar_data_type)));
-  ieee=  ieee_ar_data(abfd);
+  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);
@@ -988,13 +996,17 @@ uint8e_type buffer[512];
 
   ieee->h.abfd = abfd;
 
-  if (this_byte(&(ieee->h)) != Module_Beginning) return (bfd_target*)NULL;
+  if (this_byte(&(ieee->h)) != Module_Beginning) {
+    abfd->tdata.ieee_ar_data = save;
+      return (bfd_target*)NULL;
+    }
+  
 
   next_byte(&(ieee->h));
   library= read_id(&(ieee->h));
   if (strcmp(library , "LIBRARY") != 0) {
     bfd_release(abfd, ieee);
-    set_tdata (abfd, save);
+    abfd->tdata.ieee_ar_data = save;
     return (bfd_target *)NULL;
   }
   /* Throw away the filename */
@@ -1066,7 +1078,7 @@ static boolean
 DEFUN(ieee_mkobject,(abfd),
       bfd *abfd)
 { 
-  set_tdata (abfd, bfd_zalloc(abfd,sizeof(ieee_data_type)));
+abfd->tdata.ieee_data = (ieee_data_type *)bfd_zalloc(abfd,sizeof(ieee_data_type));
   
 
   return true;
@@ -1080,10 +1092,10 @@ DEFUN(ieee_object_p,(abfd),
   unsigned int part;
   ieee_data_type *ieee;
   uint8e_type buffer[300];
-  ieee_data_type *save = ieee_data(abfd);
-  set_tdata (abfd, 0);
+  ieee_data_type *save = IEEE_DATA(abfd);
+  abfd->tdata.ieee_data = 0;
   ieee_mkobject(abfd);
-  ieee = ieee_data(abfd);
+  ieee = IEEE_DATA(abfd);
   
   /* Read the first few bytes in to see if it makes sense */
   bfd_read((PTR)buffer, 1, sizeof(buffer), abfd);
@@ -1104,7 +1116,7 @@ DEFUN(ieee_object_p,(abfd),
   processor = ieee->mb.processor = read_id(&(ieee->h));
   if (strcmp(processor,"LIBRARY") == 0) goto fail;
   ieee->mb.module_name = read_id(&(ieee->h));
-  if (abfd->filename == (char *)NULL) {
+  if (abfd->filename == (CONST char *)NULL) {
     abfd->filename =  ieee->mb.module_name;
   }
   /* Determine the architecture and machine type of the object file.
@@ -1155,16 +1167,16 @@ DEFUN(ieee_object_p,(abfd),
    quickly. We can work out how big the file is from the trailer
    record */
 
-  ieee_data(abfd)->h.first_byte = (uint8e_type *) bfd_alloc(ieee->h.abfd, ieee->w.r.me_record
+  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_read((PTR)(ieee_data(abfd)->h.first_byte), 1,   ieee->w.r.me_record+50,  abfd);
+  bfd_read((PTR)(IEEE_DATA(abfd)->h.first_byte), 1,   ieee->w.r.me_record+50,  abfd);
 
   ieee_slurp_sections(abfd);
   return abfd->xvec;
  fail:
   (void)  bfd_release(abfd, ieee);
-  set_tdata (abfd, save);
+abfd->tdata.ieee_data = save;
   return (bfd_target *)NULL;
 }
 
@@ -1189,10 +1201,11 @@ DEFUN(ieee_print_symbol,(ignore_abfd, afile,  symbol, how),
 #endif
     BFD_FAIL();
     break;
+  case bfd_print_symbol_nm:
   case bfd_print_symbol_all:
       {
        CONST char *section_name = symbol->section == (asection *)NULL ?
-         "*abs" : symbol->section->name;
+         (CONST char *)"*abs" : symbol->section->name;
        if (symbol->name[0] == ' ') {
          fprintf(file,"* empty table entry ");
        }
@@ -1252,7 +1265,7 @@ DEFUN(do_one,(ieee, current_map, location_ptr,s),
                          {
                            unsigned int extra = 4;
                            boolean pcrel = false;
-
+asection *section;
                            ieee_reloc_type *r = 
                              (ieee_reloc_type *) bfd_alloc(ieee->h.abfd,
                                                            sizeof(ieee_reloc_type));
@@ -1261,13 +1274,18 @@ DEFUN(do_one,(ieee, current_map, location_ptr,s),
                            current_map->reloc_tail_ptr= &r->next;
                            r->next = (ieee_reloc_type *)NULL;
                            next_byte(&(ieee->h));
+/*                         abort();*/
+                           
                            parse_expression(ieee,
                                             &r->relent.addend,
-                                            &r->relent.section,
+                                            &section,
                                             &r->symbol,
                                             &pcrel, &extra);
                            r->relent.address = current_map->pc;
                            s->reloc_count++;
+if (r->relent.sym_ptr_ptr == 0) {
+                            r->relent.sym_ptr_ptr = section->symbol_ptr_ptr;
+}                          
 
                            if (this_byte(&(ieee->h)) == (int)ieee_comma) {
                              next_byte(&(ieee->h));
@@ -1393,7 +1411,7 @@ DEFUN(ieee_slurp_section_data,(abfd),
       bfd *abfd)
 {
   bfd_byte *location_ptr = (bfd_byte *)NULL;
-  ieee_data_type *ieee = ieee_data(abfd);
+  ieee_data_type *ieee = IEEE_DATA(abfd);
   unsigned int section_number ;
 
   ieee_per_section_type *current_map = (ieee_per_section_type *)NULL;
@@ -1408,7 +1426,7 @@ DEFUN(ieee_slurp_section_data,(abfd),
 
   for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
     ieee_per_section_type *per = (ieee_per_section_type *) s->used_by_bfd;
-    per->data = (bfd_byte *) bfd_alloc(ieee->h.abfd, s->size);
+    per->data = (bfd_byte *) bfd_alloc(ieee->h.abfd, s->_raw_size);
     /*SUPPRESS 68*/
     per->reloc_tail_ptr =
       (ieee_reloc_type **)&(s->relocation);
@@ -1449,10 +1467,12 @@ DEFUN(ieee_slurp_section_data,(abfd),
                    boolean pcrel;
                    next_byte(&(ieee->h));
                    must_parse_int(&(ieee->h)); /* Thow away section #*/
-                   parse_expression(ieee, &value, &dsection, &symbol,
+                   parse_expression(ieee, &value,
+                                     &dsection, 
+                                    &symbol,
                                     &pcrel, &extra);
                    current_map->pc = value;
-                   BFD_ASSERT((unsigned)(value - s->vma) <= s->size);
+                   BFD_ASSERT((unsigned)(value - s->vma) <= s->_raw_size);
                  }
                break;
 
@@ -1555,7 +1575,7 @@ DEFUN(ieee_canonicalize_reloc,(abfd, section, relptr, symbols),
 {
 /*  ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/
   ieee_reloc_type *src = (ieee_reloc_type *)(section->relocation);
-  ieee_data_type *ieee = ieee_data(abfd);
+  ieee_data_type *ieee = IEEE_DATA(abfd);
 
   while (src != (ieee_reloc_type *)NULL) {
     /* Work out which symbol to attach it this reloc to */
@@ -1565,7 +1585,7 @@ 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 = (asymbol **)NULL;
+      src->relent.sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
       break;
     default:
 
@@ -1598,25 +1618,28 @@ static void
 DEFUN(ieee_write_section_part,(abfd),
       bfd *abfd)
 {
-  ieee_data_type *ieee = ieee_data(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) {
-    ieee_write_byte(abfd, ieee_section_type_enum);
-    ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+      if (s != &bfd_abs_section) 
+      {
+       
+       ieee_write_byte(abfd, ieee_section_type_enum);
+       ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
 
-    if (abfd->flags & EXEC_P) 
+       if (abfd->flags & EXEC_P) 
        {
          /* This image is executable, so output absolute sections */
          ieee_write_byte(abfd, ieee_variable_A_enum);
          ieee_write_byte(abfd, ieee_variable_S_enum);
        }
-    else  
+       else  
        {
          ieee_write_byte(abfd, ieee_variable_C_enum);
        }
 
-    switch (s->flags &(SEC_CODE | SEC_DATA | SEC_ROM)) 
+       switch (s->flags &(SEC_CODE | SEC_DATA | SEC_ROM)) 
        {
        case SEC_CODE | SEC_LOAD:
        case SEC_CODE:
@@ -1635,30 +1658,31 @@ DEFUN(ieee_write_section_part,(abfd),
        }
 
 
-    ieee_write_id(abfd, s->name);
+       ieee_write_id(abfd, s->name);
 #if 0
-    ieee_write_int(abfd, 0);   /* Parent */
-    ieee_write_int(abfd, 0);   /* Brother */
-    ieee_write_int(abfd, 0);   /* Context */
+       ieee_write_int(abfd, 0); /* Parent */
+       ieee_write_int(abfd, 0); /* Brother */
+       ieee_write_int(abfd, 0); /* Context */
 #endif
-    /* Alignment */
-    ieee_write_byte(abfd, ieee_section_alignment_enum);
-    ieee_write_byte(abfd, 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_int(abfd, s->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_int(abfd, s->vma);
+       /* Alignment */
+       ieee_write_byte(abfd, ieee_section_alignment_enum);
+       ieee_write_byte(abfd, 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_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_int(abfd, s->vma);
+         }
+      }
+      
     }
-
-  }
 }
 
 
@@ -1687,19 +1711,19 @@ DEFUN(do_with_relocs,(abfd, s),
 
   ieee_write_twobyte(abfd, ieee_set_current_pc_enum);
   ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
-  ieee_write_expression(abfd, 0, s, 0, 0, 0);
+  ieee_write_expression(abfd, 0, s->symbol, 0, 0);
 
   if (relocs_to_go == 0) 
       {
        /* If there arn't any relocations then output the load constant byte
           opcode rather than the load with relocation opcode */
 
-       while (current_byte_index < s->size) {
+       while (current_byte_index < s->_raw_size) {
          bfd_size_type run;
          unsigned int MAXRUN  = 32;
          run = MAXRUN;
-         if (run > s->size - current_byte_index) {
-           run = s->size - current_byte_index;
+         if (run > s->_raw_size - current_byte_index) {
+           run = s->_raw_size - current_byte_index;
          }
 
          if (run != 0) {
@@ -1725,10 +1749,10 @@ DEFUN(do_with_relocs,(abfd, s),
 
        if ((PTR)stream == (PTR)NULL) {
          /* Outputting a section without data, fill it up */
-         stream = (uint8e_type *)(bfd_alloc(abfd, s->size));
-         memset((PTR)stream, 0, s->size);
+         stream = (uint8e_type *)(bfd_alloc(abfd, s->_raw_size));
+         memset((PTR)stream, 0, s->_raw_size);
        }
-       while (current_byte_index < s->size) {
+       while (current_byte_index < s->_raw_size) {
          bfd_size_type run;
          unsigned int MAXRUN = 32;
          if (relocs_to_go) {
@@ -1737,8 +1761,8 @@ DEFUN(do_with_relocs,(abfd, s),
          else {
            run = MAXRUN;
          }
-         if (run > s->size - current_byte_index) {
-           run = s->size - current_byte_index;
+         if (run > s->_raw_size - current_byte_index) {
+           run = s->_raw_size - current_byte_index;
          }
 
          if (run != 0) {
@@ -1785,16 +1809,15 @@ DEFUN(do_with_relocs,(abfd, s),
                BFD_FAIL();
              }
              ieee_write_byte(abfd, ieee_function_either_open_b_enum);
-
+             abort();
+           
              if (r->sym_ptr_ptr != (asymbol **)NULL) {
                ieee_write_expression(abfd, r->addend + ov,
-                                     r->section,
                                      *(r->sym_ptr_ptr),
                                      r->howto->pc_relative, s->index);
              }
              else {
                ieee_write_expression(abfd, r->addend + ov,
-                                     r->section,
                                      (asymbol *)NULL,
                                      r->howto->pc_relative, s->index);
              }
@@ -1832,7 +1855,7 @@ DEFUN(do_as_repeat, (abfd, s),
   ieee_write_int(abfd,  s->vma );
 
   ieee_write_byte(abfd,ieee_repeat_data_enum);
-  ieee_write_int(abfd, s->size);
+  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);
@@ -1852,7 +1875,7 @@ DEFUN(do_without_relocs, (abfd, s),
   else 
       {
        unsigned int i;
-       for (i = 0; i < s->size; i++) {
+       for (i = 0; i < s->_raw_size; i++) {
          if (stream[i] != 0) {
            do_with_relocs(abfd, s);
            return;
@@ -2003,7 +2026,7 @@ NEXT();
          section_number = THIS();
        
          NEXT();
-         ieee= ieee_data(input_bfd);
+         ieee= IEEE_DATA(input_bfd);
          s =   ieee->section_table[section_number];
          if (s->output_section) {
            value = s->output_section->vma ;
@@ -2386,7 +2409,7 @@ static void
 DEFUN(ieee_write_debug_part, (abfd),
       bfd *abfd)
 {
-  ieee_data_type *ieee = ieee_data(abfd);
+  ieee_data_type *ieee = IEEE_DATA(abfd);
   bfd_chain_type *chain = ieee->chain_root;
   unsigned char output_buffer[OBS];
   boolean some_debug = false;
@@ -2398,58 +2421,66 @@ DEFUN(ieee_write_debug_part, (abfd),
   output_bfd = abfd;
 
   if (chain == (bfd_chain_type *)NULL) {
-    /* There is no debug info, so we'll fake some up */
-    CONST static char fake[] = {
-      0xf8, 0xa, 0, 5, 't', 't', 't', 't', 't', 0, 2, 3,
-      '1','.','1',0x82, 1991>>8, 1991 & 0xff, 9, 20, 11, 07,50 };
-    ieee->w.r.debug_information_part = 0;
-
 #if 0
-here;
+      /* There is no debug info, so we'll fake some up */
+      CONST static char fake[] = {
+         0xf8, 0xa, 0, 5, 't', 't', 't', 't', 't', 0, 2, 3,
+         '1','.','1',0x82, 1991>>8, 1991 & 0xff, 9, 20, 11, 07,50 };
+      ieee->w.r.debug_information_part = 0;
 
 
-/*    bfd_write(fake, 1, sizeof(fake), abfd);*/
-    /* Now write a header for each section */
-      {
-       int i = 0;
-       asection *s = abfd->sections;
-       while (s) {
-         ieee_write_byte(abfd, 0xf8);  
-         ieee_write_byte(abfd, 0x0b);
-         ieee_write_byte(abfd, 0);
-         ieee_write_byte(abfd, 0);
-         ieee_write_byte(abfd, 1);
-         ieee_write_byte(abfd, i + IEEE_SECTION_NUMBER_BASE);
-         ieee_write_expression(abfd, 0, s, 0, 0, 0);
-         ieee_write_byte(abfd,0);
-         ieee_write_byte(abfd, 0xf9);
-         ieee_write_expression(abfd, s->size, 0, 0, 0, 0);     
+      here;
+
+
+      /*    bfd_write(fake, 1, sizeof(fake), abfd);*/
+      /* Now write a header for each section */
+    {
+      int i = 0;
+      asection *s = abfd->sections;
+      while (s) {
+         if (s != abfd->abs_section) 
+         {
+             
+           ieee_write_byte(abfd, 0xf8);        
+           ieee_write_byte(abfd, 0x0b);
+           ieee_write_byte(abfd, 0);
+           ieee_write_byte(abfd, 0);
+           ieee_write_byte(abfd, 1);
+           ieee_write_byte(abfd, i + IEEE_SECTION_NUMBER_BASE);
+           ieee_write_expression(abfd, 0, s->symbol, 0, 0, 0);
+           ieee_write_byte(abfd,0);
+           ieee_write_byte(abfd, 0xf9);
+           ieee_write_expression(abfd, s->size,
+                                 bfd_abs_section.symbol, 0, 0, 0);     
+           i++;
+         }
+           
          s = s->next;
-         i++;
+
        }       
-       /* Close the scope */
-       ieee_write_byte(abfd, 0xf9);
-      }
+      /* Close the scope */
+      ieee_write_byte(abfd, 0xf9);
+    }
 #endif
-  }
+    }
   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) {
-       bfd_seek(entry, entry_ieee->w.r.debug_information_part, SEEK_SET);
-       relocate_debug(abfd, entry);
-      }
+      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) {
+             bfd_seek(entry, entry_ieee->w.r.debug_information_part, SEEK_SET);
+             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;
+         chain = chain->next;
+       }
+      if (some_debug) {
+         ieee->w.r.debug_information_part = here;
+       }
+      else {
+         ieee->w.r.debug_information_part = 0;
+       }
     }
-  }
   flush();
 
 }  
@@ -2459,7 +2490,7 @@ DEFUN(ieee_write_data_part,(abfd),
       bfd *abfd)
 {
   asection *s;
-  ieee_data_type *ieee = ieee_data(abfd);
+  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) 
       {
@@ -2484,8 +2515,8 @@ DEFUN(init_for_output,(abfd),
 {
   asection *s; 
   for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
-    if (s->size != 0) {
-      ieee_per_section(s)->data = (bfd_byte *)(bfd_alloc(abfd, s->size));
+    if (s->_raw_size != 0) {
+      ieee_per_section(s)->data = (bfd_byte *)(bfd_alloc(abfd, s->_raw_size));
     }
   }
 }
@@ -2523,7 +2554,7 @@ DEFUN(ieee_write_external_part,(abfd),
       bfd *abfd)
 {
   asymbol **q;
-  ieee_data_type *ieee = ieee_data(abfd);
+  ieee_data_type *ieee = IEEE_DATA(abfd);
 
   unsigned int reference_index = IEEE_REFERENCE_BASE;
   unsigned int public_index = IEEE_PUBLIC_BASE+2;
@@ -2534,7 +2565,7 @@ DEFUN(ieee_write_external_part,(abfd),
     for (q = abfd->outsymbols; *q  != (asymbol *)NULL; q++) {
       asymbol *p = *q;
       hadone = true;
-      if (p->flags & BSF_UNDEFINED) {
+      if (p->section == &bfd_und_section) {
        /* This must be a symbol reference .. */
        ieee_write_byte(abfd, ieee_external_reference_enum);
        ieee_write_int(abfd, reference_index);
@@ -2542,7 +2573,7 @@ DEFUN(ieee_write_external_part,(abfd),
        p->value = reference_index;
        reference_index++;
       }
-      else if(p->flags & BSF_FORT_COMM) {
+      else if(p->section == &bfd_com_section) {
        /* This is a weak reference */
        ieee_write_byte(abfd, ieee_external_reference_enum);
        ieee_write_int(abfd, reference_index);
@@ -2572,29 +2603,29 @@ DEFUN(ieee_write_external_part,(abfd),
        /* Write out the value */
        ieee_write_2bytes(abfd, ieee_value_record_enum);
        ieee_write_int(abfd, public_index);
-       if (p->section != (asection *)NULL)
+       if (p->section != &bfd_abs_section)
            {
              if (abfd->flags & EXEC_P) 
-                 {
-                   /* If fully linked, then output all symbols
-                      relocated */
-                   ieee_write_int(abfd,
-                                  p->value + p->section->output_offset+ p->section->output_section->vma);
+             {
+               /* If fully linked, then output all symbols
+                  relocated */
+               ieee_write_int(abfd,
+                              p->value + p->section->output_offset+ p->section->output_section->vma);
 
-                 }
-             else { 
-               ieee_write_expression(abfd,
-                                     p->value + p->section->output_offset,
-                                     p->section->output_section,
-                                     (asymbol *)NULL, false, 0);
              }
+             else { 
+                 ieee_write_expression(abfd,
+                                       p->value + p->section->output_offset,
+                                       p->section->output_section->symbol
+                                       , false, 0);
+               }
            }
        else
            {
              ieee_write_expression(abfd,
                                    p->value,
-                                   (asection *)NULL,
-                                   (asymbol *)NULL, false, 0);
+                                   bfd_abs_section.symbol,
+                                   false, 0);
            }
        p->value = public_index;
        public_index++;
@@ -2611,7 +2642,7 @@ DEFUN(ieee_write_external_part,(abfd),
 }
 
 
-CONST static char exten[] = 
+CONST static unsigned char exten[] = 
   {
     0xf0, 0x20, 0x00,                                  
     0xf1, 0xce, 0x20, 0x00, 37, 3, 3,  /* Set version 3 rev 3          */
@@ -2619,7 +2650,7 @@ CONST static char exten[] =
     0xf1, 0xce, 0x20, 0x00, 38         /* set object type relocateable to x */
   };
 
-CONST static char environ[] =
+CONST static unsigned char envi[] =
   {
     0xf0, 0x21, 0x00,
 
@@ -2637,7 +2668,7 @@ void
 DEFUN(ieee_write_me_part,(abfd),
       bfd *abfd)
 {
-  ieee_data_type *ieee= ieee_data(abfd);
+  ieee_data_type *ieee= IEEE_DATA(abfd);
   ieee->w.r.trailer_part = bfd_tell(abfd);
   if (abfd->start_address) {
     ieee->w.r.me_record = bfd_tell(abfd);
@@ -2656,7 +2687,7 @@ boolean
 DEFUN(ieee_write_object_contents,(abfd),
       bfd *abfd)
 {
-  ieee_data_type *ieee = ieee_data(abfd);
+  ieee_data_type *ieee = IEEE_DATA(abfd);
   unsigned int i;
   file_ptr   old;
   /* Fast forward over the header area */
@@ -2687,14 +2718,14 @@ DEFUN(ieee_write_object_contents,(abfd),
 
 
   ieee->w.r.extension_record = bfd_tell(abfd);
-  bfd_write(exten, 1, sizeof(exten), abfd);
+  bfd_write((char *)exten, 1, sizeof(exten), abfd);
   if (abfd->flags & EXEC_P) 
     ieee_write_byte(abfd, 0x1); /* Absolute */
   else 
     ieee_write_byte(abfd, 0x2); /* Relocateable */    
   
   ieee->w.r.environmental_record = bfd_tell(abfd);
-  bfd_write(environ, 1, sizeof(environ), abfd);
+  bfd_write((char *)envi, 1, sizeof(envi), abfd);
   output_bfd = abfd;
   flush();
 
@@ -2766,7 +2797,7 @@ DEFUN(ieee_openr_next_archived_file,(arch, prev),
       bfd *arch AND
       bfd *prev)
 {
-  ieee_ar_data_type *ar = ieee_ar_data(arch);
+  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*/
@@ -2817,7 +2848,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 = IEEE_AR_DATA(abfd);
   if (ar == (ieee_ar_data_type *)NULL) {
     bfd_error = invalid_operation;
     return -1;
@@ -2861,8 +2892,8 @@ DEFUN(ieee_bfd_debug_info_accumulate,(abfd, section),
       bfd *abfd AND
       asection *section)
 {
-  ieee_data_type *ieee = ieee_data(section->owner);
-  ieee_data_type *output_ieee = ieee_data(abfd);
+  ieee_data_type *ieee = IEEE_DATA(section->owner);
+  ieee_data_type *output_ieee = IEEE_DATA(abfd);
   /* can only accumulate data from other ieee bfds */
   if (section->owner->xvec != abfd->xvec)
     return;
@@ -2909,7 +2940,8 @@ DEFUN(ieee_bfd_debug_info_accumulate,(abfd, section),
 #define ieee_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr
 #define        ieee_close_and_cleanup          bfd_generic_close_and_cleanup
 #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
 /*SUPPRESS 460 */
 bfd_target ieee_vec =
 {
@@ -2920,7 +2952,7 @@ bfd_target ieee_vec =
   (HAS_RELOC | EXEC_P |                /* object flags */
    HAS_LINENO | HAS_DEBUG |
    HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
-  (SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
+  ( SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
    |SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
   ' ',                         /* ar_pad_char */
   16,                          /* ar_max_namelen */
This page took 0.037018 seconds and 4 git commands to generate.