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: [PATCH] Fix PR middle-end/15486


> You mean that .bss variables are *not* placed in .bss.foo?
> I think that's a mistake.

Revised version attached.  As noted by Jason, we call resolve_unique_section 
in asm_emit_uninitialised, but we don't use the result.  So the patch again 
reverts Jason's change and causes asm_emit_uninitialised to return early if a 
custom section is requested.

[eric@localhost native]$ cat pr15486.c
/* PR middle-end/15486 */
/* Origin: Jonathan Larmour <jifl-bugzilla@jifvik.org> */

/* { dg-do compile { target *-*-linux* } } */
/* { dg-options "-fdata-sections" } */

int x;

/* { dg-final { scan-assembler "comm" } } */
[eric@localhost native]$ gcc/xgcc -Bgcc -S -fdata-sections pr15486.c
[eric@localhost native]$ cat pr15486.s
        .file   "pr15486.c"
        .comm   x,4,4
        .ident  "GCC: (GNU) 4.0.0 20041215 (experimental)"
        .section        .note.GNU-stack,"",@progbits
[eric@localhost native]$ gcc/xgcc -Bgcc -S -fdata-sections -fno-common 
pr15486.c
[eric@localhost native]$ cat pr15486.s
        .file   "pr15486.c"
.globl x
        .section        .bss.x,"aw",@nobits
        .align 4
        .type   x, @object
        .size   x, 4
x:
        .zero   4
        .ident  "GCC: (GNU) 4.0.0 20041215 (experimental)"
        .section        .note.GNU-stack,"",@progbits


Bootstrapped/regtested on amd64-mandrake-linux-gnu.


2004-12-17  Eric Botcazou  <ebotcazou@libertysurf.fr>

	PR middle-end/15486
	* varasm.c (asm_emit_uninitialised): Return early if
	a custom section is requested.
	(assemble_variable): Revert 2002-03-15 patch.


-- 
Eric Botcazou
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.468
diff -u -p -r1.468 varasm.c
--- varasm.c	9 Dec 2004 10:54:38 -0000	1.468
+++ varasm.c	16 Dec 2004 19:26:41 -0000
@@ -1442,9 +1442,16 @@ asm_emit_uninitialised (tree decl, const
 	destination = asm_dest_common;
     }
 
+  if (destination != asm_dest_common)
+    {
+      resolve_unique_section (decl, 0, flag_data_sections);
+      /* Custom sections don't belong here.  */
+      if (DECL_SECTION_NAME (decl))
+        return false;
+    }
+
   if (destination == asm_dest_bss)
     globalize_decl (decl);
-  resolve_unique_section (decl, 0, flag_data_sections);
 
   if (flag_shared_data)
     {
@@ -1625,16 +1632,6 @@ assemble_variable (tree decl, int top_le
   if (DECL_PRESERVE_P (decl))
     targetm.asm_out.mark_decl_preserved (name);
 
-  /* 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 = compute_reloc_for_constant (DECL_INITIAL (decl));
-      output_addressed_constants (DECL_INITIAL (decl));
-    }
-  resolve_unique_section (decl, reloc, flag_data_sections);
-
   /* Handle uninitialized definitions.  */
 
   /* If the decl has been given an explicit section name, then it
@@ -1688,7 +1685,17 @@ assemble_variable (tree decl, int top_le
   if (TREE_PUBLIC (decl) && DECL_NAME (decl))
     globalize_decl (decl);
 
+  /* 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 = compute_reloc_for_constant (DECL_INITIAL (decl));
+      output_addressed_constants (DECL_INITIAL (decl));
+    }
+
   /* Switch to the appropriate section.  */
+  resolve_unique_section (decl, reloc, flag_data_sections);
   variable_section (decl, reloc);
 
   /* dbxout.c needs to know this.  */

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