This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Xtensa: fix section flags for bss sections


Some Xtensa targets support multiple bss sections.  (Any section with a
name ending with ".bss" is treated as a bss section.)  This patch fixes
the flags for such sections to include SECTION_BSS.  Tested with the
xtensa-elf target and committed to the mainline.
2002-09-04  Bob Wilson  <bob.wilson@acm.org>

        * config/xtensa/elf.h (TARGET_SECTION_TYPE_FLAGS): Define to
        xtensa_multibss_section_type_flags.
        * config/xtensa/xtensa.c (xtensa_multibss_section_type_flags): Define.

Index: elf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/xtensa/elf.h,v
retrieving revision 1.5
diff -c -3 -r1.5 elf.h
*** elf.h	29 Jul 2002 18:07:09 -0000	1.5
--- elf.h	4 Sep 2002 16:16:59 -0000
***************
*** 24,29 ****
--- 24,31 ----
      builtin_define ("__ELF__");					\
    } while (0)
  
+ #define TARGET_SECTION_TYPE_FLAGS xtensa_multibss_section_type_flags
+ 
  /* Don't assume anything about the header files. */
  #define NO_IMPLICIT_EXTERN_C
  
Index: xtensa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/xtensa/xtensa.c,v
retrieving revision 1.18
diff -c -3 -r1.18 xtensa.c
*** xtensa.c	11 Aug 2002 18:48:52 -0000	1.18
--- xtensa.c	4 Sep 2002 16:16:59 -0000
***************
*** 197,204 ****
  static enum machine_mode xtensa_find_mode_for_size PARAMS ((unsigned));
  static struct machine_function * xtensa_init_machine_status PARAMS ((void));
  static void printx PARAMS ((FILE *, signed int));
! static void xtensa_select_rtx_section PARAMS ((enum machine_mode, rtx,
! 					       unsigned HOST_WIDE_INT));
  static void xtensa_encode_section_info PARAMS ((tree, int));
  
  static rtx frame_size_const;
--- 197,206 ----
  static enum machine_mode xtensa_find_mode_for_size PARAMS ((unsigned));
  static struct machine_function * xtensa_init_machine_status PARAMS ((void));
  static void printx PARAMS ((FILE *, signed int));
! static unsigned int xtensa_multibss_section_type_flags
!   PARAMS ((tree, const char *, int));
! static void xtensa_select_rtx_section
!   PARAMS ((enum machine_mode, rtx, unsigned HOST_WIDE_INT));
  static void xtensa_encode_section_info PARAMS ((tree, int));
  
  static rtx frame_size_const;
***************
*** 2745,2750 ****
--- 2747,2780 ----
  
    return 0;
  }
+ 
+ 
+ /* Some Xtensa targets support multiple bss sections.  If the section
+    name ends with ".bss", add SECTION_BSS to the flags.  */
+ 
+ static unsigned int
+ xtensa_multibss_section_type_flags (decl, name, reloc)
+      tree decl;
+      const char *name;
+      int reloc;
+ {
+   unsigned int flags = default_section_type_flags (decl, name, reloc);
+   const char *suffix;
+ 
+   suffix = strrchr (name, '.');
+   if (suffix && strcmp (suffix, ".bss") == 0)
+     {
+       if (!decl || (TREE_CODE (decl) == VAR_DECL
+ 		    && DECL_INITIAL (decl) == NULL_TREE))
+ 	flags |= SECTION_BSS;  /* @nobits */
+       else
+ 	warning ("only uninitialized variables can be placed in a "
+ 		 ".bss section");
+     }
+ 
+   return flags;
+ }
+ 
  
  /* The literal pool stays with the function.  */
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]