Add prototypes for static functions.
[binutils-gdb.git] / bfd / evax-etir.c
index b9c53bc5ddf9ee5ff621ba914a4b3e887e0bac31..3f7339b8fbdb9e168dc97f0ff7156b10b515b025 100644 (file)
@@ -1,11 +1,11 @@
-/* evax-etir.c -- BFD back-end for ALPHA EVAX (openVMS/AXP) files.
-   Copyright 1996 Free Software Foundation, Inc.
+/* evax-etir.c -- BFD back-end for ALPHA EVAX (openVMS/Alpha) files.
+   Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
    ETIR record handling functions
 
    go and read the openVMS linker manual (esp. appendix B)
    if you don't know what's going on here :-)
 
-   Written by Klaus Kรคmpf (kkaempf@progis.de)
+   Written by Klaus K"ampf (kkaempf@progis.de)
    of proGIS Softwareentwicklung, Aachen, Germany
 
 This program is free software; you can redistribute it and/or modify
@@ -32,7 +32,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
        qw      quadword (8 byte, 64 bit)
        da      data stream  */
 
-#include <stdio.h>
 #include <ctype.h>
 
 #include "bfd.h"
@@ -300,7 +299,7 @@ etir_sta (abfd, cmd, ptr)
          psect = bfd_getl32 (ptr);
          if (psect >= PRIV(egsd_sec_count))
            {
-             (*_bfd_error_handler) ("Bad section index in ETIR_S_C_STA_PQ");
+             (*_bfd_error_handler) (_("Bad section index in ETIR_S_C_STA_PQ"));
              bfd_set_error (bfd_error_bad_value);
              return false;
            }
@@ -315,12 +314,12 @@ etir_sta (abfd, cmd, ptr)
       case ETIR_S_C_STA_MOD:
       case ETIR_S_C_STA_CKARG:
 
-       (*_bfd_error_handler) ("Unsupported STA cmd %d", cmd);
+       (*_bfd_error_handler) (_("Unsupported STA cmd %d"), cmd);
        return false;
       break;
 
       default:
-       (*_bfd_error_handler) ("Reserved STA cmd %d", cmd);
+       (*_bfd_error_handler) (_("Reserved STA cmd %d"), cmd);
        return false;
       break;
   }
@@ -431,7 +430,7 @@ etir_sto (abfd, cmd, ptr)
        entry = (evax_symbol_entry *)bfd_hash_lookup (PRIV(evax_symbol_table), name, false, false);
        if (entry == (evax_symbol_entry *)NULL)
          {
-           (*_bfd_error_handler) ("ETIR_S_C_STO_GBL: no symbol \"%s\"",
+           (*_bfd_error_handler) (_("ETIR_S_C_STO_GBL: no symbol \"%s\""),
                                   name);
            return false;
          }
@@ -452,7 +451,7 @@ etir_sto (abfd, cmd, ptr)
        entry = (evax_symbol_entry *) bfd_hash_lookup (PRIV(evax_symbol_table), name, false, false);
        if (entry == (evax_symbol_entry *)NULL)
          {
-           (*_bfd_error_handler) ("ETIR_S_C_STO_CA: no symbol \"%s\"",
+           (*_bfd_error_handler) (_("ETIR_S_C_STO_CA: no symbol \"%s\""),
                                   name);
            return false;
          }
@@ -465,7 +464,7 @@ etir_sto (abfd, cmd, ptr)
 
     case ETIR_S_C_STO_RB:
     case ETIR_S_C_STO_AB:
-      (*_bfd_error_handler) ("ETIR_S_C_STO_RB/AB: Not supported");
+      (*_bfd_error_handler) (_("ETIR_S_C_STO_RB/AB: Not supported"));
       break;
 
     /* store offset to psect: pop stack, add low 32 bits to base of psect
@@ -523,23 +522,23 @@ etir_sto (abfd, cmd, ptr)
       /* not supported  */
 
     case ETIR_S_C_STO_LP_PSB:
-      (*_bfd_error_handler) ("ETIR_S_C_STO_LP_PSB: Not supported");
+      (*_bfd_error_handler) (_("ETIR_S_C_STO_LP_PSB: Not supported"));
       break;
 
     /* */
 
     case ETIR_S_C_STO_HINT_GBL:
-      (*_bfd_error_handler) ("ETIR_S_C_STO_HINT_GBL: not implemented");
+      (*_bfd_error_handler) (_("ETIR_S_C_STO_HINT_GBL: not implemented"));
       break;
 
     /* */
 
     case ETIR_S_C_STO_HINT_PS:
-      (*_bfd_error_handler) ("ETIR_S_C_STO_HINT_PS: not implemented");
+      (*_bfd_error_handler) (_("ETIR_S_C_STO_HINT_PS: not implemented"));
       break;
 
     default:
-      (*_bfd_error_handler) ("Reserved STO cmd %d", cmd);
+      (*_bfd_error_handler) (_("Reserved STO cmd %d"), cmd);
       break;
     }
 
@@ -647,7 +646,7 @@ etir_opr (abfd, cmd, ptr)
 
     case ETIR_S_C_OPR_INSV:
       (void)_bfd_evax_pop (abfd, NULL);
-      (*_bfd_error_handler) ("ETIR_S_C_OPR_INSV: Not supported");
+      (*_bfd_error_handler) (_("ETIR_S_C_OPR_INSV: Not supported"));
       break;
 
     /* arithmetic shift  */
@@ -665,13 +664,13 @@ etir_opr (abfd, cmd, ptr)
       /* unsigned shift  */
 
     case ETIR_S_C_OPR_USH:
-      (*_bfd_error_handler) ("ETIR_S_C_OPR_USH: Not supported");
+      (*_bfd_error_handler) (_("ETIR_S_C_OPR_USH: Not supported"));
       break;
 
       /* rotate  */
 
     case ETIR_S_C_OPR_ROT:
-      (*_bfd_error_handler) ("ETIR_S_C_OPR_ROT: Not supported");
+      (*_bfd_error_handler) (_("ETIR_S_C_OPR_ROT: Not supported"));
       break;
 
       /* select  */
@@ -690,17 +689,17 @@ etir_opr (abfd, cmd, ptr)
       /* redefine symbol to current location  */
 
     case ETIR_S_C_OPR_REDEF:
-      (*_bfd_error_handler) ("ETIR_S_C_OPR_REDEF: Not supported");
+      (*_bfd_error_handler) (_("ETIR_S_C_OPR_REDEF: Not supported"));
       break;
 
       /* define a literal  */
 
     case ETIR_S_C_OPR_DFLIT:
-      (*_bfd_error_handler) ("ETIR_S_C_OPR_DFLIT: Not supported");
+      (*_bfd_error_handler) (_("ETIR_S_C_OPR_DFLIT: Not supported"));
       break;
 
     default:
-      (*_bfd_error_handler) ("Reserved OPR cmd %d", cmd);
+      (*_bfd_error_handler) (_("Reserved OPR cmd %d"), cmd);
       break;
     }
 
@@ -764,7 +763,7 @@ etir_ctl (abfd, cmd, ptr)
       break;
 
     default:
-      (*_bfd_error_handler) ("Reserved CTL cmd %d", cmd);
+      (*_bfd_error_handler) (_("Reserved CTL cmd %d"), cmd);
       break;
     }
   return true;
@@ -788,7 +787,7 @@ etir_stc (abfd, cmd, ptr)
         arg:  */
 
     case ETIR_S_C_STC_LP:
-      (*_bfd_error_handler) ("ETIR_S_C_STC_LP: not supported");
+      (*_bfd_error_handler) (_("ETIR_S_C_STC_LP: not supported"));
       break;
 
       /* 201 Store-conditional Linkage Pair with Procedure Signature
@@ -806,7 +805,7 @@ etir_stc (abfd, cmd, ptr)
         cs     global name  */
 
     case ETIR_S_C_STC_GBL:
-      (*_bfd_error_handler) ("ETIR_S_C_STC_GBL: not supported");
+      (*_bfd_error_handler) (_("ETIR_S_C_STC_GBL: not supported"));
       break;
 
       /* 203 Store-conditional Code Address at global address
@@ -814,7 +813,7 @@ etir_stc (abfd, cmd, ptr)
         cs     procedure name  */
 
     case ETIR_S_C_STC_GCA:
-      (*_bfd_error_handler) ("ETIR_S_C_STC_GCA: not supported");
+      (*_bfd_error_handler) (_("ETIR_S_C_STC_GCA: not supported"));
       break;
 
       /* 204 Store-conditional Address at psect + offset
@@ -823,7 +822,7 @@ etir_stc (abfd, cmd, ptr)
         qw     offset  */
 
     case ETIR_S_C_STC_PS:
-      (*_bfd_error_handler) ("ETIR_S_C_STC_PS: not supported");
+      (*_bfd_error_handler) (_("ETIR_S_C_STC_PS: not supported"));
       break;
 
       /* 205 Store-conditional NOP at address of global
@@ -875,7 +874,7 @@ etir_stc (abfd, cmd, ptr)
         arg:  */
 
     case ETIR_S_C_STC_NBH_PS:
-      (*_bfd_error_handler) ("ETIR_S_C_STC_xx: (%d) not supported", cmd);
+/* FIXME     (*_bfd_error_handler) ("ETIR_S_C_STC_xx: (%d) not supported", cmd); */
       break;
 
     default:
@@ -1121,8 +1120,6 @@ _bfd_evax_write_etir (abfd)
   asection *section;
   evax_section *sptr;
   int nextoffset;
-  char uname[200];
-  char *nptr, *uptr;
 
 #if EVAX_DEBUG
   evax_debug (2, "evax_write_etir(%p)\n", abfd);
@@ -1150,7 +1147,7 @@ _bfd_evax_write_etir (abfd)
 
          if ((i = section->reloc_count) <= 0)
            {
-             (*_bfd_error_handler) ("SEC_RELOC with no relocs in section %s",
+             (*_bfd_error_handler) (_("SEC_RELOC with no relocs in section %s"),
                                     section->name);
            }
 #if EVAX_DEBUG
@@ -1174,7 +1171,8 @@ _bfd_evax_write_etir (abfd)
 #endif
        }
 
-      if (section->flags & SEC_HAS_CONTENTS)
+      if ((section->flags & SEC_HAS_CONTENTS)
+       && (! bfd_is_com_section (section)))
        {
          bfd_vma vaddr;                /* virtual addr in section */
 
@@ -1247,19 +1245,8 @@ _bfd_evax_write_etir (abfd)
                                    _bfd_evax_output_begin (abfd,
                                                            ETIR_S_C_STO_GBL_LW,
                                                            -1);
-                                   uptr = uname;
-                                   nptr = (char *)sym->name;
-                                   while (*nptr)
-                                     {
-                                       if (islower (*nptr))
-                                         *uptr = toupper (*nptr);
-                                       else
-                                         *uptr = *nptr;
-                                       nptr++;
-                                       uptr++;
-                                     }
-                                   *uptr = 0;
-                                   _bfd_evax_output_counted (abfd, uname);
+                                   _bfd_evax_output_counted (abfd,
+                                                             _bfd_evax_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
                                    _bfd_evax_output_flush (abfd);
                                  }
                                else if (bfd_is_abs_section (sym->section))
@@ -1324,19 +1311,8 @@ _bfd_evax_write_etir (abfd)
                                    _bfd_evax_output_begin (abfd,
                                                            ETIR_S_C_STO_GBL,
                                                            -1);
-                                   uptr = uname;
-                                   nptr = (char *)sym->name;
-                                   while (*nptr)
-                                     {
-                                       if (islower (*nptr))
-                                         *uptr = toupper (*nptr);
-                                       else
-                                         *uptr = *nptr;
-                                       nptr++;
-                                       uptr++;
-                                     }
-                                   *uptr = 0;
-                                   _bfd_evax_output_counted (abfd, uname);
+                                   _bfd_evax_output_counted (abfd,
+                                                             _bfd_evax_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
                                    _bfd_evax_output_flush (abfd);
                                  }
                                else if (bfd_is_abs_section (sym->section))
@@ -1397,42 +1373,12 @@ _bfd_evax_write_etir (abfd)
                                evax_output_begin(abfd, ETIR_S_C_STO_HINT_GBL, -1);
                                evax_output_long(abfd, (unsigned long)(sec->index));
                                evax_output_quad(abfd, (uquad)addr);
-                               uptr = uname;
-                               nptr = (char *)(*(*rptr)->sym_ptr_ptr)->name;
-                               while (*nptr)
-                                 {
-                                   if (islower (*nptr))
-                                     *uptr = toupper (*nptr);
-                                   else
-                                     *uptr = *nptr;
-                                   nptr++;
-                                   uptr++;
-                                 }
-                               *uptr = 0;
 
-                               evax_output_counted(abfd, uname);
+                               evax_output_counted(abfd, _bfd_evax_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
                                evax_output_flush(abfd);
 #endif
                              }
                              break;
-#if 0
-                           case ALPHA_R_BRADDR:
-                             break;
-                           case ALPHA_R_SREL16:
-                             break;
-                           case ALPHA_R_SREL32:
-                             break;
-                           case ALPHA_R_SREL64:
-                             break;
-                           case ALPHA_R_OP_PUSH:
-                             break;
-                           case ALPHA_R_OP_STORE:
-                             break;
-                           case ALPHA_R_OP_PSUB:
-                             break;
-                           case ALPHA_R_OP_PRSHIFT:
-                             break;
-#endif
                            case ALPHA_R_LINKAGE:
                              {
                                if (_bfd_evax_output_check (abfd, 64) < 0)
@@ -1447,26 +1393,35 @@ _bfd_evax_write_etir (abfd)
                                _bfd_evax_output_long (abfd,
                                                       (unsigned long)PRIV(evax_linkage_index));
                                PRIV(evax_linkage_index) += 2;
-                               uptr = uname;
-                               nptr = (char *)(*(*rptr)->sym_ptr_ptr)->name;
-                               while (*nptr)
+                               _bfd_evax_output_counted (abfd,
+                                                         _bfd_evax_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+                               _bfd_evax_output_byte (abfd, 0);
+                               _bfd_evax_output_flush (abfd);
+                             }
+                             break;
+
+                           case ALPHA_R_CODEADDR:
+                             {
+                               if (_bfd_evax_output_check (abfd,
+                                                           strlen((char *)sym->name))
+                                   < 0)
                                  {
-                                   if (islower (*nptr))
-                                     *uptr = toupper (*nptr);
-                                   else
-                                     *uptr = *nptr;
-                                   nptr++;
-                                   uptr++;
+                                   end_etir_record (abfd);
+                                   start_etir_record (abfd,
+                                                      section->index,
+                                                      vaddr, false);
                                  }
-                               *uptr = 0;
-                               _bfd_evax_output_counted (abfd, uname);
-                               _bfd_evax_output_byte (abfd, 0);
+                               _bfd_evax_output_begin (abfd,
+                                                       ETIR_S_C_STO_CA,
+                                                       -1);
+                               _bfd_evax_output_counted (abfd,
+                                                         _bfd_evax_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
                                _bfd_evax_output_flush (abfd);
                              }
                              break;
 
                            default:
-                             (*_bfd_error_handler) ("Unhandled relocation %s",
+                             (*_bfd_error_handler) (_("Unhandled relocation %s"),
                                                     (*rptr)->howto->name);
                              break;
                            }