This is the mail archive of the gcc-bugs@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: PATCH: Re: optimization/7171: Not enough room for program headers (allocated 7, need 8)


On Wed, Jul 31, 2002 at 10:26:32AM -0700, H. J. Lu wrote:
> 	* output.h (decl_readonly_section): New prototype.
> 	(DECL_READONLY_SECTION): Use decl_readonly_section.
> 	* varasm.c (decl_readonly_section): New.

I like it.  Except for the maintaining the old macro thing.

I applied the following version.


r~


        * output.h (DECL_READONLY_SECTION): Remove.
        (decl_readonly_section): Declare.
        * varasm.c (decl_readonly_section): New.
        (default_section_type_flags, default_select_section): Use it.
        * config/arm/pe.c (arm_pe_unique_section): Likewise.
        * config/i386/interix.c (i386_pe_unique_section): Likewise.
        * config/i386/winnt.c (i386_pe_unique_section): Likewise.
        * config/mcore/mcore.c (mcore_unique_section): Likewise.
        * config/mips/mips.c (mips_unique_section): Likewise.

Index: output.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/output.h,v
retrieving revision 1.107
diff -c -p -d -u -r1.107 output.h
--- output.h	4 Jun 2002 07:07:51 -0000	1.107
+++ output.h	1 Aug 2002 23:25:05 -0000
@@ -468,16 +468,9 @@ extern struct rtx_def *current_output_in
    The precise value is the insn being output, to pass to error_for_asm.  */
 extern rtx this_is_asm_operands;
 
-/* Decide whether DECL needs to be in a writable section.  RELOC is the same
-   as for SELECT_SECTION.  */
-
-#define DECL_READONLY_SECTION(DECL,RELOC)		\
-  (TREE_READONLY (DECL)					\
-   && ! TREE_THIS_VOLATILE (DECL)			\
-   && DECL_INITIAL (DECL)				\
-   && (DECL_INITIAL (DECL) == error_mark_node		\
-       || TREE_CONSTANT (DECL_INITIAL (DECL)))		\
-   && ! (RELOC && (flag_pic || DECL_ONE_ONLY (DECL))))
+/* Decide whether DECL needs to be in a writable section.
+   RELOC is the same as for SELECT_SECTION.  */
+extern bool decl_readonly_section PARAMS ((tree, int));
 
 /* User label prefix in effect for this compilation.  */
 extern const char *user_label_prefix;
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.298
diff -c -p -d -u -r1.298 varasm.c
--- varasm.c	1 Aug 2002 21:59:35 -0000	1.298
+++ varasm.c	1 Aug 2002 23:25:05 -0000
@@ -4712,7 +4712,7 @@ default_section_type_flags (decl, name, 
 
   if (decl && TREE_CODE (decl) == FUNCTION_DECL)
     flags = SECTION_CODE;
-  else if (decl && DECL_READONLY_SECTION (decl, reloc))
+  else if (decl && decl_readonly_section (decl, reloc))
     flags = 0;
   else
     flags = SECTION_WRITE;
@@ -4872,7 +4872,7 @@ default_select_section (decl, reloc, ali
 
   if (DECL_P (decl))
     {
-      if (DECL_READONLY_SECTION (decl, reloc))
+      if (decl_readonly_section (decl, reloc))
 	readonly = true;
     }
   else if (TREE_CODE (decl) == CONSTRUCTOR)
@@ -5009,6 +5009,25 @@ categorize_decl_for_section (decl, reloc
     }
 
   return ret;
+}
+
+bool
+decl_readonly_section (decl, reloc)
+     tree decl;
+     int reloc;
+{
+  switch (categorize_decl_for_section (decl, reloc))
+    {
+    case SECCAT_RODATA:
+    case SECCAT_RODATA_MERGE_STR:
+    case SECCAT_RODATA_MERGE_STR_INIT:
+    case SECCAT_RODATA_MERGE_CONST:
+      return true;
+      break;
+    default:
+      return false;
+      break;
+    }
 }
 
 /* Select a section based on the above categorization.  */
Index: config/arm/pe.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/pe.c,v
retrieving revision 1.15
diff -c -p -d -u -r1.15 pe.c
--- config/arm/pe.c	19 May 2002 07:55:31 -0000	1.15
+++ config/arm/pe.c	1 Aug 2002 23:25:06 -0000
@@ -264,7 +264,7 @@ arm_pe_unique_section (decl, reloc)
      (everything from the $ on is stripped).  */
   if (TREE_CODE (decl) == FUNCTION_DECL)
     prefix = ".text$";
-  else if (DECL_READONLY_SECTION (decl, reloc))
+  else if (decl_readonly_section (decl, reloc))
     prefix = ".rdata$";
   else
     prefix = ".data$";
Index: config/i386/interix.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/interix.c,v
retrieving revision 1.9
diff -c -p -d -u -r1.9 interix.c
--- config/i386/interix.c	19 May 2002 07:55:34 -0000	1.9
+++ config/i386/interix.c	1 Aug 2002 23:25:06 -0000
@@ -112,7 +112,7 @@ i386_pe_unique_section (decl, reloc)
      without a .rdata section.  */
   if (TREE_CODE (decl) == FUNCTION_DECL)
     prefix = ".text$";
-  else if (DECL_READONLY_SECTION (decl, reloc))
+  else if (decl_readonly_section (decl, reloc))
     prefix = ".rdata$";
   else
     prefix = ".data$";
Index: config/i386/winnt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/winnt.c,v
retrieving revision 1.32
diff -c -p -d -u -r1.32 winnt.c
--- config/i386/winnt.c	19 May 2002 07:55:34 -0000	1.32
+++ config/i386/winnt.c	1 Aug 2002 23:25:06 -0000
@@ -472,7 +472,7 @@ i386_pe_unique_section (decl, reloc)
      without a .rdata section.  */
   if (TREE_CODE (decl) == FUNCTION_DECL)
     prefix = ".text$";
-  else if (DECL_READONLY_SECTION (decl, reloc))
+  else if (decl_readonly_section (decl, reloc))
     prefix = ".rdata$";
   else
     prefix = ".data$";
@@ -518,7 +518,7 @@ i386_pe_section_type_flags (decl, name, 
 
   if (decl && TREE_CODE (decl) == FUNCTION_DECL)
     flags = SECTION_CODE;
-  else if (decl && DECL_READONLY_SECTION (decl, reloc))
+  else if (decl && decl_readonly_section (decl, reloc))
     flags = 0;
   else
     {
Index: config/mcore/mcore.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mcore/mcore.c,v
retrieving revision 1.36
diff -c -p -d -u -r1.36 mcore.c
--- config/mcore/mcore.c	30 Jul 2002 02:24:17 -0000	1.36
+++ config/mcore/mcore.c	1 Aug 2002 23:25:06 -0000
@@ -3540,7 +3540,7 @@ mcore_unique_section (decl, reloc)
     prefix = ".text$";
   /* For compatibility with EPOC, we ignore the fact that the
      section might have relocs against it.  */
-  else if (DECL_READONLY_SECTION (decl, 0))
+  else if (decl_readonly_section (decl, 0))
     prefix = ".rdata$";
   else
     prefix = ".data$";
Index: config/mips/mips.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.c,v
retrieving revision 1.219
diff -c -p -d -u -r1.219 mips.c
--- config/mips/mips.c	29 Jul 2002 22:21:41 -0000	1.219
+++ config/mips/mips.c	1 Aug 2002 23:25:07 -0000
@@ -10310,7 +10310,7 @@ mips_unique_section (decl, reloc)
 	 read-only data if possible, in order to reduce RAM
 	 usage.  */
 
-      if (DECL_READONLY_SECTION (decl, reloc))
+      if (decl_readonly_section (decl, reloc))
 	sec = 1;
       else if (size > 0 && size <= mips_section_threshold)
 	sec = 3;
@@ -10325,7 +10325,7 @@ mips_unique_section (decl, reloc)
 
       if (size > 0 && size <= mips_section_threshold)
 	sec = 3;
-      else if (DECL_READONLY_SECTION (decl, reloc))
+      else if (decl_readonly_section (decl, reloc))
 	sec = 1;
       else
 	sec = 2;


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