diff options
author | Michael Meissner <meissner@gcc.gnu.org> | 1995-04-18 10:56:20 +0000 |
---|---|---|
committer | Michael Meissner <meissner@gcc.gnu.org> | 1995-04-18 10:56:20 +0000 |
commit | eb0430f02e045c3539a9d4120bc1bbde8925e7ad (patch) | |
tree | 3797b4898ef256a0d0a50f9f2fe8ea17a160bebc /gcc/varasm.c | |
parent | a07a2d17c5061bfea5a5a457c935450d7c1e979e (diff) | |
download | gcc-eb0430f02e045c3539a9d4120bc1bbde8925e7ad.zip gcc-eb0430f02e045c3539a9d4120bc1bbde8925e7ad.tar.gz gcc-eb0430f02e045c3539a9d4120bc1bbde8925e7ad.tar.bz2 |
Make weak symbols work again.
From-SVN: r9407
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index c4249a9..d822613 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -96,13 +96,23 @@ int size_directive_output; tree last_assemble_variable_decl; -/* Nonzero if at least one function definition has been seen. */ - -static int function_defined; +#if defined (HANDLE_PRAGMA_WEAK) || (defined (WEAK_ASM_OP) && defined (ASM_OUTPUT_DEF)) /* Any weak symbol declarations waiting to be emitted. */ -static tree weak_decls; +struct weak_syms +{ + struct weak_syms *next; + char *name; + char *value; +}; + +static struct weak_syms *weak_decls; +#endif + +/* Nonzero if at least one function definition has been seen. */ + +static int function_defined; struct addr_const; struct constant_descriptor; @@ -3942,15 +3952,29 @@ enum pragma_state /* Output asm to handle ``#pragma weak'' */ void -handle_pragma_weak (what, asm_out_file, name, value) +handle_pragma_weak (what, out_file, name, value) enum pragma_state what; - FILE *asm_out_file; + FILE *out_file; char *name, *value; { if (what == ps_name || what == ps_value) { - weak_decls = perm_tree_cons (what == ps_value ? value : NULL_TREE, - name, weak_decls); + struct weak_syms *weak = + (struct weak_syms *)permalloc (sizeof (struct weak_syms)); + weak->next = weak_decls; + weak->name = permalloc (strlen (name) + 1); + strcpy (weak->name, name); + + if (what != ps_value) + weak->value = NULL_PTR; + + else + { + weak->value = permalloc (strlen (value) + 1); + strcpy (weak->value, value); + } + + weak_decls = weak; } else if (! (what == ps_done || what == ps_start)) warning ("malformed `#pragma weak'"); @@ -3967,8 +3991,9 @@ declare_weak (decl) if (! TREE_PUBLIC (decl)) error_with_decl (decl, "weak declaration of `%s' must be public"); else - weak_decls = perm_tree_cons (NULL_TREE, DECL_ASSEMBLER_NAME (decl), - weak_decls); + handle_pragma_weak (ps_name, asm_out_file, + IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), + NULL_PTR); } /* Emit any pending weak declarations. */ @@ -3979,20 +4004,19 @@ weak_finish () #ifdef HANDLE_PRAGMA_WEAK if (HANDLE_PRAGMA_WEAK) { - tree t; - for (t = weak_decls; t; t = TREE_CHAIN (t)) + struct weak_syms *t; + for (t = weak_decls; t; t = t->next) { - tree decl = TREE_VALUE (t); - char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0); - fprintf (asm_out_file, "\t%s\t", WEAK_ASM_OP); if (output_bytecode) - BC_OUTPUT_LABELREF (asm_out_file, name); + BC_OUTPUT_LABELREF (asm_out_file, t->name); else - ASM_OUTPUT_LABELREF (asm_out_file, name); + ASM_OUTPUT_LABELREF (asm_out_file, t->name); fputc ('\n', asm_out_file); + if (t->value) + ASM_OUTPUT_DEF (asm_out_file, t->name, t->value); } } #endif |