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]

KDE and GCC take III


Hi,
This patch fixes the problems pointed out by Richard.  Bootstrapped/regtested i386/linux
OK now?


	* varasm.c (assemble_variable): Set reloc to 3 for error_mark
	containing pointers.
	(output_addressed_constants): Check for local/external relocations.
	* elfos.h (SELECT_SECTION): Classify data section.
	* tm.texi (SELECT_SECTION): Update documentation.
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/varasm.c,v
retrieving revision 1.229
diff -c -3 -p -r1.229 varasm.c
*** varasm.c	2001/11/23 11:21:07	1.229
--- varasm.c	2001/11/26 23:39:33
*************** assemble_variable (decl, top_level, at_e
*** 1677,1683 ****
  
    /* Output any data that we will need to use the address of.  */
    if (DECL_INITIAL (decl) == error_mark_node)
!     reloc = contains_pointers_p (TREE_TYPE (decl));
    else if (DECL_INITIAL (decl))
      reloc = output_addressed_constants (DECL_INITIAL (decl));
  
--- 1677,1683 ----
  
    /* Output any data that we will need to use the address of.  */
    if (DECL_INITIAL (decl) == error_mark_node)
!     reloc = contains_pointers_p (TREE_TYPE (decl)) ? 3 : 0;
    else if (DECL_INITIAL (decl))
      reloc = output_addressed_constants (DECL_INITIAL (decl));
  
*************** output_addressed_constants (exp)
*** 4205,4213 ****
  	tree constant = TREE_OPERAND (exp, 0);
  
  	while (TREE_CODE (constant) == COMPONENT_REF)
! 	  {
! 	    constant = TREE_OPERAND (constant, 0);
! 	  }
  
  	if (TREE_CODE_CLASS (TREE_CODE (constant)) == 'c'
  	    || TREE_CODE (constant) == CONSTRUCTOR)
--- 4205,4216 ----
  	tree constant = TREE_OPERAND (exp, 0);
  
  	while (TREE_CODE (constant) == COMPONENT_REF)
! 	  constant = TREE_OPERAND (constant, 0);
! 
! 	if (TREE_PUBLIC (constant))
! 	  reloc |= 2;
! 	else
! 	  reloc |= 1;
  
  	if (TREE_CODE_CLASS (TREE_CODE (constant)) == 'c'
  	    || TREE_CODE (constant) == CONSTRUCTOR)
*************** output_addressed_constants (exp)
*** 4215,4221 ****
  	     for addresses of variables or functions.  */
  	  output_constant_def (constant, 0);
        }
-       reloc = 1;
        break;
  
      case PLUS_EXPR:
--- 4218,4223 ----
Index: config/elfos.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/elfos.h,v
retrieving revision 1.37
diff -c -3 -p -r1.37 elfos.h
*** elfos.h	2001/11/15 17:55:26	1.37
--- elfos.h	2001/11/26 23:39:34
*************** const_section ()						\
*** 352,359 ****
  /* A C statement or statements to switch to the appropriate
     section for output of DECL.  DECL is either a `VAR_DECL' node
     or a constant of some sort.  RELOC indicates whether forming
!    the initial value of DECL requires link-time relocations.  */
  
  #undef SELECT_SECTION
  #define SELECT_SECTION(DECL, RELOC, ALIGN)			\
  {								\
--- 352,375 ----
  /* A C statement or statements to switch to the appropriate
     section for output of DECL.  DECL is either a `VAR_DECL' node
     or a constant of some sort.  RELOC indicates whether forming
!    the initial value of DECL requires link-time relocations.  
!  
!    To optimize loading of shared programs, define following subsections
!    of data section by attaching:
  
+    .rel
+      Section with this string in name contains data that do have
+      relocations, so they get grouped together and dynamic linker
+      will visit fewer pages in memory.
+    .ro
+      Marks data read only otherwise.  This is usefull with prelinking
+      as most of relocations won't be dynamically linked and thus
+      stay read only.
+    .local
+      Marks data containing relocations only to local objects.  These
+      relocation will get fully resolved by prelinking.
+  */
+ 
  #undef SELECT_SECTION
  #define SELECT_SECTION(DECL, RELOC, ALIGN)			\
  {								\
*************** const_section ()						\
*** 366,377 ****
      }								\
    else if (TREE_CODE (DECL) == VAR_DECL)			\
      {								\
!       if ((flag_pic && RELOC)					\
! 	  || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)	\
  	  || !DECL_INITIAL (DECL)				\
  	  || (DECL_INITIAL (DECL) != error_mark_node		\
  	      && !TREE_CONSTANT (DECL_INITIAL (DECL))))		\
! 	data_section ();					\
        else if (flag_merge_constants < 2)			\
  	/* C and C++ don't allow different variables to share	\
  	   the same location.  -fmerge-all-constants allows	\
--- 382,403 ----
      }								\
    else if (TREE_CODE (DECL) == VAR_DECL)			\
      {								\
!       if (!TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)	\
  	  || !DECL_INITIAL (DECL)				\
  	  || (DECL_INITIAL (DECL) != error_mark_node		\
  	      && !TREE_CONSTANT (DECL_INITIAL (DECL))))		\
! 	{							\
! 	  if (flag_pic && ((RELOC) & 2))			\
! 	    named_section (NULL_TREE, ".data.rel", RELOC);	\
! 	  else if (flag_pic && (RELOC))				\
! 	    named_section (NULL_TREE, ".data.rel.local", RELOC);\
! 	  else							\
! 	    data_section ();					\
! 	}							\
!       else if (flag_pic && ((RELOC) & 2))			\
! 	named_section (NULL_TREE, ".data.rel.ro", RELOC);	\
!       else if (flag_pic && (RELOC))				\
! 	named_section (NULL_TREE, ".data.rel.ro.local", RELOC);	\
        else if (flag_merge_constants < 2)			\
  	/* C and C++ don't allow different variables to share	\
  	   the same location.  -fmerge-all-constants allows	\
*************** const_section ()						\
*** 386,395 ****
      }								\
    else if (TREE_CODE (DECL) == CONSTRUCTOR)			\
      {								\
!       if ((flag_pic && RELOC)					\
! 	  || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)	\
! 	  || ! TREE_CONSTANT (DECL))				\
! 	data_section ();					\
        else							\
  	const_section ();					\
      }								\
--- 412,430 ----
      }								\
    else if (TREE_CODE (DECL) == CONSTRUCTOR)			\
      {								\
!       if (TREE_SIDE_EFFECTS (DECL) || ! TREE_CONSTANT (DECL))	\
! 	{							\
! 	  if (flag_pic && ((RELOC) & 2))			\
! 	    named_section (NULL_TREE, ".data.rel", RELOC);	\
! 	  else if (flag_pic && (RELOC))				\
! 	    named_section (NULL_TREE, ".data.rel.local", RELOC);\
! 	  else							\
! 	    data_section ();					\
! 	}							\
!       else if (flag_pic && ((RELOC) & 2))			\
! 	named_section (NULL_TREE, ".data.rel.ro", RELOC);	\
!       else if (flag_pic && (RELOC))				\
! 	named_section (NULL_TREE, ".data.rel.ro.local", RELOC);	\
        else							\
  	const_section ();					\
      }								\
Index: doc/tm.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/doc/tm.texi,v
retrieving revision 1.70
diff -c -3 -p -r1.70 tm.texi
*** tm.texi	2001/11/22 02:19:58	1.70
--- tm.texi	2001/11/26 23:39:38
*************** A C statement or statements to switch to
*** 5661,5667 ****
  output of @var{exp}.  You can assume that @var{exp} is either a
  @code{VAR_DECL} node or a constant of some sort.  @var{reloc}
  indicates whether the initial value of @var{exp} requires link-time
! relocations.  Select the section by calling @code{text_section} or one
  of the alternatives for other sections.  @var{align} is the constant
  alignment in bits.
  
--- 5661,5669 ----
  output of @var{exp}.  You can assume that @var{exp} is either a
  @code{VAR_DECL} node or a constant of some sort.  @var{reloc}
  indicates whether the initial value of @var{exp} requires link-time
! relocations.  Bit 1 is set when variable contains local relocations
! only, while bit 2 is set for global relocations.
! Select the section by calling @code{text_section} or one
  of the alternatives for other sections.  @var{align} is the constant
  alignment in bits.
  


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