diff options
author | Alan Modra <amodra@bigpond.net.au> | 2002-03-01 06:00:38 +0000 |
---|---|---|
committer | Alan Modra <amodra@gcc.gnu.org> | 2002-03-01 16:30:38 +1030 |
commit | 79c4e63fcb67a28be17dc1e964014fa5fc2a316e (patch) | |
tree | 146341b9078d1b8ac0de9b80ea4f78629e3a7048 /gcc/varasm.c | |
parent | 562ff1637faf0ce60e65c13a9a7c27015b6226bc (diff) | |
download | gcc-79c4e63fcb67a28be17dc1e964014fa5fc2a316e.zip gcc-79c4e63fcb67a28be17dc1e964014fa5fc2a316e.tar.gz gcc-79c4e63fcb67a28be17dc1e964014fa5fc2a316e.tar.bz2 |
tm.texi (ASM_WEAKEN_DECL): Document.
* doc/tm.texi (ASM_WEAKEN_DECL): Document.
(ASM_WEAKEN_LABEL): Mention ASM_WEAKEN_DECL.
(SUPPORTS_WEAK): Likewise.
* output.h (add_weak): Add tree param.
* varasm.c (add_weak): Likewise. Save decl.
(struct weak_syms): Add decl field.
(mark_weak_decls): New function.
(init_varasm_once): ggc_add_root mark_weak_decls.
(assemble_start_function): Use ASM_WEAKEN_DECL.
(assemble_variable): Likewise.
(assemble_alias): Likewise.
(declare_weak): Pass decl to add_weak.
(weak_finish): Use ASM_WEAKEN_DECL. Try to find decl.
(remove_from_pending_weak_list): Declare and define for
ASM_WEAKEN_DECL.
* c-pragma.c (handle_pragma_weak): Adjust add_weak call.
* c-pragma.h (HANDLE_PRAGMA_WEAK): Define if ASM_WEAKEN_DECL too.
* defaults.h (SUPPORTS_WEAK): Likewise.
* config/rs6000/linux64.h (ASM_DECLARE_FUNCTION_NAME): Don't emit
.weak for code sym. Do emit .size for descriptor sym.
(ASM_DECLARE_FUNCTION_SIZE): Define.
* config/rs6000/rs6000.h (ASM_WEAKEN_DECL): Define.
(ASM_OUTPUT_DEF_FROM_DECLS): Don't emit .weak here. Don't output
.lglobl unless TARGET_XCOFF. Formatting fixes.
* config/rs6000/xcoff.h (ASM_DECLARE_FUNCTION_NAME): Don't emit
.weak for code sym.
(HANDLE_PRAGMA_WEAK): Remove.
(ASM_WEAKEN_LABEL): Remove.
* config/rs6000/aix.h (HANDLE_SYSV_PRAGMA): Define.
Co-Authored-By: David Edelsohn <edelsohn@gnu.org>
From-SVN: r50181
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 69 |
1 files changed, 57 insertions, 12 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index fa69592..f8fb16c 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -42,6 +42,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "obstack.h" #include "hashtab.h" #include "c-pragma.h" +#include "c-tree.h" #include "ggc.h" #include "langhooks.h" #include "tm_p.h" @@ -166,7 +167,8 @@ static unsigned HOST_WIDE_INT array_size_for_constructor PARAMS ((tree)); static unsigned min_align PARAMS ((unsigned, unsigned)); static void output_constructor PARAMS ((tree, HOST_WIDE_INT, unsigned int)); -#ifdef ASM_WEAKEN_LABEL +static void mark_weak_decls PARAMS ((void *)); +#if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL) static void remove_from_pending_weak_list PARAMS ((const char *)); #endif static int in_named_entry_eq PARAMS ((const PTR, const PTR)); @@ -1237,10 +1239,14 @@ assemble_start_function (decl, fnname) weak_global_object_name = name; } -#ifdef ASM_WEAKEN_LABEL +#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 @@ -1644,10 +1650,14 @@ assemble_variable (decl, top_level, at_end, dont_output_data) /* First make the assembler name(s) global if appropriate. */ if (TREE_PUBLIC (decl) && DECL_NAME (decl)) { -#ifdef ASM_WEAKEN_LABEL +#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 @@ -5012,17 +5022,31 @@ output_constructor (exp, size, align) struct weak_syms { struct weak_syms * next; + tree decl; const char * name; const char * value; }; static struct weak_syms * weak_decls; +/* Mark weak_decls for garbage collection. */ + +static void +mark_weak_decls (arg) + void *arg; +{ + struct weak_syms *t; + + for (t = *(struct weak_syms **) arg; t != NULL; t = t->next) + ggc_mark_tree (t->decl); +} + /* Add function NAME to the weak symbols list. VALUE is a weak alias associated with NAME. */ int -add_weak (name, value) +add_weak (decl, name, value) + tree decl; const char *name; const char *value; { @@ -5034,6 +5058,7 @@ add_weak (name, value) return 0; weak->next = weak_decls; + weak->decl = decl; weak->name = name; weak->value = value; weak_decls = weak; @@ -5052,7 +5077,7 @@ declare_weak (decl) else if (TREE_ASM_WRITTEN (decl)) error_with_decl (decl, "weak declaration of `%s' must precede definition"); else if (SUPPORTS_WEAK) - add_weak (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), NULL); + add_weak (decl, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), NULL); else warning_with_decl (decl, "weak declaration of `%s' not supported"); @@ -5067,8 +5092,18 @@ weak_finish () if (SUPPORTS_WEAK) { struct weak_syms *t; - for (t = weak_decls; t; t = t->next) + for (t = weak_decls; t != NULL; t = t->next) { +#ifdef ASM_WEAKEN_DECL + tree decl = t->decl; + if (decl == NULL_TREE) + { + tree name = get_identifier (t->name); + if (name) + decl = lookup_name (name); + } + ASM_WEAKEN_DECL (asm_out_file, decl, t->name, t->value); +#else #ifdef ASM_OUTPUT_WEAK_ALIAS ASM_OUTPUT_WEAK_ALIAS (asm_out_file, t->name, t->value); #else @@ -5078,6 +5113,7 @@ weak_finish () ASM_WEAKEN_LABEL (asm_out_file, t->name); #endif #endif +#endif } } } @@ -5085,7 +5121,7 @@ weak_finish () /* Remove NAME from the pending list of weak symbols. This prevents the compiler from emitting multiple .weak directives which confuses some assemblers. */ -#ifdef ASM_WEAKEN_LABEL +#if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL) static void remove_from_pending_weak_list (name) const char *name; @@ -5105,7 +5141,7 @@ remove_from_pending_weak_list (name) p = &(t->next); } } -#endif /* ASM_WEAKEN_LABEL */ +#endif /* defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL) */ /* Emit an assembler directive to make the symbol for DECL an alias to the symbol for TARGET. */ @@ -5127,10 +5163,14 @@ assemble_alias (decl, target) if (TREE_PUBLIC (decl)) { -#ifdef ASM_WEAKEN_LABEL +#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 @@ -5147,12 +5187,16 @@ assemble_alias (decl, target) ASM_OUTPUT_DEF (asm_out_file, name, IDENTIFIER_POINTER (target)); #endif TREE_ASM_WRITTEN (decl) = 1; -#else -#ifdef ASM_OUTPUT_WEAK_ALIAS +#else /* !ASM_OUTPUT_DEF */ +#if defined (ASM_OUTPUT_WEAK_ALIAS) || defined (ASM_WEAKEN_DECL) if (! DECL_WEAK (decl)) warning ("only weak aliases are supported in this configuration"); +#ifdef ASM_WEAKEN_DECL + ASM_WEAKEN_DECL (asm_out_file, decl, name, IDENTIFIER_POINTER (target)); +#else ASM_OUTPUT_WEAK_ALIAS (asm_out_file, name, IDENTIFIER_POINTER (target)); +#endif TREE_ASM_WRITTEN (decl) = 1; #else warning ("alias definitions not supported in this configuration; ignored"); @@ -5232,6 +5276,7 @@ init_varasm_once () mark_const_hash_entry); ggc_add_root (&const_str_htab, 1, sizeof const_str_htab, mark_const_str_htab); + ggc_add_root (&weak_decls, 1, sizeof weak_decls, mark_weak_decls); const_alias_set = new_alias_set (); } |