This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH to varasm.c
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 13 Mar 2002 14:19:17 +0000
- Subject: PATCH to varasm.c
Kaveh's recent change to assemble_variable broke C++ vague linkage, as
asm_emit_uninitialized didn't handle weak symbols. Fixed thus.
Booted and tested i686-pc-linux-gnu, applied to trunk only, as Kaveh's
change is only on the trunk.
Test in g++.old-deja/g++.other/comdat3.C. I used the old-deja harness
because dg.exp doesn't support multi-file testcases yet.
2002-03-13 Jason Merrill <jason@redhat.com>
* varasm.c (globalize_decl): New fn.
(assemble_start_function): Use it.
(asm_emit_uninitialized): Use it.
(assemble_alias): Use it.
(assemble_variable): Use it.
*** varasm.c.~1~ Tue Mar 12 01:50:44 2002
--- varasm.c Wed Mar 13 13:57:32 2002
*************** static void mark_weak_decls PARAMS ((vo
*** 171,176 ****
--- 171,177 ----
#if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
static void remove_from_pending_weak_list PARAMS ((const char *));
#endif
+ static void globalize_decl PARAMS ((tree));
static void maybe_assemble_visibility PARAMS ((tree));
static int in_named_entry_eq PARAMS ((const PTR, const PTR));
static hashval_t in_named_entry_hash PARAMS ((const PTR));
*************** assemble_start_function (decl, fnname)
*** 1237,1258 ****
weak_global_object_name = name;
}
! #if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
! if (DECL_WEAK (decl))
! {
! #ifdef ASM_WEAKEN_DECL
! ASM_WEAKEN_DECL (asm_out_file, decl, fnname, 0);
! #else
! ASM_WEAKEN_LABEL (asm_out_file, fnname);
! #endif
! /* Remove this function from the pending weak list so that
! we do not emit multiple .weak directives for it. */
! remove_from_pending_weak_list
! (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
! }
! else
! #endif
! ASM_GLOBALIZE_LABEL (asm_out_file, fnname);
maybe_assemble_visibility (decl);
}
--- 1238,1244 ----
weak_global_object_name = name;
}
! globalize_decl (decl);
maybe_assemble_visibility (decl);
}
*************** asm_emit_uninitialised (decl, name, size
*** 1443,1448 ****
--- 1429,1435 ----
{
#ifdef ASM_EMIT_BSS
case asm_dest_bss:
+ globalize_decl (decl);
ASM_EMIT_BSS (decl, name, size, rounded);
break;
#endif
*************** assemble_variable (decl, top_level, at_e
*** 1657,1680 ****
/* First make the assembler name(s) global if appropriate. */
if (TREE_PUBLIC (decl) && DECL_NAME (decl))
! {
! #if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
! if (DECL_WEAK (decl))
! {
! #ifdef ASM_WEAKEN_DECL
! ASM_WEAKEN_DECL (asm_out_file, decl, name, 0);
! #else
! ASM_WEAKEN_LABEL (asm_out_file, name);
! #endif
! /* Remove this variable from the pending weak list so that
! we do not emit multiple .weak directives for it. */
! remove_from_pending_weak_list
! (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
! }
! else
! #endif
! ASM_GLOBALIZE_LABEL (asm_out_file, name);
! }
/* Output any data that we will need to use the address of. */
if (DECL_INITIAL (decl) == error_mark_node)
--- 1644,1650 ----
/* First make the assembler name(s) global if appropriate. */
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)
*************** remove_from_pending_weak_list (name)
*** 5151,5156 ****
--- 5121,5152 ----
}
#endif /* defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL) */
+ /* Emit the assembly bits to indicate that DECL is globally visible. */
+
+ static void
+ globalize_decl (decl)
+ tree decl;
+ {
+ const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+
+ #if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
+ if (DECL_WEAK (decl))
+ {
+ #ifdef ASM_WEAKEN_DECL
+ ASM_WEAKEN_DECL (asm_out_file, decl, name, 0);
+ #else
+ ASM_WEAKEN_LABEL (asm_out_file, name);
+ #endif
+ /* Remove this function from the pending weak list so that
+ we do not emit multiple .weak directives for it. */
+ remove_from_pending_weak_list (name);
+ return;
+ }
+ /* else */
+ #endif
+ ASM_GLOBALIZE_LABEL (asm_out_file, name);
+ }
+
/* Emit an assembler directive to make the symbol for DECL an alias to
the symbol for TARGET. */
*************** assemble_alias (decl, target)
*** 5171,5192 ****
if (TREE_PUBLIC (decl))
{
! #if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
! if (DECL_WEAK (decl))
! {
! #ifdef ASM_WEAKEN_DECL
! ASM_WEAKEN_DECL (asm_out_file, decl, name, 0);
! #else
! ASM_WEAKEN_LABEL (asm_out_file, name);
! #endif
! /* Remove this function from the pending weak list so that
! we do not emit multiple .weak directives for it. */
! remove_from_pending_weak_list
! (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
! }
! else
! #endif
! ASM_GLOBALIZE_LABEL (asm_out_file, name);
maybe_assemble_visibility (decl);
}
--- 5167,5173 ----
if (TREE_PUBLIC (decl))
{
! globalize_decl (decl);
maybe_assemble_visibility (decl);
}