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]

PATCH for optimization/6871


A global variable such as

  const int i = 0;

used to live in .rodata/.text.  The recent BSS support work caused it to
move to .bss, where it doesn't take up space in the executable.  Ulrich
points out in the PR that this is a bad idea for readonly variables, as in
.rodata they can be shared between processes, but in .bss they take up
space in each process.  Fixed thus.

Tested i686-pc-linux-gnu, applied to trunk and 3.3.  Testcase in
gcc.dg/section1.c

2003-03-14  Jason Merrill  <jason at redhat dot com>

	PR optimization/6871
	* varasm.c (assemble_variable): Leave constant zeroes in .rodata.

*** varasm.c.~1~	2003-03-10 11:45:17.000000000 -0500
--- varasm.c	2003-03-14 15:36:43.000000000 -0500
*************** assemble_variable (decl, top_level, at_e
*** 1551,1556 ****
--- 1551,1558 ----
    else if (DECL_INITIAL (decl) == 0
  	   || DECL_INITIAL (decl) == error_mark_node
  	   || (flag_zero_initialized_in_bss
+ 	       /* Leave constant zeroes in .rodata so they can be shared.  */
+ 	       && !TREE_READONLY (decl)
  	       && initializer_zerop (DECL_INITIAL (decl))))
      {
        unsigned HOST_WIDE_INT size = tree_low_cst (DECL_SIZE_UNIT (decl), 1);

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