ld/ARM: Fix IFUNC and TLS descriptors in the same shared object
[deliverable/binutils-gdb.git] / gas / config / tc-vax.c
index 47b4fcaea24e049d008632b625d6059774bc25ab..bccf596b55b10d4d0184b158dfd89f775fbfe44c 100644 (file)
@@ -1,13 +1,11 @@
 /* tc-vax.c - vax-specific -
-   Copyright 1987, 1991, 1992, 1993, 1994, 1995, 1998, 2000, 2001, 2002,
-   2003, 2004, 2005, 2006
-   Free Software Foundation, Inc.
+   Copyright (C) 1987-2014 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
    GAS 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)
+   the Free Software Foundation; either version 3, or (at your option)
    any later version.
 
    GAS is distributed in the hope that it will be useful,
@@ -280,15 +278,21 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED)
 {
   valueT value = * valueP;
 
-  if (((fixP->fx_addsy == NULL && fixP->fx_subsy == NULL)
-       && fixP->fx_r_type != BFD_RELOC_32_PLT_PCREL
-       && fixP->fx_r_type != BFD_RELOC_32_GOT_PCREL)
-      || fixP->fx_r_type == NO_RELOC)
-    number_to_chars_littleendian (fixP->fx_where + fixP->fx_frag->fr_literal,
-                                 value, fixP->fx_size);
+  if (fixP->fx_subsy != (symbolS *) NULL)
+    as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
 
-  if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
+  if (fixP->fx_addsy == NULL)
     fixP->fx_done = 1;
+
+  if (fixP->fx_done)
+    number_to_chars_littleendian (fixP->fx_where + fixP->fx_frag->fr_literal,
+                                 value, fixP->fx_size);
+  else
+    /* Initialise the part of an instruction frag covered by the
+       relocation.  (Many occurrences of frag_more followed by fix_new
+       lack any init of the frag.)  Since VAX uses RELA relocs the
+       value we write into this field doesn't really matter.  */
+    memset (fixP->fx_where + fixP->fx_frag->fr_literal, 0, fixP->fx_size);
 }
 
 /* Convert a number from VAX byte order (little endian)
@@ -396,23 +400,20 @@ md_estimate_size_before_relax (fragS *fragP, segT segment)
                  || S_IS_WEAK (fragP->fr_symbol)
                  || S_IS_EXTERNAL (fragP->fr_symbol)))
            {
-             if (p[0] & 0x10)
-               {
-                 if (flag_want_pic)
-                   as_fatal ("PIC reference to %s is indirect.\n",
-                             S_GET_NAME (fragP->fr_symbol));
-               }
+             /* Indirect references cannot go through the GOT or PLT,
+                let's hope they'll become local in the final link.  */
+             if ((ELF_ST_VISIBILITY (S_GET_OTHER (fragP->fr_symbol))
+                  != STV_DEFAULT)
+                 || (p[0] & 0x10))
+               reloc_type = BFD_RELOC_32_PCREL;
+             else if (((unsigned char *) fragP->fr_opcode)[0] == VAX_CALLS
+                      || ((unsigned char *) fragP->fr_opcode)[0] == VAX_CALLG
+                      || ((unsigned char *) fragP->fr_opcode)[0] == VAX_JSB
+                      || ((unsigned char *) fragP->fr_opcode)[0] == VAX_JMP
+                      || S_IS_FUNCTION (fragP->fr_symbol))
+               reloc_type = BFD_RELOC_32_PLT_PCREL;
              else
-               {
-                 if (((unsigned char *) fragP->fr_opcode)[0] == VAX_CALLS
-                     || ((unsigned char *) fragP->fr_opcode)[0] == VAX_CALLG
-                     || ((unsigned char *) fragP->fr_opcode)[0] == VAX_JSB
-                     || ((unsigned char *) fragP->fr_opcode)[0] == VAX_JMP
-                     || S_IS_FUNCTION (fragP->fr_symbol))
-                   reloc_type = BFD_RELOC_32_PLT_PCREL;
-                 else
-                   reloc_type = BFD_RELOC_32_GOT_PCREL;
-               }
+               reloc_type = BFD_RELOC_32_GOT_PCREL;
            }
 #endif
          switch (RELAX_STATE (fragP->fr_subtype))
@@ -852,6 +853,8 @@ static const struct vot
   {"jbcs",     {"rlvbb?", 0x800000e3}},
   {"jbsc",     {"rlvbb?", 0x800000e4}},
   {"jbcc",     {"rlvbb?", 0x800000e5}},
+  {"jbssi",    {"rlvbb?", 0x800000e6}},
+  {"jbcci",    {"rlvbb?", 0x800000e7}},
   {"jlbs",     {"rlb?", 0x800000e8}},
   {"jlbc",     {"rlb?", 0x800000e9}},
 
@@ -959,11 +962,11 @@ vip_begin (int synthetic_too,             /* 1 means include jXXX op-codes.  */
   op_hash = hash_new ();
 
   for (vP = votstrs; *vP->vot_name && !retval; vP++)
-    retval = hash_insert (op_hash, vP->vot_name, (PTR) &vP->vot_detail);
+    retval = hash_insert (op_hash, vP->vot_name, (void *) &vP->vot_detail);
 
   if (synthetic_too)
     for (vP = synthetic_votstrs; *vP->vot_name && !retval; vP++)
-      retval = hash_insert (op_hash, vP->vot_name, (PTR) &vP->vot_detail);
+      retval = hash_insert (op_hash, vP->vot_name, (void *) &vP->vot_detail);
 
 #ifndef CONST_TABLE
   vip_op_defaults (immediate, indirect, displen);
@@ -1272,10 +1275,8 @@ vip_op (char *optext, struct vop *vopP)
      get the types wrong below, we lose at compile time rather than at
      lint or run time.  */
   char access_mode;            /* vop_access.  */
-  char width;                  /* vop_width.  */
 
   access_mode = vopP->vop_access;
-  width = vopP->vop_width;
   /* None of our code bugs (yet), no user text errors, no warnings
      even.  */
   err = wrn = 0;
@@ -2341,7 +2342,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
   if (fixp->fx_tcbit)
     abort ();
 
-  if (fixp->fx_r_type != BFD_RELOC_NONE)
+  if (fixp->fx_r_type != NO_RELOC)
     {
       code = fixp->fx_r_type;
 
@@ -2401,7 +2402,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
 #endif
 
   reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
-  assert (reloc->howto != 0);
+  gas_assert (reloc->howto != 0);
 
   return reloc;
 }
@@ -2714,6 +2715,7 @@ md_assemble (char *instruction_string)
   if (need_pass_2 || goofed)
     return;
 
+  dwarf2_emit_insn (0);
   /* Emit op-code.  */
   /* Remember where it is, in case we want to modify the op-code later.  */
   opcode_low_byteP = frag_more (v.vit_opcode_nbytes);
@@ -3152,7 +3154,8 @@ md_assemble (char *instruction_string)
                          if (flag_want_pic && operandP->vop_mode == 8
                                && this_add_symbol != NULL)
                            {
-                             as_warn (_("Symbol used as immediate operand in PIC mode."));
+                             as_warn (_("Symbol %s used as immediate operand in PIC mode."),
+                                      S_GET_NAME (this_add_symbol));
                            }
 #endif
                          p[0] = (operandP->vop_mode << 4) | 0xF;
@@ -3168,7 +3171,8 @@ md_assemble (char *instruction_string)
                                                  min (sizeof (valueT),
                                                       (size_t) nbytes));
                              if ((size_t) nbytes > sizeof (valueT))
-                               memset (p + 5, '\0', nbytes - sizeof (valueT));
+                               memset (p + 1 + sizeof (valueT),
+                                       '\0', nbytes - sizeof (valueT));
                            }
                          else
                            {
@@ -3265,3 +3269,142 @@ md_begin (void)
       fP->high = &big_operand_bits[i][SIZE_OF_LARGE_NUMBER - 1];
     }
 }
+
+bfd_reloc_code_real_type
+vax_cons (expressionS *exp, int size)
+{
+  char *save;
+  char *vax_cons_special_reloc;
+
+  SKIP_WHITESPACE ();
+  vax_cons_special_reloc = NULL;
+  save = input_line_pointer;
+  if (input_line_pointer[0] == '%')
+    {
+      if (strncmp (input_line_pointer + 1, "pcrel", 5) == 0)
+       {
+         input_line_pointer += 6;
+         vax_cons_special_reloc = "pcrel";
+       }
+      if (vax_cons_special_reloc)
+       {
+         int bad = 0;
+
+         switch (size)
+           {
+           case 1:
+             if (*input_line_pointer != '8')
+               bad = 1;
+             input_line_pointer--;
+             break;
+           case 2:
+             if (input_line_pointer[0] != '1' || input_line_pointer[1] != '6')
+               bad = 1;
+             break;
+           case 4:
+             if (input_line_pointer[0] != '3' || input_line_pointer[1] != '2')
+               bad = 1;
+             break;
+           default:
+             bad = 1;
+             break;
+           }
+
+         if (bad)
+           {
+             as_bad (_("Illegal operands: Only %%r_%s%d allowed in %d-byte data fields"),
+                     vax_cons_special_reloc, size * 8, size);
+           }
+         else
+           {
+             input_line_pointer += 2;
+             if (*input_line_pointer != '(')
+               {
+                 as_bad (_("Illegal operands: %%r_%s%d requires arguments in ()"),
+                         vax_cons_special_reloc, size * 8);
+                 bad = 1;
+               }
+           }
+
+         if (bad)
+           {
+             input_line_pointer = save;
+             vax_cons_special_reloc = NULL;
+           }
+         else
+           {
+             int c;
+             char *end = ++input_line_pointer;
+             int npar = 0;
+
+             while (! is_end_of_line[(c = *end)])
+               {
+                 if (c == '(')
+                   npar++;
+                 else if (c == ')')
+                   {
+                     if (!npar)
+                       break;
+                     npar--;
+                   }
+                 end++;
+               }
+
+             if (c != ')')
+               as_bad (_("Illegal operands: %%r_%s%d requires arguments in ()"),
+                       vax_cons_special_reloc, size * 8);
+             else
+               {
+                 *end = '\0';
+                 expression (exp);
+                 *end = c;
+                 if (input_line_pointer != end)
+                   {
+                     as_bad (_("Illegal operands: %%r_%s%d requires arguments in ()"),
+                             vax_cons_special_reloc, size * 8);
+                   }
+                 else
+                   {
+                     input_line_pointer++;
+                     SKIP_WHITESPACE ();
+                     c = *input_line_pointer;
+                     if (! is_end_of_line[c] && c != ',')
+                       as_bad (_("Illegal operands: garbage after %%r_%s%d()"),
+                               vax_cons_special_reloc, size * 8);
+                   }
+               }
+           }
+       }
+    }
+  if (vax_cons_special_reloc == NULL)
+    expression (exp);
+  else
+    switch (size)
+      {
+      case 1: return BFD_RELOC_8_PCREL;
+      case 2: return BFD_RELOC_16_PCREL;
+      case 4: return BFD_RELOC_32_PCREL;
+      }
+  return NO_RELOC;
+}
+
+/* This is called by emit_expr via TC_CONS_FIX_NEW when creating a
+   reloc for a cons.  */
+
+void
+vax_cons_fix_new (fragS *frag, int where, unsigned int nbytes, expressionS *exp,
+                 bfd_reloc_code_real_type r)
+{
+  if (r == NO_RELOC)
+    r = (nbytes == 1 ? BFD_RELOC_8
+        : nbytes == 2 ? BFD_RELOC_16
+        : BFD_RELOC_32);
+
+  fix_new_exp (frag, where, (int) nbytes, exp, 0, r);
+}
+
+char *
+md_atof (int type, char * litP, int * sizeP)
+{
+  return vax_md_atof (type, litP, sizeP);
+}
This page took 0.026752 seconds and 4 git commands to generate.