This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix notice_global_symbol
- From: Jan Hubicka <jh at suse dot cz>
- To: rth at redhat dot com, gcc-patches at gcc dot gnu dot org
- Date: Fri, 10 Oct 2003 23:25:34 +0200
- Subject: Fix notice_global_symbol
Hi,
this patch fixes several problems, most of them noticed by Richard B. Kreckel.
One problem has been dealing with uninitialized variables that are not output into common section like:
/* { dg-final { scan-assembler "_GLOBAL__I_foobar" } } */
struct foo { foo (); };
foo foobar;
Other problem is the fact that we currently re-set the first_weak_symbol and
first_global_symbol until both are set.
Last problem is missing DECL_NAME check as reported elsewhere in bugzilla.
Bootstrapped/regtested i386. OK?
Honza
Fri Oct 10 23:20:51 CEST 2003 Jan Hubicka <jh@suse.cz>
* varasm.c (notice_global_symbol): Fix handling of variables; avoid
re-computing of variable.
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.390
diff -c -3 -p -r1.390 varasm.c
*** varasm.c 2 Oct 2003 14:47:51 -0000 1.390
--- varasm.c 10 Oct 2003 21:20:38 -0000
*************** default_ctor_section_asm_out_constructor
*** 1041,1053 ****
void
notice_global_symbol (tree decl)
{
! if ((!first_global_object_name || !weak_global_object_name)
! && TREE_PUBLIC (decl) && !DECL_COMMON (decl)
! && !DECL_EXTERNAL (decl)
! && (TREE_CODE (decl) == FUNCTION_DECL
! || (TREE_CODE (decl) == VAR_DECL
! && (DECL_INITIAL (decl) != 0
! && DECL_INITIAL (decl) != error_mark_node))))
{
const char *p;
char *name;
--- 1041,1064 ----
void
notice_global_symbol (tree decl)
{
! const char **type = &first_global_object_name;
!
! if (first_global_object_name
! || !TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)
! || !DECL_NAME (decl)
! || (TREE_CODE (decl) != FUNCTION_DECL
! && (TREE_CODE (decl) != VAR_DECL
! || (DECL_COMMON (decl)
! && (DECL_INITIAL (decl) == 0
! || DECL_INITIAL (decl) == error_mark_node)))))
! return;
!
! /* We win when global object is found, but it is usefull to know about weak
! symbol as well so we can produce nicer unique names. */
! if (DECL_WEAK (decl) || DECL_ONE_ONLY (decl))
! type = &weak_global_object_name;
!
! if (!*type)
{
const char *p;
char *name;
*************** notice_global_symbol (tree decl)
*** 1056,1065 ****
p = (* targetm.strip_name_encoding) (XSTR (XEXP (decl_rtl, 0), 0));
name = xstrdup (p);
! if (! DECL_WEAK (decl) && ! DECL_ONE_ONLY (decl))
! first_global_object_name = name;
! else
! weak_global_object_name = name;
}
}
--- 1067,1073 ----
p = (* targetm.strip_name_encoding) (XSTR (XEXP (decl_rtl, 0), 0));
name = xstrdup (p);
! *type = name;
}
}