* config/obj-elf.c: Make use of elf_group_name and elf_next_in_group
[deliverable/binutils-gdb.git] / gas / config / tc-ppc.c
index a0f18d586db08e4c29c4f11499571f69c39cdbb0..ef4341fe530d1b8e06c3d95e787d039f1b5a5ac4 100644 (file)
@@ -21,8 +21,8 @@
    02111-1307, USA.  */
 
 #include <stdio.h>
-#include <ctype.h>
 #include "as.h"
+#include "safe-ctype.h"
 #include "subsegs.h"
 
 #include "opcode/ppc.h"
@@ -618,10 +618,10 @@ register_name (expressionP)
 
   /* Find the spelling of the operand.  */
   start = name = input_line_pointer;
-  if (name[0] == '%' && isalpha (name[1]))
+  if (name[0] == '%' && ISALPHA (name[1]))
     name = ++input_line_pointer;
 
-  else if (!reg_names_p || !isalpha (name[0]))
+  else if (!reg_names_p || !ISALPHA (name[0]))
     return false;
 
   c = get_symbol_end ();
@@ -1383,10 +1383,10 @@ ppc_elf_suffix (str_p, exp_p)
 
   for (ch = *str, str2 = ident;
        (str2 < ident + sizeof (ident) - 1
-       && (isalnum (ch) || ch == '@'));
+       && (ISALNUM (ch) || ch == '@'));
        ch = *++str)
     {
-      *str2++ = (islower (ch)) ? ch : tolower (ch);
+      *str2++ = TOLOWER (ch);
     }
 
   *str2 = '\0';
@@ -1820,7 +1820,7 @@ md_assemble (str)
 #endif
 
   /* Get the opcode.  */
-  for (s = str; *s != '\0' && ! isspace (*s); s++)
+  for (s = str; *s != '\0' && ! ISSPACE (*s); s++)
     ;
   if (*s != '\0')
     *s++ = '\0';
@@ -1843,7 +1843,7 @@ md_assemble (str)
   insn = opcode->opcode;
 
   str = s;
-  while (isspace (*str))
+  while (ISSPACE (*str))
     ++str;
 
   /* PowerPC operands are just expressions.  The only real issue is
@@ -2176,6 +2176,7 @@ md_assemble (str)
            }
 
          if (BFD_DEFAULT_TARGET_SIZE == 64
+             && ppc_size == PPC_OPCODE_64
              && (operand->flags & PPC_OPERAND_DS) != 0)
            {
              switch (reloc)
@@ -2266,7 +2267,7 @@ md_assemble (str)
        ++str;
     }
 
-  while (isspace (*str))
+  while (ISSPACE (*str))
     ++str;
 
   if (*str != '\0')
@@ -2440,7 +2441,7 @@ ppc_section_letter (letter, ptr_msg)
   if (letter == 'e')
     return SHF_EXCLUDE;
 
-  *ptr_msg = _("Bad .section directive: want a,w,x,e in string");
+  *ptr_msg = _("Bad .section directive: want a,e,w,x,M,S in string");
   return 0;
 }
 
@@ -3167,7 +3168,10 @@ ppc_function (ignore)
 }
 
 /* The .bf pseudo-op.  This is just like a COFF C_FCN symbol named
-   ".bf".  */
+   ".bf".  If the pseudo op .bi was seen before .bf, patch the .bi sym
+   with the correct line number */
+static symbolS *saved_bi_sym = 0;
 
 static void
 ppc_bf (ignore)
@@ -3186,6 +3190,14 @@ ppc_bf (ignore)
   S_SET_NUMBER_AUXILIARY (sym, 1);
   SA_SET_SYM_LNNO (sym, coff_line_base);
 
+  /* Line number for bi.  */
+  if (saved_bi_sym) 
+    {
+      S_SET_VALUE (saved_bi_sym, coff_n_line_nos);
+      saved_bi_sym = 0;
+    }
+  
+
   symbol_get_tc (sym)->output = 1;
 
   ppc_frob_label (sym);
@@ -3219,7 +3231,8 @@ ppc_ef (ignore)
 
 /* The .bi and .ei pseudo-ops.  These take a string argument and
    generates a C_BINCL or C_EINCL symbol, which goes at the start of
-   the symbol list.  */
+   the symbol list.  The value of .bi will be know when the next .bf
+   is encountered.  */
 
 static void
 ppc_biei (ei)
@@ -3249,6 +3262,12 @@ ppc_biei (ei)
   S_SET_STORAGE_CLASS (sym, ei ? C_EINCL : C_BINCL);
   symbol_get_tc (sym)->output = 1;
 
+  /* Save bi.  */
+  if (ei) 
+    saved_bi_sym = 0;
+  else
+    saved_bi_sym = sym;
+
   for (look = last_biei ? last_biei : symbol_rootP;
        (look != (symbolS *) NULL
        && (S_GET_STORAGE_CLASS (look) == C_FILE
@@ -3586,6 +3605,7 @@ ppc_tc (ignore)
 
 #endif /* OBJ_XCOFF */
 #ifdef OBJ_ELF
+  int align;
 
   /* Skip the TOC symbol name.  */
   while (is_part_of_name (*input_line_pointer)
@@ -3596,8 +3616,9 @@ ppc_tc (ignore)
     ++input_line_pointer;
 
   /* Align to a four/eight byte boundary.  */
-  frag_align (BFD_DEFAULT_TARGET_SIZE == 64 ? 3 : 2, 0, 0);
-  record_alignment (now_seg, BFD_DEFAULT_TARGET_SIZE == 64 ? 3 : 2);
+  align = BFD_DEFAULT_TARGET_SIZE == 64 && ppc_size == PPC_OPCODE_64 ? 3 : 2;
+  frag_align (align, 0, 0);
+  record_alignment (now_seg, align);
 #endif /* OBJ_ELF */
 
   if (*input_line_pointer != ',')
@@ -3630,7 +3651,7 @@ ppc_is_toc_sym (sym)
 #endif
 #ifdef OBJ_ELF
   const char *sname = segment_name (S_GET_SEGMENT (sym));
-  if (BFD_DEFAULT_TARGET_SIZE == 64)
+  if (BFD_DEFAULT_TARGET_SIZE == 64 && ppc_size == PPC_OPCODE_64)
     return strcmp (sname, ".toc") == 0;
   else
     return strcmp (sname, ".got") == 0;
@@ -4267,8 +4288,7 @@ ppc_canonicalize_symbol_name (name)
        }
 
       for (s++; *s != '\0' && *s != brac; s++)
-       if (islower (*s))
-         *s = toupper (*s);
+       *s = TOUPPER (*s);
 
       if (*s == '\0' || s[1] != '\0')
        as_bad (_("bad symbol suffix"));
@@ -5175,6 +5195,7 @@ md_apply_fix3 (fixp, valuep, seg)
          fixp->fx_r_type = BFD_RELOC_PPC_TOC16;
 #ifdef OBJ_ELF
          if (BFD_DEFAULT_TARGET_SIZE == 64
+             && ppc_size == PPC_OPCODE_64
              && (operand->flags & PPC_OPERAND_DS) != 0)
            fixp->fx_r_type = BFD_RELOC_PPC64_TOC16_DS;
 #endif
@@ -5209,7 +5230,10 @@ md_apply_fix3 (fixp, valuep, seg)
       switch (fixp->fx_r_type)
        {
        case BFD_RELOC_CTOR:
-         /* FIXME: 32 bits even for 64-bit targets?  */
+         if (BFD_DEFAULT_TARGET_SIZE == 64 && ppc_size == PPC_OPCODE_64)
+           goto ctor64;
+         /* fall through */
+
        case BFD_RELOC_32:
          if (fixp->fx_pcrel)
            fixp->fx_r_type = BFD_RELOC_32_PCREL;
@@ -5224,6 +5248,7 @@ md_apply_fix3 (fixp, valuep, seg)
          break;
 
        case BFD_RELOC_64:
+       ctor64:
          if (fixp->fx_pcrel)
            fixp->fx_r_type = BFD_RELOC_64_PCREL;
          /* fall through */
This page took 0.026622 seconds and 4 git commands to generate.