* dw2gencfi.c (cfi_pseudo_table): Add cfi_gnu_window_save.
[binutils-gdb.git] / gas / config / obj-coff.c
index 72233b81d1468fdaff3ed16557fe75cdb462884a..5ab0ec69a237c11be5465529df01b5244a43205b 100644 (file)
@@ -271,7 +271,7 @@ fetch_coff_debug_section ()
   static segT debug_section;
   if (!debug_section)
     {
-      CONST asymbol *s;
+      const asymbol *s;
       s = bfd_make_debug_symbol (stdoutput, (char *) 0, 0);
       assert (s != 0);
       debug_section = s->section;
@@ -711,7 +711,7 @@ obj_coff_endef (ignore)
       /* intentional fallthrough */
     case C_FCN:
       {
-       CONST char *name;
+       const char *name;
        S_SET_SEGMENT (def_symbol_in_progress, text_section);
 
        name = S_GET_NAME (def_symbol_in_progress);
@@ -1147,7 +1147,9 @@ coff_obj_read_begin_hook ()
 }
 
 symbolS *coff_last_function;
+#ifndef OBJ_XCOFF
 static symbolS *coff_last_bf;
+#endif
 
 void
 coff_frob_symbol (symp, punt)
@@ -1397,23 +1399,24 @@ coff_frob_file_after_relocs ()
   bfd_map_over_sections (stdoutput, coff_adjust_section_syms, (char*) 0);
 }
 
-/*
- * implement the .section pseudo op:
- *     .section name {, "flags"}
- *                ^         ^
- *                |         +--- optional flags: 'b' for bss
- *                |                              'i' for info
- *                +-- section name               'l' for lib
- *                                               'n' for noload
- *                                               'o' for over
- *                                               'w' for data
- *                                              'd' (apparently m88k for data)
- *                                               'x' for text
- *                                              'r' for read-only data
- *                                              's' for shared data (PE)
- * But if the argument is not a quoted string, treat it as a
- * subsegment number.
- */
+/* Implement the .section pseudo op:
+       .section name {, "flags"}
+                  ^         ^
+                  |         +--- optional flags: 'b' for bss
+                  |                              'i' for info
+                  +-- section name               'l' for lib
+                                                 'n' for noload
+                                                 'o' for over
+                                                 'w' for data
+                                                'd' (apparently m88k for data)
+                                                 'x' for text
+                                                'r' for read-only data
+                                                's' for shared data (PE)
+   But if the argument is not a quoted string, treat it as a
+   subsegment number.
+
+   Note the 'a' flag is silently ignored.  This allows the same
+   .section directive to be parsed in both ELF and COFF formats.  */
 
 void
 obj_coff_section (ignore)
@@ -1464,11 +1467,14 @@ obj_coff_section (ignore)
                {
                case 'b': flags |= SEC_ALLOC; flags &=~ SEC_LOAD; break;
                case 'n': flags &=~ SEC_LOAD; flags |= SEC_NEVER_LOAD; break;
+
+               case 's': flags |= SEC_SHARED; /* fall through */
                case 'd': flags |= SEC_DATA | SEC_LOAD; /* fall through */
                case 'w': flags &=~ SEC_READONLY; break;
+
+               case 'a': break; /* For compatability with ELF.  */
                case 'x': flags |= SEC_CODE | SEC_LOAD; break;
                case 'r': flags |= SEC_READONLY; break;
-               case 's': flags |= SEC_SHARED; break;
 
                case 'i': /* STYP_INFO */
                case 'l': /* STYP_LIB */
@@ -3420,6 +3426,19 @@ remove_subsegs ()
 unsigned long machine;
 int coff_flags;
 
+#ifndef SUB_SEGMENT_ALIGN
+#ifdef HANDLE_ALIGN
+/* The last subsegment gets an aligment corresponding to the alignment
+   of the section.  This allows proper nop-filling at the end of
+   code-bearing sections.  */
+#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN)                                        \
+  (!(FRCHAIN)->frch_next || (FRCHAIN)->frch_next->frch_seg != (SEG)    \
+   ? get_recorded_alignment (SEG) : 0)
+#else
+#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 1
+#endif
+#endif
+
 extern void
 write_object_file ()
 {
@@ -3443,28 +3462,27 @@ write_object_file ()
 
   string_byte_count = 4;
 
+  /* Run through all the sub-segments and align them up.  Also
+     close any open frags.  We tack a .fill onto the end of the
+     frag chain so that any .align's size can be worked by looking
+     at the next frag.  */
   for (frchain_ptr = frchain_root;
        frchain_ptr != (struct frchain *) NULL;
        frchain_ptr = frchain_ptr->frch_next)
     {
-      /* Run through all the sub-segments and align them up.  Also
-        close any open frags.  We tack a .fill onto the end of the
-        frag chain so that any .align's size can be worked by looking
-        at the next frag.  */
+      int alignment;
 
       subseg_set (frchain_ptr->frch_seg, frchain_ptr->frch_subseg);
 
-#ifndef SUB_SEGMENT_ALIGN
-#define SUB_SEGMENT_ALIGN(SEG) 1
-#endif
+      alignment = SUB_SEGMENT_ALIGN (now_seg, frchain_ptr);
+
 #ifdef md_do_align
-      md_do_align (SUB_SEGMENT_ALIGN (now_seg), (char *) NULL, 0, 0,
-                  alignment_done);
+      md_do_align (alignment, (char *) NULL, 0, 0, alignment_done);
 #endif
       if (subseg_text_p (now_seg))
-       frag_align_code (SUB_SEGMENT_ALIGN (now_seg), 0);
+       frag_align_code (alignment, 0);
       else
-       frag_align (SUB_SEGMENT_ALIGN (now_seg), 0, 0);
+       frag_align (alignment, 0, 0);
 
 #ifdef md_do_align
     alignment_done:
@@ -3613,7 +3631,7 @@ write_object_file ()
 #if 0
   /* Recent changes to write need this, but where it should
      go is up to Ken..  */
-  if (bfd_close_all_done (abfd) == false)
+  if (!bfd_close_all_done (abfd))
     as_fatal (_("Can't close %s: %s"), out_file_name,
              bfd_errmsg (bfd_get_error ()));
 #else
@@ -4084,8 +4102,8 @@ obj_coff_lcomm (ignore)
 
 static void
 fixup_mdeps (frags, h, this_segment)
-     fragS * frags;
-     object_headers * h;
+     fragS *frags;
+     object_headers *h ATTRIBUTE_UNUSED;
      segT this_segment;
 {
   subseg_change (this_segment, 0);
@@ -4609,8 +4627,8 @@ const pseudo_typeS coff_pseudo_table[] =
 #endif
   {"version", s_ignore, 0},
   {"ABORT", s_abort, 0},
-#ifdef TC_M88K
-  /* The m88k uses sdef instead of def.  */
+#if defined( TC_M88K ) || defined ( TC_TIC4X )
+  /* The m88k and tic4x uses sdef instead of def.  */
   {"sdef", obj_coff_def, 0},
 #endif
   {NULL, NULL, 0}              /* end sentinel */
@@ -4645,6 +4663,7 @@ const struct format_ops coff_format_ops =
   coff_frob_symbol,
   0,   /* frob_file */
   0,   /* frob_file_before_adjust */
+  0,   /* frob_file_before_fix */
   coff_frob_file_after_relocs,
   0,   /* s_get_size */
   0,   /* s_set_size */