Update copyright years
[deliverable/binutils-gdb.git] / gas / config / obj-coff.c
index 59fe032e10f1a731809beaaca43143559ec5b916..79c8f88cd63ee6828cd494b87088a0adef8a2ef6 100644 (file)
@@ -1,7 +1,5 @@
 /* coff object file format
-   Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
-   Free Software Foundation, Inc.
+   Copyright (C) 1989-2014 Free Software Foundation, Inc.
 
    This file is part of GAS.
 
 #include "safe-ctype.h"
 #include "obstack.h"
 #include "subsegs.h"
+#include "struc-symbol.h"
 
 #ifdef TE_PE
 #include "coff/pe.h"
 #endif
 
+#ifdef OBJ_XCOFF
+#include "coff/xcoff.h"
+#endif
+
 #define streq(a,b)     (strcmp ((a), (b)) == 0)
 #define strneq(a,b,n)  (strncmp ((a), (b), (n)) == 0)
 
@@ -218,10 +221,10 @@ obj_coff_common_parse (int ignore ATTRIBUTE_UNUSED, symbolS *symbolP, addressT s
        }
 
       /* Emit a string.  Note no NUL-termination.  */
-      pfxlen = strlen (" -aligncomm:") + strlen (S_GET_NAME (symbolP)) + 1;
+      pfxlen = strlen (" -aligncomm:") + 2 + strlen (S_GET_NAME (symbolP)) + 1;
       numlen = snprintf (numbuff, sizeof (numbuff), "%d", (int) align);
       frag = frag_more (pfxlen + numlen);
-      (void) sprintf (frag, " -aligncomm:%s,", S_GET_NAME (symbolP));
+      (void) sprintf (frag, " -aligncomm:\"%s\",", S_GET_NAME (symbolP));
       memcpy (frag + pfxlen, numbuff, numlen);
       /* Restore original subseg. */
       subseg_set (current_seg, current_subseg);
@@ -1095,15 +1098,8 @@ weak_name2altname (const char * name)
 static const char *
 weak_altname2name (const char * name)
 {
-  char * weak_name;
-  char * dot;
-
   gas_assert (weak_is_altname (name));
-
-  weak_name = xstrdup (name + 6);
-  if ((dot = strchr (weak_name, '.')))
-    *dot = 0;
-  return weak_name;
+  return xstrdup (name + 6);
 }
 
 /* Make a weak symbol name unique by
@@ -1121,9 +1117,6 @@ weak_uniquify (const char * name)
 #endif
   gas_assert (weak_is_altname (name));
 
-  if (strchr (name + sizeof (weak_altprefix), '.'))
-    return name;
-
   ret = xmalloc (strlen (name) + strlen (unique) + 2);
   strcpy (ret, name);
   strcat (ret, ".");
@@ -1365,7 +1358,8 @@ coff_frob_symbol (symbolS *symp, int *punt)
                }
            }
 
-         if (coff_last_function == 0 && SF_GET_FUNCTION (symp))
+         if (coff_last_function == 0 && SF_GET_FUNCTION (symp)
+             && S_IS_DEFINED (symp))
            {
              union internal_auxent *auxp;
 
@@ -1377,7 +1371,8 @@ coff_frob_symbol (symbolS *symp, int *punt)
                      sizeof (auxp->x_sym.x_fcnary.x_ary.x_dimen));
            }
 
-         if (S_GET_STORAGE_CLASS (symp) == C_EFCN)
+         if (S_GET_STORAGE_CLASS (symp) == C_EFCN
+             && S_IS_DEFINED (symp))
            {
              if (coff_last_function == 0)
                as_fatal (_("C_EFCN symbol for %s out of scope"),
@@ -1537,6 +1532,7 @@ coff_frob_file_after_relocs (void)
                                                  'o' for over
                                                  'w' for data
                                                 'd' (apparently m88k for data)
+                                                'e' for exclude
                                                  'x' for text
                                                 'r' for read-only data
                                                 's' for shared data (PE)
@@ -1604,6 +1600,11 @@ obj_coff_section (int ignore ATTRIBUTE_UNUSED)
                }
              switch (attr)
                {
+               case 'e':
+                 /* Exclude section from linking.  */
+                 flags |= SEC_EXCLUDE;
+                 break;
+
                case 'b':
                  /* Uninitialised data section.  */
                  flags |= SEC_ALLOC;
@@ -1678,6 +1679,7 @@ obj_coff_section (int ignore ATTRIBUTE_UNUSED)
     }
 
   sec = subseg_new (name, (subsegT) exp);
+
   if (alignment >= 0)
     sec->alignment_power = alignment;
 
@@ -1730,17 +1732,18 @@ coff_frob_section (segT sec)
   segT strsec;
   char *p;
   fragS *fragp;
-  bfd_vma size, n_entries, mask;
-  bfd_vma align_power = (bfd_vma)sec->alignment_power + OCTETS_PER_BYTE_POWER;
+  bfd_vma n_entries;
 
   /* The COFF back end in BFD requires that all section sizes be
      rounded up to multiples of the corresponding section alignments,
      supposedly because standard COFF has no other way of encoding alignment
      for sections.  If your COFF flavor has a different way of encoding
      section alignment, then skip this step, as TICOFF does.  */
-  size = bfd_get_section_size (sec);
-  mask = ((bfd_vma) 1 << align_power) - 1;
+  bfd_vma size = bfd_get_section_size (sec);
 #if !defined(TICOFF)
+  bfd_vma align_power = (bfd_vma) sec->alignment_power + OCTETS_PER_BYTE_POWER;
+  bfd_vma mask = ((bfd_vma) 1 << align_power) - 1;
+
   if (size & mask)
     {
       bfd_vma new_size;
@@ -1771,8 +1774,13 @@ coff_frob_section (segT sec)
 #endif
     {
       symbolS *secsym = section_symbol (sec);
+      unsigned char sclass = C_STAT;
 
-      S_SET_STORAGE_CLASS (secsym, C_STAT);
+#ifdef OBJ_XCOFF
+      if (bfd_get_section_flags (stdoutput, sec) & SEC_DEBUGGING)
+        sclass = C_DWARF;
+#endif
+      S_SET_STORAGE_CLASS (secsym, sclass);
       S_SET_NUMBER_AUXILIARY (secsym, 1);
       SF_SET_STATICS (secsym);
       SA_SET_SCN_SCNLEN (secsym, size);
@@ -1828,12 +1836,16 @@ obj_coff_init_stab_section (segT seg)
 }
 
 #ifdef DEBUG
+const char * s_get_name (symbolS *);
+
 const char *
 s_get_name (symbolS *s)
 {
   return ((s == NULL) ? "(NULL)" : S_GET_NAME (s));
 }
 
+void symbol_dump (void);
+
 void
 symbol_dump (void)
 {
@@ -1938,5 +1950,6 @@ const struct format_ops coff_format_ops =
   0,   /* ecoff_set_ext */
   coff_obj_read_begin_hook,
   coff_obj_symbol_new_hook,
-  coff_obj_symbol_clone_hook
+  coff_obj_symbol_clone_hook,
+  coff_adjust_symtab
 };
This page took 0.026844 seconds and 4 git commands to generate.