Add support for a ".file 0" directive if supporting DWARF 5 or higher.
[deliverable/binutils-gdb.git] / gas / config / tc-vax.c
index 299746b802d85a7946a8071349d8180b4bc3c331..5634566945b821a2239ee776f37e3fd4a46db5bf 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
-   Free Software Foundation, Inc.
+   Copyright (C) 1987-2020 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,
@@ -129,7 +127,7 @@ int flag_want_pic;          /* -k */
  bbsc          e4
  bbcc          e5
  Always, you complement 0th bit to reverse condition.
- Always, 1-byte opcde, longword-address, byte-address, 1-byte-displacement
+ Always, 1-byte opcode, longword-address, byte-address, 1-byte-displacement
 
  2c.   J<cond> where cond tests low-order memory bit
  length of byte,word,long.
@@ -190,7 +188,7 @@ int flag_want_pic;          /* -k */
 #define BB (1+-128)
 #define WF (2+ 32767)
 #define WB (2+-32768)
-/* Dont need LF, LB because they always reach. [They are coded as 0.]  */
+/* Don't need LF, LB because they always reach. [They are coded as 0.]  */
 
 #define C(a,b) ENCODE_RELAX(a,b)
 /* This macro has no side-effects.  */
@@ -238,7 +236,7 @@ const relax_typeS md_relax_table[] =
 #undef WB
 
 void float_cons (int);
-int flonum_gen2vax (char, FLONUM_TYPE *, LITTLENUM_TYPE *);
+int flonum_gen2vax (int, FLONUM_TYPE *, LITTLENUM_TYPE *);
 
 const pseudo_typeS md_pseudo_table[] =
 {
@@ -280,20 +278,29 @@ 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);
 }
 
-long
-md_chars_to_number (unsigned char con[],       /* Low order byte 1st.  */
-                   int nbytes)         /* Number of bytes in the input.  */
+/* Convert a number from VAX byte order (little endian)
+   into host byte order.
+   con         is the buffer to convert,
+   nbytes      is the length of the given buffer.  */
+static long
+md_chars_to_number (unsigned char con[], int nbytes)
 {
   long retval;
 
@@ -393,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))
@@ -779,11 +783,11 @@ static const short int vax_operand_width_size[256] =
    ban these opcodes. They are mnemonics for "elastic" instructions
    that are supposed to assemble into the fewest bytes needed to do a
    branch, or to do a conditional branch, or whatever.
-  
+
    The opcode is in the usual place [low-order n*8 bits]. This means
    that if you mask off the bucky bits, the usual rules apply about
    how long the opcode is.
-  
+
    All VAX branch displacements come at the end of the instruction.
    For simple branches (1-byte opcode + 1-byte displacement) the last
    operand is coded 'b?' where the "data type" '?' is a clue that we
@@ -791,25 +795,23 @@ static const short int vax_operand_width_size[256] =
    and branch around a jump. This is by far the most common case.
    That is why the VIT_OPCODE_SYNTHETIC bit is set: it says this is
    a 0-byte op-code followed by 2 or more bytes of operand address.
-  
+
    If the op-code has VIT_OPCODE_SPECIAL set, then we have a more unusual
    case.
-  
+
    For JBSB & JBR the treatment is the similar, except (1) we have a 'bw'
    option before (2) we can directly JSB/JMP because there is no condition.
    These operands have 'b-' as their access/data type.
-  
+
    That leaves a bunch of random opcodes: JACBx, JxOBxxx. In these
    cases, we do the same idea. JACBxxx are all marked with a 'b!'
    JAOBxxx & JSOBxxx are marked with a 'b:'.  */
 #if (VIT_OPCODE_SYNTHETIC != 0x80000000)
-You have just broken the encoding below, which assumes the sign bit
-  means 'I am an imaginary instruction'.
+#error "You have just broken the encoding below, which assumes the sign bit means 'I am an imaginary instruction'."
 #endif
 
 #if (VIT_OPCODE_SPECIAL != 0x40000000)
-  You have just broken the encoding below, which assumes the 0x40 M bit means
-  'I am not to be "optimised" the way normal branches are'.
+#error "You have just broken the encoding below, which assumes the 0x40 M bit means 'I am not to be "optimised" the way normal branches are'."
 #endif
 
 static const struct vot
@@ -851,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}},
 
@@ -958,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);
@@ -973,14 +977,14 @@ vip_begin (int synthetic_too,             /* 1 means include jXXX op-codes.  */
 
 /* Take 3 char.s, the last of which may be `\0` (non-existent)
    and return the VAX register number that they represent.
-  
+
    Return -1 if they don't form a register name. Good names return
    a number from 0:15 inclusive.
-  
+
    Case is not important in a name.
-  
+
    Register names understood are:
-  
+
        R0
        R1
        R2
@@ -998,18 +1002,18 @@ vip_begin (int synthetic_too,            /* 1 means include jXXX op-codes.  */
        R14     SP
        R15     PC  */
 
-#define AP (12)
-#define FP (13)
-#define SP (14)
-#define PC (15)
+#define AP 12
+#define FP 13
+#define SP 14
+#define PC 15
 
-static int                             /* Return -1 or 0:15.  */
-vax_reg_parse (char c1, char c2,       /* 3 chars of register name.  */
-              char c3, char c4)        /* c3 == 0 if 2-character reg name.  */
+/* Returns the register number of something like '%r15' or 'ap', supplied
+   in four single chars. Returns -1 if the register isn't recognized,
+   0..15 otherwise.  */
+static int
+vax_reg_parse (char c1, char c2, char c3, char c4)
 {
-  int retval;
-
-  retval = -1;
+  int retval = -1;
 
 #ifdef OBJ_ELF
   if (c1 != '%')       /* Register prefixes are mandatory for ELF.  */
@@ -1077,20 +1081,20 @@ vax_reg_parse (char c1, char c2,        /* 3 chars of register name.  */
    For speed, expect a string of whitespace to be reduced to a single ' '.
    This is the case for GNU AS, and is easy for other DEC-compatible
    assemblers.
-  
+
    Knowledge about DEC VAX assembler operand notation lives here.
    This doesn't even know what a register name is, except it believes
    all register names are 2 or 3 characters, and lets vax_reg_parse() say
    what number each name represents.
    It does, however, know that PC, SP etc are special registers so it can
    detect addressing modes that are silly for those registers.
-  
+
    Where possible, it delivers 1 fatal or 1 warning message if the operand
    is suspect. Exactly what we test for is still evolving.
 
    ---
        Arg block.
-  
+
    There were a number of 'mismatched argument type' bugs to vip_op.
    The most general solution is to typedef each (of many) arguments.
    We used instead a typedef'd argument block. This is less modular
@@ -1098,7 +1102,7 @@ vax_reg_parse (char c1, char c2,  /* 3 chars of register name.  */
    on most engines, and seems to keep programmers happy. It will have
    to be done properly if we ever want to use vip_op as a general-purpose
    module (it was designed to be).
-  
+
        G^
 
    Doesn't support DEC "G^" format operands. These always take 5 bytes
@@ -1109,14 +1113,14 @@ vax_reg_parse (char c1, char c2,        /* 3 chars of register name.  */
    If there is some other use for "G^", feel free to code it in!
 
        speed
-  
+
    If I nested if()s more, I could avoid testing (*err) which would save
    time, space and page faults. I didn't nest all those if()s for clarity
    and because I think the mode testing can be re-arranged 1st to test the
-   commoner constructs 1st. Does anybody have statistics on this?  
-  
+   commoner constructs 1st. Does anybody have statistics on this?
+
        error messages
-  
+
    In future, we should be able to 'compose' error messages in a scratch area
    and give the user MUCH more informative error messages. Although this takes
    a little more code at run-time, it will make this module much more self-
@@ -1125,18 +1129,18 @@ vax_reg_parse (char c1, char c2,        /* 3 chars of register name.  */
    the Un*x characters "$`*", that most users will expect from this AS.
 
    ----
-   
+
    The input is a string, ending with '\0'.
-  
+
    We also require a 'hint' of what kind of operand is expected: so
    we can remind caller not to write into literals for instance.
-  
+
    The output is a skeletal instruction.
-  
+
    The algorithm has two parts.
    1. extract the syntactic features (parse off all the @^#-()+[] mode crud);
    2. express the @^#-()+[] as some parameters suited to further analysis.
-  
+
    2nd step is where we detect the googles of possible invalid combinations
    a human (or compiler) might write. Note that if we do a half-way
    decent assembler, we don't know how long to make (eg) displacement
@@ -1153,19 +1157,19 @@ vax_reg_parse (char c1, char c2,        /* 3 chars of register name.  */
     -  error text(s)            why we couldn't understand the operand
 
    ----
-    
+
    To decode output of this, test errtxt. If errtxt[0] == '\0', then
    we had no errors that prevented parsing. Also, if we ever report
    an internal bug, errtxt[0] is set non-zero. So one test tells you
    if the other outputs are to be taken seriously.
 
    ----
-   
+
    Dec defines the semantics of address modes (and values)
    by a two-letter code, explained here.
-  
+
      letter 1:   access type
-  
+
        a         address calculation - no data access, registers forbidden
        b         branch displacement
        m         read - let go of bus - write back    "modify"
@@ -1173,9 +1177,9 @@ vax_reg_parse (char c1, char c2,  /* 3 chars of register name.  */
        v         bit field address: like 'a' but registers are OK
        w         write
        space    no operator (eg ".long foo") [our convention]
-  
+
      letter 2:   data type (i.e. width, alignment)
-  
+
        b         byte
        d         double precision floating point (D format)
        f         single precision floating point (F format)
@@ -1188,11 +1192,11 @@ vax_reg_parse (char c1, char c2,        /* 3 chars of register name.  */
        ?        simple synthetic branch operand
        -        unconditional synthetic JSB/JSR operand
        !        complex synthetic branch operand
-  
+
    The '-?!' letter 2's are not for external consumption. They are used
    for various assemblers. Generally, all unknown widths are assumed 0.
    We don't limit your choice of width character.
-  
+
    DEC operands are hard work to parse. For example, '@' as the first
    character means indirect (deferred) mode but elsewhere it is a shift
    operator.
@@ -1201,9 +1205,9 @@ vax_reg_parse (char c1, char c2,  /* 3 chars of register name.  */
    We try hard not to parse anything that MIGHT be part of the expression
    buried in that syntax. For example if we see @...(Rn) we don't check
    for '-' before the '(' because mode @-(Rn) does not exist.
-  
+
    After parsing we have:
-  
+
    at                     1 if leading '@' (or Un*x '*')
    len                    takes one value from " bilsw". eg B^ -> 'b'.
    hash                   1 if leading '#' (or Un*x '$')
@@ -1214,7 +1218,7 @@ vax_reg_parse (char c1, char c2,  /* 3 chars of register name.  */
    paren                  1 if () are around register
    reg                    major register number 0:15    -1 means absent
    ndx                    index register number 0:15    -1 means absent
-  
+
    Again, I dare not explain it: just trace ALL the code!
 
    Summary of vip_op outputs.
@@ -1229,12 +1233,12 @@ vax_reg_parse (char c1, char c2,        /* 3 chars of register name.  */
   {@}#foo, no S^               8+@     PC      " i"    optional
   {@}{q^}{(Rn)}                10+@+q  option  " bwl"  optional  */
 
+/* Dissect user-input 'optext' (which is something like "@B^foo@bar(AP)[FP]:")
+   using the vop in vopP. vopP's vop_access and vop_width. We fill _ndx, _reg,
+   _mode, _short, _warn, _error, _expr_begin, _expr_end and _nbytes.  */
+
 static void
-vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
-       struct vop *vopP) /* Input fields: vop_access, vop_width.
-                            Output fields: _ndx, _reg, _mode, _short, _warn,
-                            _error _expr_begin, _expr_end, _nbytes.
-                            vop_nbytes : number of bytes in a datum.  */
+vip_op (char *optext, struct vop *vopP)
 {
   /* Track operand text forward.  */
   char *p;
@@ -1271,10 +1275,8 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
      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;
@@ -1314,7 +1316,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
   /* p points to what may be the beginning of an expression.
      We have peeled off the front all that is peelable.
      We know at, len, hash.
-    
+
      Lets point q at the end of the text and parse that (backwards).  */
 
   for (q = p; *q; q++)
@@ -1489,7 +1491,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
      We will deliver a 4-bit reg, and a 4-bit mode.  */
 
   /* Case of branch operand. Different. No L^B^W^I^S^ allowed for instance.
-    
+
      in:  at   ?
           len  ?
           hash ?
@@ -1498,7 +1500,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
           paren        ?
           reg   ?
           ndx   ?
-    
+
      out: mode  0
           reg   -1
           len  ' '
@@ -1517,7 +1519,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
   /* Since nobody seems to use it: comment this 'feature'(?) out for now.  */
 #ifdef NEVER
   /* Case of stand-alone operand. e.g. ".long foo"
-    
+
      in:  at   ?
           len  ?
           hash ?
@@ -1526,7 +1528,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
           paren        ?
           reg   ?
           ndx   ?
-    
+
      out: mode  0
           reg   -1
           len  ' '
@@ -1563,7 +1565,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
 #endif
 
   /* Case of S^#.
-    
+
      in:  at       0
           len      's'               definition
           hash     1              demand
@@ -1572,7 +1574,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
           paren    0             by "()" scan logic because "S^" seen
           reg      -1                or nn by mistake
           ndx      -1
-    
+
      out: mode     0
           reg      -1
           len      's'
@@ -1604,9 +1606,9 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
            err = _("S^# may only read-access");
        }
     }
-  
+
   /* Case of -(Rn), which is weird case.
-    
+
      in:  at       0
           len      '
           hash     0
@@ -1615,7 +1617,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
           paren    1              by definition
           reg      present           by definition
           ndx      optional
-    
+
      out: mode     7
           reg      present
           len      ' '
@@ -1646,7 +1648,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
     }
 
   /* Case of (Rn)+, which is slightly different.
-    
+
      in:  at
           len      ' '
           hash     0
@@ -1655,7 +1657,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
           paren    1              by definition
           reg      present           by definition
           ndx      optional
-    
+
      out: mode     8+@
           reg      present
           len      ' '
@@ -1677,7 +1679,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
     }
 
   /* Case of #, without S^.
-    
+
      in:  at
           len      ' ' or 'i'
           hash     1              by definition
@@ -1686,7 +1688,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
           paren    0
           reg      absent
           ndx      optional
-    
+
      out: mode     8+@
           reg      PC
           len      ' ' or 'i'
@@ -1725,7 +1727,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
 
   /* Case of Rn. We separate this one because it has a few special
      errors the remaining modes lack.
-    
+
      in:  at       optional
           len      ' '
           hash     0             by program logic
@@ -1734,7 +1736,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
           paren    0             by definition
           reg      present           by definition
           ndx      optional
-    
+
      out: mode     5+@
           reg      present
           len      ' '               enforce no length
@@ -1771,7 +1773,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
                       paren == 1  OR reg==-1  */
 
   /* Rest of cases fit into one bunch.
-    
+
      in:  at       optional
           len      ' ' or 'b' or 'w' or 'l'
           hash     0             by program logic
@@ -1780,7 +1782,7 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
           paren    optional
           reg      optional
           ndx      optional
-    
+
      out: mode     10 + @ + len
           reg      optional
           len      ' ' or 'b' or 'w' or 'l'
@@ -1794,8 +1796,10 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
        {
        case 'l':
          mode += 2;
+         /* Fall through.  */
        case 'w':
          mode += 2;
+         /* Fall through.  */
        case ' ':       /* Assumed B^ until our caller changes it.  */
        case 'b':
          break;
@@ -1830,15 +1834,15 @@ vip_op (char *optext, /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
    knowledge of how you parse (or evaluate) your expressions.
    We do however strip off and decode addressing modes and operation
    mnemonic.
-  
+
    The exploded instruction is returned to a struct vit of your choice.
    #include "vax-inst.h" to know what a struct vit is.
-  
+
    This function's value is a string. If it is not "" then an internal
    logic error was found: read this code to assign meaning to the string.
    No argument string should generate such an error string:
    it means a bug in our code, not in the user's text.
-  
+
    You MUST have called vip_begin() once before using this function.  */
 
 static void
@@ -1863,7 +1867,7 @@ vip (struct vit *vitP,            /* We build an exploded instruction here.  */
 
   if (*instring == ' ')
     ++instring;
-  
+
   /* MUST end in end-of-string or exactly 1 space.  */
   for (p = instring; *p && *p != ' '; p++)
     ;
@@ -2034,8 +2038,6 @@ main (void)
    We declare arrays non-local in case some of our tiny-minded machines
    default to small stacks. Also, helps with some debuggers.  */
 
-#include <stdio.h>
-
 char answer[100];              /* Human types into here.  */
 char *p;                       /*  */
 char *myerr;
@@ -2111,7 +2113,7 @@ main (void)
 
        default:
          my_operand_length = 2;
-         printf ("I dn't understand access width %c\n", mywidth);
+         printf ("I don't understand access width %c\n", mywidth);
          break;
        }
       printf ("VAX assembler instruction operand: ");
@@ -2142,9 +2144,8 @@ main (void)
     }
 }
 
-mumble (text, value)
-     char *text;
-     int value;
+void
+mumble (char *text, int value)
 {
   printf ("%s:", text);
   if (value >= 0)
@@ -2204,14 +2205,14 @@ struct option md_longopts[] =
 {
 #ifdef OBJ_ELF
 #define OPTION_PIC (OPTION_MD_BASE)
-  {"pic", no_argument, NULL, OPTION_PIC},
+  { "pic", no_argument, NULL, OPTION_PIC },
 #endif
-  {NULL, no_argument, NULL, 0}
+  { NULL, no_argument, NULL, 0 }
 };
 size_t md_longopts_size = sizeof (md_longopts);
 
 int
-md_parse_option (int c, char *arg)
+md_parse_option (int c, const char *arg)
 {
   switch (c)
     {
@@ -2343,7 +2344,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;
 
@@ -2389,8 +2390,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
 #undef F
 #undef MAP
 
-  reloc = xmalloc (sizeof (arelent));
-  reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+  reloc = XNEW (arelent);
+  reloc->sym_ptr_ptr = XNEW (asymbol *);
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 #ifndef OBJ_ELF
@@ -2403,11 +2404,12 @@ 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;
 }
 
+/* vax:md_assemble() emit frags for 1 instruction given in textual form.  */
 void
 md_assemble (char *instruction_string)
 {
@@ -2715,6 +2717,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);
@@ -3126,9 +3129,9 @@ md_assemble (char *instruction_string)
                          || operandP->vop_access == 'a')
                        {
                          if (operandP->vop_access == 'v')
-                           as_warn (_("Invalid operand:  immediate value used as base address."));
+                           as_warn (_("Invalid operand: immediate value used as base address."));
                          else
-                           as_warn (_("Invalid operand:  immediate value used as address."));
+                           as_warn (_("Invalid operand: immediate value used as address."));
                          /* gcc 2.6.3 is known to generate these in at least
                             one case.  */
                        }
@@ -3153,7 +3156,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;
@@ -3169,7 +3173,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
                            {
@@ -3266,3 +3271,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;
+  const 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);
+}
+
+const char *
+md_atof (int type, char * litP, int * sizeP)
+{
+  return vax_md_atof (type, litP, sizeP);
+}
This page took 0.041149 seconds and 4 git commands to generate.