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]

Re: [RFC] PowerPC select_section / unique_section


>>>>> Richard Henderson writes:

Richard> Err, no, that's not what I mean.  A boolean field (not function)
Richard> that says whether small data continues to be read only as well.

	Okay, I did not notice that the targetm structure now has
constants in addition to functions.  I also misunderstood that sdata
normally does permit symbols which would have been placed in a readonly
section. 

	Is the following patch more what you meant?

Thanks, David


	* target-def.h (TARGET_HAVE_SRODATA_SECTION): New macro.
	* target.h (gcc_target): Add have_srodata_section member.
	* varasm.c (section_category): Add SECCAT_SRODATA.
	(categorize_decl_for_section): Return SECCAT_SRODATA for sdata if
	READONLY_SDATA_SECTION defined.
	(decl_readonly_section_1): True for SECCAT_SRODATA also.
	(default_elf_select_section_1): Map SECCAT_SRODATA to .sdata2.
	(default_unique_section_1): Likewise.

Index: target-def.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/target-def.h,v
retrieving revision 1.30
diff -c -p -r1.30 target-def.h
*** target-def.h	21 Aug 2002 02:41:44 -0000	1.30
--- target-def.h	4 Sep 2002 16:35:00 -0000
*************** Foundation, 59 Temple Place - Suite 330,
*** 118,123 ****
--- 118,127 ----
  #define TARGET_HAVE_TLS false
  #endif
  
+ #ifndef TARGET_HAVE_SRODATA_SECTION
+ #define TARGET_HAVE_SRODATA_SECTION false
+ #endif
+ 
  #ifndef TARGET_ASM_EXCEPTION_SECTION
  #define TARGET_ASM_EXCEPTION_SECTION default_exception_section
  #endif
*************** Foundation, 59 Temple Place - Suite 330,
*** 253,259 ****
    TARGET_STRIP_NAME_ENCODING,			\
    TARGET_HAVE_NAMED_SECTIONS,			\
    TARGET_HAVE_CTORS_DTORS,			\
!   TARGET_HAVE_TLS				\
  }
  
  #include "hooks.h"
--- 257,264 ----
    TARGET_STRIP_NAME_ENCODING,			\
    TARGET_HAVE_NAMED_SECTIONS,			\
    TARGET_HAVE_CTORS_DTORS,			\
!   TARGET_HAVE_TLS,				\
!   TARGET_HAVE_SRODATA_SECTION			\
  }
  
  #include "hooks.h"
Index: target.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/target.h,v
retrieving revision 1.33
diff -c -p -r1.33 target.h
*** target.h	21 Aug 2002 02:41:44 -0000	1.33
--- target.h	4 Sep 2002 16:35:00 -0000
*************** struct gcc_target
*** 262,267 ****
--- 262,270 ----
  
    /* True if thread-local storage is supported.  */
    bool have_tls;
+ 
+   /* True if a small readonly data section is supported.  */
+   bool have_srodata_section;
  };
  
  extern struct gcc_target targetm;
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/varasm.c,v
retrieving revision 1.304
diff -c -p -r1.304 varasm.c
*** varasm.c	4 Sep 2002 01:56:11 -0000	1.304
--- varasm.c	4 Sep 2002 16:35:01 -0000
*************** enum section_category
*** 4898,4903 ****
--- 4898,4904 ----
    SECCAT_RODATA_MERGE_STR,
    SECCAT_RODATA_MERGE_STR_INIT,
    SECCAT_RODATA_MERGE_CONST,
+   SECCAT_SRODATA,
  
    SECCAT_DATA,
  
*************** categorize_decl_for_section (decl, reloc
*** 4999,5004 ****
--- 5000,5007 ----
      {
        if (ret == SECCAT_BSS)
  	ret = SECCAT_SBSS;
+       else if (targetm.have_srodata_section && ret == SECCAT_RODATA)
+ 	ret = SECCAT_SRODATA;
        else
  	ret = SECCAT_SDATA;
      }
*************** decl_readonly_section_1 (decl, reloc, sh
*** 5026,5031 ****
--- 5029,5035 ----
      case SECCAT_RODATA_MERGE_STR:
      case SECCAT_RODATA_MERGE_STR_INIT:
      case SECCAT_RODATA_MERGE_CONST:
+     case SECCAT_SRODATA:
        return true;
        break;
      default:
*************** default_elf_select_section_1 (decl, relo
*** 5069,5074 ****
--- 5073,5081 ----
      case SECCAT_RODATA_MERGE_CONST:
        mergeable_constant_section (DECL_MODE (decl), align, 0);
        break;
+     case SECCAT_SRODATA:
+       named_section (NULL_TREE, ".sdata2", reloc);
+       break;
      case SECCAT_DATA:
        data_section ();
        break;
*************** default_unique_section_1 (decl, reloc, s
*** 5140,5145 ****
--- 5147,5155 ----
      case SECCAT_RODATA_MERGE_STR_INIT:
      case SECCAT_RODATA_MERGE_CONST:
        prefix = one_only ? ".gnu.linkonce.r." : ".rodata.";
+       break;
+     case SECCAT_SRODATA:
+       prefix = one_only ? ".gnu.linkonce.s2." : ".sdata2.";
        break;
      case SECCAT_DATA:
      case SECCAT_DATA_REL:


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