S/390: Fix 16 bit pc relative relocs.
[deliverable/binutils-gdb.git] / gas / config / obj-evax.c
index eb50283e2b6623ca858b967cee2b1118ad186885..b6d8c314cac3be3062cdb7f5b7ec33923a45b8e5 100644 (file)
@@ -1,5 +1,5 @@
 /* obj-evax.c - EVAX (openVMS/Alpha) object file format.
-   Copyright 1996, 1997, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1996-2016 Free Software Foundation, Inc.
    Contributed by Klaus Kämpf (kkaempf@progis.de) of
      proGIS Software, Aachen, Germany.
    Extensively enhanced by Douglas Rupp of AdaCore.
@@ -23,9 +23,9 @@
 
 #define OBJ_HEADER "obj-evax.h"
 
+#include "as.h"
 #include "bfd.h"
 #include "vms.h"
-#include "as.h"
 #include "subsegs.h"
 #include "struc-symbol.h"
 #include "safe-ctype.h"
@@ -60,10 +60,9 @@ s_evax_weak (int ignore ATTRIBUTE_UNUSED)
 
   do
     {
-      name = input_line_pointer;
-      c = get_symbol_end ();
+      c = get_symbol_name (&name);
       symbolP = symbol_find_or_make (name);
-      *input_line_pointer = c;
+      (void) restore_line_pointer (c);
       SKIP_WHITESPACE ();
       S_SET_WEAK (symbolP);
       if (c == ',')
@@ -87,8 +86,7 @@ evax_symbol_new_hook (symbolS *sym)
 {
   struct evax_private_udata_struct *udata;
 
-  udata = (struct evax_private_udata_struct *)
-    xmalloc (sizeof (struct evax_private_udata_struct));
+  udata = XNEW (struct evax_private_udata_struct);
 
   udata->bsym = symbol_get_bfdsym (sym);
   udata->enbsym = NULL;
@@ -125,7 +123,10 @@ evax_frob_symbol (symbolS *sym, int *punt)
             O_symbol and we hope the equated symbol is still there.  */
          sym = symbol_get_value_expression (sym)->X_add_symbol;
          if (sym == NULL)
-           abort ();
+            {
+              as_bad (_("no entry symbol for global function '%s'"), symname);
+              return;
+            }
          symbol = symbol_get_bfdsym (sym);
          udata->enbsym
            = ((struct evax_private_udata_struct *)symbol->udata.p)->enbsym;
@@ -145,11 +146,14 @@ evax_frob_file_before_adjust (void)
   subseg_set (alpha_link_section, 0);
   seginfo = seg_info (alpha_link_section);
 
+  /* Handle .linkage fixups.  */
   for (l = alpha_linkage_fixup_root; l != NULL; l = l->next)
     {
       if (S_GET_SEGMENT (l->fixp->fx_addsy) == alpha_link_section)
        {
-         symbolS * entry_sym;
+          /* The symbol is defined in the file.  The linkage entry decays to
+             two relocs.  */
+         symbolS *entry_sym;
          fixS *fixpentry, *fixppdesc, *fixtail;
 
          fixtail = seginfo->fix_tail;
@@ -162,7 +166,7 @@ evax_frob_file_before_adjust (void)
          fixpentry = fix_new (l->fixp->fx_frag, l->fixp->fx_where, 8,
                               entry_sym, l->fixp->fx_offset, 0,
                               BFD_RELOC_64);
-         fixppdesc = fix_new (l->fixp->fx_frag, l->fixp->fx_where+8, 8,
+         fixppdesc = fix_new (l->fixp->fx_frag, l->fixp->fx_where + 8, 8,
                               l->fixp->fx_addsy, l->fixp->fx_offset, 0,
                               BFD_RELOC_64);
          l->fixp->fx_size = 0;
@@ -180,6 +184,7 @@ evax_frob_file_before_adjust (void)
        }
       else
        {
+          /* Assign a linkage index.  */
          ((struct evax_private_udata_struct *)
           symbol_get_bfdsym (l->label)->udata.p)->lkindex = linkage_index;
 
@@ -267,9 +272,7 @@ evax_shorten_name (char *id)
     }
 
   /* We only need worry about krunching the base symbol.  */
-  base_id = xmalloc (suffix_dotdot - prefix_dotdot + 1);
-  strncpy (base_id, &id[prefix_dotdot], suffix_dotdot - prefix_dotdot);
-  base_id [suffix_dotdot - prefix_dotdot] = 0;
+  base_id = xmemdup0 (&id[prefix_dotdot], suffix_dotdot - prefix_dotdot);
 
   if (strlen (base_id) > MAX_LABEL_LENGTH)
     {
@@ -293,8 +296,7 @@ evax_shorten_name (char *id)
        strcat (new_id, suffix);
 
       /* Save it on the heap and return.  */
-      return_id = xmalloc (strlen (new_id) + 1);
-      strcpy (return_id, new_id);
+      return_id = xstrdup (new_id);
 
       return return_id;
     }
@@ -325,7 +327,7 @@ evax_shorten_name (char *id)
    which further designates that the name was truncated):
 
    "original_identifier"_haaaaabbbccc
-   
+
    aaaaa = 32-bit CRC
    bbb = length of original identifier
    ccc = sum of 32-bit CRC characters
@@ -354,7 +356,7 @@ static char decodings[256];
 /* Table used by the crc32 function to calcuate the checksum.  */
 static unsigned int crc32_table[256] = {0, 0};
 
-/* Given a string in BUF, calculate a 32-bit CRC for it. 
+/* Given a string in BUF, calculate a 32-bit CRC for it.
 
    This is used as a reasonably unique hash for the given string.  */
 
@@ -492,7 +494,7 @@ is_truncated_identifier (char *id)
      a truncated identifier.  */
   if (len != MAX_LABEL_LENGTH)
     return 0;
-  
+
   /* Start scanning backwards for a _h.  */
   len = len - 3 - 3 - 5 - 2;
   ptr = id + len;
This page took 0.029087 seconds and 4 git commands to generate.