Commit 79c4e63f by Alan Modra Committed by Alan Modra

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
parent 562ff163
2002-03-01 Alan Modra <amodra@bigpond.net.au>
David Edelsohn <edelsohn@gnu.org>
* 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.
2002-03-01 Jason Merrill <jason@redhat.com> 2002-03-01 Jason Merrill <jason@redhat.com>
* tree.h (TARGET_EXPR_SLOT, TARGET_EXPR_INITIAL): New macros. * tree.h (TARGET_EXPR_SLOT, TARGET_EXPR_INITIAL): New macros.
......
/* Handle #pragma, system V.4 style. Supports #pragma weak and #pragma pack. /* Handle #pragma, system V.4 style. Supports #pragma weak and #pragma pack.
Copyright (C) 1992, 1997, 1998, 1999, 2000, 2001 Copyright (C) 1992, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -298,7 +298,8 @@ handle_pragma_weak (dummy) ...@@ -298,7 +298,8 @@ handle_pragma_weak (dummy)
if (t != CPP_EOF) if (t != CPP_EOF)
warning ("junk at end of #pragma weak"); warning ("junk at end of #pragma weak");
add_weak (IDENTIFIER_POINTER (name), value ? IDENTIFIER_POINTER (value) : 0); add_weak (NULL_TREE, IDENTIFIER_POINTER (name),
value ? IDENTIFIER_POINTER (value) : NULL);
} }
#endif #endif
......
...@@ -23,9 +23,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -23,9 +23,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#define GCC_C_PRAGMA_H #define GCC_C_PRAGMA_H
#ifdef HANDLE_SYSV_PRAGMA #ifdef HANDLE_SYSV_PRAGMA
/* Support #pragma weak iff ASM_WEAKEN_LABEL and ASM_OUTPUT_WEAK_ALIAS are #if ((defined (ASM_WEAKEN_LABEL) && defined (ASM_OUTPUT_WEAK_ALIAS)) \
defined. */ || defined (ASM_WEAKEN_DECL))
#if defined (ASM_WEAKEN_LABEL) && defined (ASM_OUTPUT_WEAK_ALIAS)
#define HANDLE_PRAGMA_WEAK SUPPORTS_WEAK #define HANDLE_PRAGMA_WEAK SUPPORTS_WEAK
#endif #endif
......
/* Definitions of target machine for GNU compiler, /* Definitions of target machine for GNU compiler,
for IBM RS/6000 POWER running AIX. for IBM RS/6000 POWER running AIX.
Copyright (C) 2000, 2001 Free Software Foundation, Inc. Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
...@@ -27,6 +27,9 @@ Boston, MA 02111-1307, USA. */ ...@@ -27,6 +27,9 @@ Boston, MA 02111-1307, USA. */
collect has a chance to see them, so scan the object files directly. */ collect has a chance to see them, so scan the object files directly. */
#define COLLECT_EXPORT_LIST #define COLLECT_EXPORT_LIST
/* Handle #pragma weak and #pragma pack. */
#define HANDLE_SYSV_PRAGMA
/* This is the only version of nm that collect2 can work with. */ /* This is the only version of nm that collect2 can work with. */
#define REAL_NM_FILE_NAME "/usr/ucb/nm" #define REAL_NM_FILE_NAME "/usr/ucb/nm"
......
/* Definitions of target machine for GNU compiler, /* Definitions of target machine for GNU compiler,
for 64 bit powerpc linux. for 64 bit powerpc linux.
Copyright (C) 2000, 2001 Free Software Foundation, Inc. Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
...@@ -250,32 +250,39 @@ do { \ ...@@ -250,32 +250,39 @@ do { \
fputs (DOUBLE_INT_ASM_OP, (FILE)); \ fputs (DOUBLE_INT_ASM_OP, (FILE)); \
putc ('.', (FILE)); \ putc ('.', (FILE)); \
assemble_name ((FILE), (NAME)); \ assemble_name ((FILE), (NAME)); \
putc ('\n', (FILE)); \ fputs (",.TOC.@tocbase,0\n\t.previous\n\t.size\t", (FILE)); \
fputs (DOUBLE_INT_ASM_OP, (FILE)); \ assemble_name ((FILE), (NAME)); \
fputs (".TOC.@tocbase, 0\n\t.previous\n", (FILE)); \ fputs (",24\n\t.type\t.", (FILE)); \
\ assemble_name ((FILE), (NAME)); \
if (TREE_PUBLIC (DECL)) \ fputs (",@function\n", (FILE)); \
if (TREE_PUBLIC (DECL) && ! DECL_WEAK (DECL)) \
{ \ { \
if (DECL_WEAK (DECL)) \ fputs ("\t.globl\t.", (FILE)); \
fputs ("\t.weak\t", (FILE)); \
else \
fputs ("\t.globl\t", (FILE)); \
putc ('.', (FILE)); \
assemble_name ((FILE), (NAME)); \ assemble_name ((FILE), (NAME)); \
putc ('\n', (FILE)); \ putc ('\n', (FILE)); \
} \ } \
fputs (TYPE_ASM_OP, (FILE)); \
putc ('.', (FILE)); \
assemble_name ((FILE), (NAME)); \
putc (',', (FILE)); \
fprintf ((FILE), TYPE_OPERAND_FMT, "function"); \
putc ('\n', (FILE)); \
ASM_DECLARE_RESULT ((FILE), DECL_RESULT (DECL)); \ ASM_DECLARE_RESULT ((FILE), DECL_RESULT (DECL)); \
putc ('.', (FILE)); \ putc ('.', (FILE)); \
ASM_OUTPUT_LABEL ((FILE), (NAME)); \ ASM_OUTPUT_LABEL ((FILE), (NAME)); \
} \ } \
while (0) while (0)
/* This is how to declare the size of a function. */
#undef ASM_DECLARE_FUNCTION_SIZE
#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
do \
{ \
if (!flag_inhibit_size_directive) \
{ \
fputs ("\t.size\t.", (FILE)); \
assemble_name ((FILE), (FNAME)); \
fputs (",.-.", (FILE)); \
assemble_name ((FILE), (FNAME)); \
putc ('\n', (FILE)); \
} \
} \
while (0)
/* Return non-zero if this entry is to be written into the constant /* Return non-zero if this entry is to be written into the constant
pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF
or a CONST containing one of them. If -mfp-in-toc (the default), or a CONST containing one of them. If -mfp-in-toc (the default),
......
...@@ -2422,43 +2422,71 @@ extern int toc_initialized; ...@@ -2422,43 +2422,71 @@ extern int toc_initialized;
#define RS6000_WEAK 0 #define RS6000_WEAK 0
#endif #endif
/* This implementes the `alias' attribute. */ #if RS6000_WEAK
#define ASM_OUTPUT_DEF_FROM_DECLS(FILE,decl,target) \ /* Used in lieu of ASM_WEAKEN_LABEL. */
do { \ #define ASM_WEAKEN_DECL(FILE, DECL, NAME, VAL) \
const char * alias = XSTR (XEXP (DECL_RTL (decl), 0), 0); \ do \
const char * name = IDENTIFIER_POINTER (target); \ { \
if (TREE_CODE (decl) == FUNCTION_DECL \ fputs ("\t.weak\t", (FILE)); \
&& DEFAULT_ABI == ABI_AIX) \ assemble_name ((FILE), (NAME)); \
{ \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL \
if (TREE_PUBLIC (decl)) \ && DEFAULT_ABI == ABI_AIX) \
{ \ { \
if (RS6000_WEAK && DECL_WEAK (decl)) \ fputs (",.", (FILE)); \
{ \ assemble_name ((FILE), (NAME)); \
fputs ("\t.weak .", FILE); \ } \
assemble_name (FILE, alias); \ fputc ('\n', (FILE)); \
putc ('\n', FILE); \ if (VAL) \
} \ { \
else \ ASM_OUTPUT_DEF ((FILE), (NAME), (VAL)); \
{ \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL \
fputs ("\t.globl .", FILE); \ && DEFAULT_ABI == ABI_AIX) \
assemble_name (FILE, alias); \ { \
putc ('\n', FILE); \ fputs ("\t.set\t.", (FILE)); \
} \ assemble_name ((FILE), (NAME)); \
} \ fputs (",.", (FILE)); \
else \ assemble_name ((FILE), (VAL)); \
{ \ fputc ('\n', (FILE)); \
fputs ("\t.lglobl .", FILE); \ } \
assemble_name (FILE, alias); \ } \
putc ('\n', FILE); \ } \
} \ while (0)
fputs ("\t.set .", FILE); \ #endif
assemble_name (FILE, alias); \
fputs (",.", FILE); \ /* This implements the `alias' attribute. */
assemble_name (FILE, name); \ #undef ASM_OUTPUT_DEF_FROM_DECLS
fputc ('\n', FILE); \ #define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL, TARGET) \
} \ do \
ASM_OUTPUT_DEF (FILE, alias, name); \ { \
} while (0) const char *alias = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
const char *name = IDENTIFIER_POINTER (TARGET); \
if (TREE_CODE (DECL) == FUNCTION_DECL \
&& DEFAULT_ABI == ABI_AIX) \
{ \
if (TREE_PUBLIC (DECL)) \
{ \
if (!RS6000_WEAK || !DECL_WEAK (DECL)) \
{ \
fputs ("\t.globl\t.", FILE); \
assemble_name (FILE, alias); \
putc ('\n', FILE); \
} \
} \
else if (TARGET_XCOFF) \
{ \
fputs ("\t.lglobl\t.", FILE); \
assemble_name (FILE, alias); \
putc ('\n', FILE); \
} \
fputs ("\t.set\t.", FILE); \
assemble_name (FILE, alias); \
fputs (",.", FILE); \
assemble_name (FILE, name); \
fputc ('\n', FILE); \
} \
ASM_OUTPUT_DEF (FILE, alias, name); \
} \
while (0)
/* Output to assembler file text saying following lines /* Output to assembler file text saying following lines
may contain character constants, extra white space, comments, etc. */ may contain character constants, extra white space, comments, etc. */
......
/* Definitions of target machine for GNU compiler, /* Definitions of target machine for GNU compiler,
for some generic XCOFF file format for some generic XCOFF file format
Copyright (C) 2001 Free Software Foundation, Inc. Copyright (C) 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
...@@ -345,13 +345,7 @@ toc_section () \ ...@@ -345,13 +345,7 @@ toc_section () \
SYMBOL_REF_FLAG (sym_ref) = 1; \ SYMBOL_REF_FLAG (sym_ref) = 1; \
if (TREE_PUBLIC (DECL)) \ if (TREE_PUBLIC (DECL)) \
{ \ { \
if (RS6000_WEAK && DECL_WEAK (decl)) \ if (!RS6000_WEAK || !DECL_WEAK (decl)) \
{ \
fputs ("\t.weak .", FILE); \
RS6000_OUTPUT_BASENAME (FILE, NAME); \
putc ('\n', FILE); \
} \
else \
{ \ { \
fputs ("\t.globl .", FILE); \ fputs ("\t.globl .", FILE); \
RS6000_OUTPUT_BASENAME (FILE, NAME); \ RS6000_OUTPUT_BASENAME (FILE, NAME); \
...@@ -464,20 +458,6 @@ toc_section () \ ...@@ -464,20 +458,6 @@ toc_section () \
xcoff_bss_section_name); \ xcoff_bss_section_name); \
} while (0) } while (0)
/* Output a weak symbol, if weak support present. */
#ifdef HAVE_GAS_WEAK
#define HANDLE_PRAGMA_WEAK 1
#define ASM_WEAKEN_LABEL(FILE, NAME) \
do \
{ \
fputs ("\t.weak ", (FILE)); \
assemble_name ((FILE), (NAME)); \
fputc ('\n', (FILE)); \
} \
while (0)
#endif /* HAVE_GAS_WEAK */
/* This is how we tell the assembler that two symbols have the same value. */ /* This is how we tell the assembler that two symbols have the same value. */
#define SET_ASM_OP "\t.set " #define SET_ASM_OP "\t.set "
......
/* Definitions of various defaults for tm.h macros. /* Definitions of various defaults for tm.h macros.
Copyright (C) 1992, 1996, 1997, 1998, 1999, 2000, 2001 Copyright (C) 1992, 1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc. Free Software Foundation, Inc.
Contributed by Ron Guilmette (rfg@monkeys.com) Contributed by Ron Guilmette (rfg@monkeys.com)
...@@ -158,7 +158,7 @@ do { ASM_OUTPUT_LABEL(FILE,LABEL_ALTERNATE_NAME (INSN)); } while (0) ...@@ -158,7 +158,7 @@ do { ASM_OUTPUT_LABEL(FILE,LABEL_ALTERNATE_NAME (INSN)); } while (0)
/* This determines whether or not we support weak symbols. */ /* This determines whether or not we support weak symbols. */
#ifndef SUPPORTS_WEAK #ifndef SUPPORTS_WEAK
#ifdef ASM_WEAKEN_LABEL #if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
#define SUPPORTS_WEAK 1 #define SUPPORTS_WEAK 1
#else #else
#define SUPPORTS_WEAK 0 #define SUPPORTS_WEAK 0
......
...@@ -6169,7 +6169,7 @@ itself; before and after that, output the additional assembler syntax ...@@ -6169,7 +6169,7 @@ itself; before and after that, output the additional assembler syntax
for making that name global, and a newline. for making that name global, and a newline.
@findex ASM_WEAKEN_LABEL @findex ASM_WEAKEN_LABEL
@item ASM_WEAKEN_LABEL @item ASM_WEAKEN_LABEL (@var{stream}, @var{name})
A C statement (sans semicolon) to output to the stdio stream A C statement (sans semicolon) to output to the stdio stream
@var{stream} some commands that will make the label @var{name} weak; @var{stream} some commands that will make the label @var{name} weak;
that is, available for reference from other files but only used if that is, available for reference from other files but only used if
...@@ -6178,18 +6178,29 @@ no other definition is available. Use the expression ...@@ -6178,18 +6178,29 @@ no other definition is available. Use the expression
itself; before and after that, output the additional assembler syntax itself; before and after that, output the additional assembler syntax
for making that name weak, and a newline. for making that name weak, and a newline.
If you don't define this macro, GCC will not support weak If you don't define this macro or @code{ASM_WEAKEN_DECL}, GCC will not
symbols and you should not define the @code{SUPPORTS_WEAK} macro. support weak symbols and you should not define the @code{SUPPORTS_WEAK}
macro.
@findex ASM_WEAKEN_DECL
@item ASM_WEAKEN_DECL (@var{stream}, @var{decl}, @var{name}, @var{value})
Combines (and replaces) the function of @code{ASM_WEAKEN_LABEL} and
@code{ASM_OUTPUT_WEAK_ALIAS}, allowing access to the associated function
or variable decl. If @var{value} is not @code{NULL}, this C statement
should output to the stdio stream @var{stream} assembler code which
defines (equates) the weak symbol @var{name} to have the value
@var{value}. If @var{value} is @code{NULL}, it should output commands
to make @var{name} weak.
@findex SUPPORTS_WEAK @findex SUPPORTS_WEAK
@item SUPPORTS_WEAK @item SUPPORTS_WEAK
A C expression which evaluates to true if the target supports weak symbols. A C expression which evaluates to true if the target supports weak symbols.
If you don't define this macro, @file{defaults.h} provides a default If you don't define this macro, @file{defaults.h} provides a default
definition. If @code{ASM_WEAKEN_LABEL} is defined, the default definition. If either @code{ASM_WEAKEN_LABEL} or @code{ASM_WEAKEN_DECL}
definition is @samp{1}; otherwise, it is @samp{0}. Define this macro if is defined, the default definition is @samp{1}; otherwise, it is
you want to control weak symbol support with a compiler flag such as @samp{0}. Define this macro if you want to control weak symbol support
@option{-melf}. with a compiler flag such as @option{-melf}.
@findex MAKE_DECL_ONE_ONLY (@var{decl}) @findex MAKE_DECL_ONE_ONLY (@var{decl})
@item MAKE_DECL_ONE_ONLY @item MAKE_DECL_ONE_ONLY
......
...@@ -137,7 +137,7 @@ extern const char *get_insn_template PARAMS ((int, rtx)); ...@@ -137,7 +137,7 @@ extern const char *get_insn_template PARAMS ((int, rtx));
/* Add function NAME to the weak symbols list. VALUE is a weak alias /* Add function NAME to the weak symbols list. VALUE is a weak alias
associated with NAME. */ associated with NAME. */
extern int add_weak PARAMS ((const char *, const char *)); extern int add_weak PARAMS ((tree, const char *, const char *));
/* Functions in flow.c */ /* Functions in flow.c */
extern void allocate_for_life_analysis PARAMS ((void)); extern void allocate_for_life_analysis PARAMS ((void));
......
...@@ -42,6 +42,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -42,6 +42,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "obstack.h" #include "obstack.h"
#include "hashtab.h" #include "hashtab.h"
#include "c-pragma.h" #include "c-pragma.h"
#include "c-tree.h"
#include "ggc.h" #include "ggc.h"
#include "langhooks.h" #include "langhooks.h"
#include "tm_p.h" #include "tm_p.h"
...@@ -166,7 +167,8 @@ static unsigned HOST_WIDE_INT array_size_for_constructor PARAMS ((tree)); ...@@ -166,7 +167,8 @@ static unsigned HOST_WIDE_INT array_size_for_constructor PARAMS ((tree));
static unsigned min_align PARAMS ((unsigned, unsigned)); static unsigned min_align PARAMS ((unsigned, unsigned));
static void output_constructor PARAMS ((tree, HOST_WIDE_INT, static void output_constructor PARAMS ((tree, HOST_WIDE_INT,
unsigned 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 *)); static void remove_from_pending_weak_list PARAMS ((const char *));
#endif #endif
static int in_named_entry_eq PARAMS ((const PTR, const PTR)); static int in_named_entry_eq PARAMS ((const PTR, const PTR));
...@@ -1237,10 +1239,14 @@ assemble_start_function (decl, fnname) ...@@ -1237,10 +1239,14 @@ assemble_start_function (decl, fnname)
weak_global_object_name = name; weak_global_object_name = name;
} }
#ifdef ASM_WEAKEN_LABEL #if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
if (DECL_WEAK (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); ASM_WEAKEN_LABEL (asm_out_file, fnname);
#endif
/* Remove this function from the pending weak list so that /* Remove this function from the pending weak list so that
we do not emit multiple .weak directives for it. */ we do not emit multiple .weak directives for it. */
remove_from_pending_weak_list remove_from_pending_weak_list
...@@ -1644,10 +1650,14 @@ assemble_variable (decl, top_level, at_end, dont_output_data) ...@@ -1644,10 +1650,14 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
/* First make the assembler name(s) global if appropriate. */ /* First make the assembler name(s) global if appropriate. */
if (TREE_PUBLIC (decl) && DECL_NAME (decl)) if (TREE_PUBLIC (decl) && DECL_NAME (decl))
{ {
#ifdef ASM_WEAKEN_LABEL #if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
if (DECL_WEAK (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); ASM_WEAKEN_LABEL (asm_out_file, name);
#endif
/* Remove this variable from the pending weak list so that /* Remove this variable from the pending weak list so that
we do not emit multiple .weak directives for it. */ we do not emit multiple .weak directives for it. */
remove_from_pending_weak_list remove_from_pending_weak_list
...@@ -5012,17 +5022,31 @@ output_constructor (exp, size, align) ...@@ -5012,17 +5022,31 @@ output_constructor (exp, size, align)
struct weak_syms struct weak_syms
{ {
struct weak_syms * next; struct weak_syms * next;
tree decl;
const char * name; const char * name;
const char * value; const char * value;
}; };
static struct weak_syms * weak_decls; 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 /* Add function NAME to the weak symbols list. VALUE is a weak alias
associated with NAME. */ associated with NAME. */
int int
add_weak (name, value) add_weak (decl, name, value)
tree decl;
const char *name; const char *name;
const char *value; const char *value;
{ {
...@@ -5034,6 +5058,7 @@ add_weak (name, value) ...@@ -5034,6 +5058,7 @@ add_weak (name, value)
return 0; return 0;
weak->next = weak_decls; weak->next = weak_decls;
weak->decl = decl;
weak->name = name; weak->name = name;
weak->value = value; weak->value = value;
weak_decls = weak; weak_decls = weak;
...@@ -5052,7 +5077,7 @@ declare_weak (decl) ...@@ -5052,7 +5077,7 @@ declare_weak (decl)
else if (TREE_ASM_WRITTEN (decl)) else if (TREE_ASM_WRITTEN (decl))
error_with_decl (decl, "weak declaration of `%s' must precede definition"); error_with_decl (decl, "weak declaration of `%s' must precede definition");
else if (SUPPORTS_WEAK) else if (SUPPORTS_WEAK)
add_weak (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), NULL); add_weak (decl, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), NULL);
else else
warning_with_decl (decl, "weak declaration of `%s' not supported"); warning_with_decl (decl, "weak declaration of `%s' not supported");
...@@ -5067,8 +5092,18 @@ weak_finish () ...@@ -5067,8 +5092,18 @@ weak_finish ()
if (SUPPORTS_WEAK) if (SUPPORTS_WEAK)
{ {
struct weak_syms *t; 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 #ifdef ASM_OUTPUT_WEAK_ALIAS
ASM_OUTPUT_WEAK_ALIAS (asm_out_file, t->name, t->value); ASM_OUTPUT_WEAK_ALIAS (asm_out_file, t->name, t->value);
#else #else
...@@ -5078,6 +5113,7 @@ weak_finish () ...@@ -5078,6 +5113,7 @@ weak_finish ()
ASM_WEAKEN_LABEL (asm_out_file, t->name); ASM_WEAKEN_LABEL (asm_out_file, t->name);
#endif #endif
#endif #endif
#endif
} }
} }
} }
...@@ -5085,7 +5121,7 @@ weak_finish () ...@@ -5085,7 +5121,7 @@ weak_finish ()
/* Remove NAME from the pending list of weak symbols. This prevents /* Remove NAME from the pending list of weak symbols. This prevents
the compiler from emitting multiple .weak directives which confuses the compiler from emitting multiple .weak directives which confuses
some assemblers. */ some assemblers. */
#ifdef ASM_WEAKEN_LABEL #if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
static void static void
remove_from_pending_weak_list (name) remove_from_pending_weak_list (name)
const char *name; const char *name;
...@@ -5105,7 +5141,7 @@ remove_from_pending_weak_list (name) ...@@ -5105,7 +5141,7 @@ remove_from_pending_weak_list (name)
p = &(t->next); 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 /* Emit an assembler directive to make the symbol for DECL an alias to
the symbol for TARGET. */ the symbol for TARGET. */
...@@ -5127,10 +5163,14 @@ assemble_alias (decl, target) ...@@ -5127,10 +5163,14 @@ assemble_alias (decl, target)
if (TREE_PUBLIC (decl)) if (TREE_PUBLIC (decl))
{ {
#ifdef ASM_WEAKEN_LABEL #if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
if (DECL_WEAK (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); ASM_WEAKEN_LABEL (asm_out_file, name);
#endif
/* Remove this function from the pending weak list so that /* Remove this function from the pending weak list so that
we do not emit multiple .weak directives for it. */ we do not emit multiple .weak directives for it. */
remove_from_pending_weak_list remove_from_pending_weak_list
...@@ -5147,12 +5187,16 @@ assemble_alias (decl, target) ...@@ -5147,12 +5187,16 @@ assemble_alias (decl, target)
ASM_OUTPUT_DEF (asm_out_file, name, IDENTIFIER_POINTER (target)); ASM_OUTPUT_DEF (asm_out_file, name, IDENTIFIER_POINTER (target));
#endif #endif
TREE_ASM_WRITTEN (decl) = 1; TREE_ASM_WRITTEN (decl) = 1;
#else #else /* !ASM_OUTPUT_DEF */
#ifdef ASM_OUTPUT_WEAK_ALIAS #if defined (ASM_OUTPUT_WEAK_ALIAS) || defined (ASM_WEAKEN_DECL)
if (! DECL_WEAK (decl)) if (! DECL_WEAK (decl))
warning ("only weak aliases are supported in this configuration"); 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)); ASM_OUTPUT_WEAK_ALIAS (asm_out_file, name, IDENTIFIER_POINTER (target));
#endif
TREE_ASM_WRITTEN (decl) = 1; TREE_ASM_WRITTEN (decl) = 1;
#else #else
warning ("alias definitions not supported in this configuration; ignored"); warning ("alias definitions not supported in this configuration; ignored");
...@@ -5232,6 +5276,7 @@ init_varasm_once () ...@@ -5232,6 +5276,7 @@ init_varasm_once ()
mark_const_hash_entry); mark_const_hash_entry);
ggc_add_root (&const_str_htab, 1, sizeof const_str_htab, ggc_add_root (&const_str_htab, 1, sizeof const_str_htab,
mark_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 (); const_alias_set = new_alias_set ();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment