diff options
author | Jason Merrill <merrill@gnu.org> | 1995-05-16 01:02:59 +0000 |
---|---|---|
committer | Jason Merrill <merrill@gnu.org> | 1995-05-16 01:02:59 +0000 |
commit | daefd78b4ccc28ce52e5c8a7abebe5b6fc903cc3 (patch) | |
tree | 9d5f3bb804d2bbfb71d3beebd8c3bc2c6f1f2499 /gcc | |
parent | 27a2e668fddbb747a6f62e3c2388ca846319ebe5 (diff) | |
download | gcc-daefd78b4ccc28ce52e5c8a7abebe5b6fc903cc3.zip gcc-daefd78b4ccc28ce52e5c8a7abebe5b6fc903cc3.tar.gz gcc-daefd78b4ccc28ce52e5c8a7abebe5b6fc903cc3.tar.bz2 |
Update weak symbol support
From-SVN: r9697
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-decl.c | 1 | ||||
-rw-r--r-- | gcc/c-pragma.h | 8 | ||||
-rw-r--r-- | gcc/config/aoutos.h | 15 | ||||
-rw-r--r-- | gcc/config/i386/freebsd.h | 7 | ||||
-rw-r--r-- | gcc/config/i386/osfrose.h | 9 | ||||
-rw-r--r-- | gcc/config/m88k/m88k.h | 15 | ||||
-rw-r--r-- | gcc/config/netbsd.h | 9 | ||||
-rw-r--r-- | gcc/config/sparc/sunos4.h | 15 | ||||
-rw-r--r-- | gcc/config/svr4.h | 7 | ||||
-rw-r--r-- | gcc/defaults.h | 9 | ||||
-rw-r--r-- | gcc/libgcc2.c | 37 | ||||
-rw-r--r-- | gcc/tree.h | 6 | ||||
-rw-r--r-- | gcc/varasm.c | 35 |
13 files changed, 109 insertions, 64 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index db990350..f06be29 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1791,6 +1791,7 @@ duplicate_decls (newdecl, olddecl) } /* Merge the storage class information. */ + DECL_WEAK (newdecl) |= DECL_WEAK (olddecl); /* For functions, static overrides non-static. */ if (TREE_CODE (newdecl) == FUNCTION_DECL) { diff --git a/gcc/c-pragma.h b/gcc/c-pragma.h index 061f416..530492b 100644 --- a/gcc/c-pragma.h +++ b/gcc/c-pragma.h @@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public License along with GNU CC; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* Support #pragma weak by default if WEAK_ASM_OP and ASM_OUTPUT_DEF - are defined. */ -#if !defined (HANDLE_PRAGMA_WEAK) && defined (WEAK_ASM_OP) && defined (ASM_OUTPUT_DEF) -#define HANDLE_PRAGMA_WEAK 1 +/* Support #pragma weak iff ASM_WEAKEN_LABEL and ASM_OUTPUT_DEF are + defined. */ +#if defined (ASM_WEAKEN_LABEL) && defined (ASM_OUTPUT_DEF) +#define HANDLE_PRAGMA_WEAK SUPPORTS_WEAK #endif enum pragma_state diff --git a/gcc/config/aoutos.h b/gcc/config/aoutos.h index f7bfc90..b398965 100644 --- a/gcc/config/aoutos.h +++ b/gcc/config/aoutos.h @@ -85,18 +85,3 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ fputc ('\n', FILE); \ } \ } while (0) - -/* If we're using GNU as and ld, we support weak symbols. */ - -#define HANDLE_PRAGMA_WEAK flag_gnu_linker -#define WEAK_ASM_OP ".weak" -#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ - do { if (flag_gnu_linker) \ - { \ - fprintf ((FILE), "\t%s\t", ".set"); \ - assemble_name (FILE, LABEL1); \ - fprintf (FILE, ","); \ - assemble_name (FILE, LABEL2); \ - fprintf (FILE, "\n"); \ - } \ - } while (0) diff --git a/gcc/config/i386/freebsd.h b/gcc/config/i386/freebsd.h index 10a486d..102cb94 100644 --- a/gcc/config/i386/freebsd.h +++ b/gcc/config/i386/freebsd.h @@ -118,7 +118,12 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #define TYPE_ASM_OP ".type" #define SIZE_ASM_OP ".size" -#define WEAK_ASM_OP ".weak" + +/* This is how we tell the assembler that a symbol is weak. */ + +#define ASM_WEAKEN_LABEL(FILE,NAME) \ + do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \ + fputc ('\n', FILE); } while (0) /* The following macro defines the format used to output the second operand of the .type assembler directive. Different svr4 assemblers diff --git a/gcc/config/i386/osfrose.h b/gcc/config/i386/osfrose.h index fa2040c..159c184 100644 --- a/gcc/config/i386/osfrose.h +++ b/gcc/config/i386/osfrose.h @@ -94,7 +94,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Handle #pragma weak and #pragma pack. */ #define HANDLE_SYSV_PRAGMA -#define HANDLE_PRAGMA_WEAK TARGET_ELF +#define SUPPORTS_WEAK TARGET_ELF /* Change default predefines. */ #undef CPP_PREDEFINES @@ -617,9 +617,14 @@ while (0) #define TYPE_ASM_OP ".type" #define SIZE_ASM_OP ".size" -#define WEAK_ASM_OP ".weak" #define SET_ASM_OP ".set" +/* This is how we tell the assembler that a symbol is weak. */ + +#define ASM_WEAKEN_LABEL(FILE,NAME) \ + do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \ + fputc ('\n', FILE); } while (0) + /* The following macro defines the format used to output the second operand of the .type assembler directive. Different svr4 assemblers expect various different forms for this operand. The one given here diff --git a/gcc/config/m88k/m88k.h b/gcc/config/m88k/m88k.h index 76a7083..3f84cd6 100644 --- a/gcc/config/m88k/m88k.h +++ b/gcc/config/m88k/m88k.h @@ -198,13 +198,13 @@ extern char * reg_names[]; Redefined in sysv4.h, and luna.h. */ #define VERSION_INFO1 "88open OCS/BCS, " #ifndef VERSION_INFO2 -#define VERSION_INFO2 "$Revision: 1.1.1.2.2.2 $" +#define VERSION_INFO2 "$Revision: 1.63 $" #endif #ifndef VERSION_STRING #define VERSION_STRING version_string #ifdef __STDC__ -#define TM_RCS_ID "@(#)" __FILE__ " $Revision: 1.1.1.2.2.2 $ " __DATE__ +#define TM_RCS_ID "@(#)" __FILE__ " $Revision: 1.63 $ " __DATE__ #else #define TM_RCS_ID "$What: <@(#) m88k.h,v 1.1.1.2.2.2> $" #endif /* __STDC__ */ @@ -1542,7 +1542,7 @@ enum reg_class { NO_REGS, AP_REG, XRF_REGS, GENERAL_REGS, AGRF_REGS, #define HANDLE_SYSV_PRAGMA /* Tell when to handle #pragma weak. This is only done for V.4. */ -#define HANDLE_PRAGMA_WEAK TARGET_SVR4 +#define SUPPORTS_WEAK TARGET_SVR4 /* Max number of bytes we can move from memory to memory in one reasonably fast instruction. */ @@ -1725,7 +1725,6 @@ enum reg_class { NO_REGS, AP_REG, XRF_REGS, GENERAL_REGS, AGRF_REGS, #undef FINI_SECTION_ASM_OP #undef TYPE_ASM_OP #undef SIZE_ASM_OP -#undef WEAK_ASM_OP #undef SET_ASM_OP #undef SKIP_ASM_OP #undef COMMON_ASM_OP @@ -1776,12 +1775,18 @@ enum reg_class { NO_REGS, AP_REG, XRF_REGS, GENERAL_REGS, AGRF_REGS, /* These are specific to PIC. */ #define TYPE_ASM_OP "type" #define SIZE_ASM_OP "size" -#define WEAK_ASM_OP "weak" #ifndef AS_BUG_POUND_TYPE /* Faulty assemblers require @ rather than #. */ #undef TYPE_OPERAND_FMT #define TYPE_OPERAND_FMT "#%s" #endif +/* This is how we tell the assembler that a symbol is weak. */ + +#undef ASM_WEAKEN_LABEL +#define ASM_WEAKEN_LABEL(FILE,NAME) \ + do { fputs ("\tweak\t", FILE); assemble_name (FILE, NAME); \ + fputc ('\n', FILE); } while (0) + /* These are specific to version 03.00 assembler syntax. */ #define INTERNAL_ASM_OP "local" #define VERSION_ASM_OP "version" diff --git a/gcc/config/netbsd.h b/gcc/config/netbsd.h index af4f62e..8c0974a 100644 --- a/gcc/config/netbsd.h +++ b/gcc/config/netbsd.h @@ -82,10 +82,15 @@ #undef TYPE_ASM_OP #undef SIZE_ASM_OP -#undef WEAK_ASM_OP #define TYPE_ASM_OP ".type" #define SIZE_ASM_OP ".size" -#define WEAK_ASM_OP ".weak" + +/* This is how we tell the assembler that a symbol is weak. */ + +#undef ASM_WEAKEN_LABEL +#define ASM_WEAKEN_LABEL(FILE,NAME) \ + do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \ + fputc ('\n', FILE); } while (0) /* The following macro defines the format used to output the second operand of the .type assembler directive. Different svr4 assemblers diff --git a/gcc/config/sparc/sunos4.h b/gcc/config/sparc/sunos4.h index fd108e8..c7bcaad 100644 --- a/gcc/config/sparc/sunos4.h +++ b/gcc/config/sparc/sunos4.h @@ -20,18 +20,3 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #define SUNOS4_SHARED_LIBRARIES 1 #include "sparc/sparc.h" - -/* If we're using GNU as and ld, we support weak symbols. */ - -#define HANDLE_PRAGMA_WEAK flag_gnu_linker -#define WEAK_ASM_OP ".weak" -#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ - do { if (flag_gnu_linker) \ - { \ - fprintf ((FILE), "\t%s\t", ".set"); \ - assemble_name (FILE, LABEL1); \ - fprintf (FILE, ","); \ - assemble_name (FILE, LABEL2); \ - fprintf (FILE, "\n"); \ - } \ - } while (0) diff --git a/gcc/config/svr4.h b/gcc/config/svr4.h index 051187b..c1c8692 100644 --- a/gcc/config/svr4.h +++ b/gcc/config/svr4.h @@ -648,7 +648,12 @@ dtors_section () \ #define TYPE_ASM_OP ".type" #define SIZE_ASM_OP ".size" -#define WEAK_ASM_OP ".weak" + +/* This is how we tell the assembler that a symbol is weak. */ + +#define ASM_WEAKEN_LABEL(FILE,NAME) \ + do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \ + fputc ('\n', FILE); } while (0) /* The following macro defines the format used to output the second operand of the .type assembler directive. Different svr4 assemblers diff --git a/gcc/defaults.h b/gcc/defaults.h index df5ce1c..f43a3f0 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -131,3 +131,12 @@ do { fprintf (FILE, "\t%s\t", ASM_SHORT); \ } while (0) #endif #endif + +/* This determines whether or not we support weak symbols. */ +#ifndef SUPPORTS_WEAK +#ifdef ASM_WEAKEN_LABEL +#define SUPPORTS_WEAK 1 +#else +#define SUPPORTS_WEAK 0 +#endif +#endif diff --git a/gcc/libgcc2.c b/gcc/libgcc2.c index 7647baa..32cb00b 100644 --- a/gcc/libgcc2.c +++ b/gcc/libgcc2.c @@ -31,6 +31,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "tconfig.h" #include "machmode.h" +#include "defaults.h" #ifndef L_trampoline #include <stddef.h> #endif @@ -40,6 +41,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #undef abort #endif +#if (SUPPORTS_WEAK == 1) && defined (ASM_OUTPUT_DEF) +#define WEAK_ALIAS +#endif + /* Permit the tm.h file to select the endianness to use just for this file. This is used when the endianness is determined when the compiler is run. */ @@ -1606,9 +1611,15 @@ typedef void (*vfp)(void); extern vfp __new_handler; extern void __default_new_handler (void); -void * __builtin_new (size_t sz) __attribute__ ((weak)); +#ifdef WEAK_ALIAS +void * __builtin_new (size_t sz) + __attribute__ ((weak, alias ("___builtin_new"))); +void * +___builtin_new (size_t sz) +#else void * __builtin_new (size_t sz) +#endif { void *p; vfp handler = (__new_handler) ? __new_handler : __default_new_handler; @@ -1633,9 +1644,15 @@ __builtin_new (size_t sz) extern void * __builtin_new (size_t); -void * __builtin_vec_new (size_t sz) __attribute__ ((weak)); +#ifdef WEAK_ALIAS +void * __builtin_vec_new (size_t sz) + __attribute__ ((weak, alias ("___builtin_vec_new"))); +void * +___builtin_vec_new (size_t sz) +#else void * __builtin_vec_new (size_t sz) +#endif { return __builtin_new (sz); } @@ -1696,9 +1713,15 @@ __default_new_handler () by C++ programs to return to the free store a block of memory allocated as a single object. */ -void __builtin_delete (void *ptr) __attribute__ ((weak)); +#ifdef WEAK_ALIAS +void __builtin_delete (void *ptr) + __attribute__ ((weak, alias ("___builtin_delete"))); +void +___builtin_delete (void *ptr) +#else void __builtin_delete (void *ptr) +#endif { if (ptr) free (ptr); @@ -1712,9 +1735,15 @@ __builtin_delete (void *ptr) extern void __builtin_delete (void *); -void __builtin_vec_delete (void *ptr) __attribute__ ((weak)); +#ifdef WEAK_ALIAS +void __builtin_vec_delete (void *ptr) + __attribute__ ((weak, alias ("___builtin_vec_delete"))); +void +___builtin_vec_delete (void *ptr) +#else void __builtin_vec_delete (void *ptr) +#endif { __builtin_delete (ptr); } @@ -958,6 +958,9 @@ struct tree_type /* Used to indicate that this DECL represents a compiler-generated entity. */ #define DECL_ARTIFICIAL(NODE) ((NODE)->decl.artificial_flag) +/* Used to indicate that this DECL has weak linkage. */ +#define DECL_WEAK(NODE) ((NODE)->decl.weak_flag) + /* Additional flags for language-specific uses. */ #define DECL_LANG_FLAG_0(NODE) ((NODE)->decl.lang_flag_0) #define DECL_LANG_FLAG_1(NODE) ((NODE)->decl.lang_flag_1) @@ -997,7 +1000,8 @@ struct tree_decl unsigned static_ctor_flag : 1; unsigned static_dtor_flag : 1; unsigned artificial_flag : 1; - /* room for one more */ + unsigned weak_flag : 1; + /* room for no more */ unsigned lang_flag_0 : 1; unsigned lang_flag_1 : 1; diff --git a/gcc/varasm.c b/gcc/varasm.c index 613ec4f..a06680b 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -802,6 +802,11 @@ assemble_start_function (decl, fnname) { if (!first_global_object_name) STRIP_NAME_ENCODING (first_global_object_name, fnname); +#ifdef ASM_WEAKEN_LABEL + if (DECL_WEAK (decl)) + ASM_WEAKEN_LABEL (asm_out_file, fnname); + else +#endif if (output_bytecode) BC_GLOBALIZE_LABEL (asm_out_file, fnname); else @@ -1172,6 +1177,11 @@ assemble_variable (decl, top_level, at_end, dont_output_data) { if (!first_global_object_name) STRIP_NAME_ENCODING(first_global_object_name, name); +#ifdef ASM_WEAKEN_LABEL + if (DECL_WEAK (decl)) + ASM_WEAKEN_LABEL (asm_out_file, name); + else +#endif ASM_GLOBALIZE_LABEL (asm_out_file, name); } #if 0 @@ -3964,14 +3974,12 @@ void declare_weak (decl) tree decl; { -#ifdef HANDLE_PRAGMA_WEAK if (! TREE_PUBLIC (decl)) error_with_decl (decl, "weak declaration of `%s' must be public"); - else - handle_pragma_weak (ps_name, - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), - NULL_PTR); -#endif + else if (TREE_ASM_WRITTEN (decl)) + error_with_decl (decl, "weak declaration of `%s' must precede definition"); + else if (SUPPORTS_WEAK) + DECL_WEAK (decl) = 1; } /* Emit any pending weak declarations. */ @@ -3985,14 +3993,7 @@ weak_finish () struct weak_syms *t; for (t = weak_decls; t; t = t->next) { - fprintf (asm_out_file, "\t%s\t", WEAK_ASM_OP); - - if (output_bytecode) - BC_OUTPUT_LABELREF (asm_out_file, t->name); - else - ASM_OUTPUT_LABELREF (asm_out_file, t->name); - - fputc ('\n', asm_out_file); + ASM_WEAKEN_LABEL (asm_out_file, t->name); if (t->value) ASM_OUTPUT_DEF (asm_out_file, t->name, t->value); } @@ -4014,6 +4015,11 @@ assemble_alias (decl, target) if (TREE_PUBLIC (decl)) { +#ifdef ASM_WEAKEN_LABEL + if (DECL_WEAK (decl)) + ASM_WEAKEN_LABEL (asm_out_file, name); + else +#endif if (output_bytecode) BC_GLOBALIZE_LABEL (asm_out_file, name); else @@ -4021,6 +4027,7 @@ assemble_alias (decl, target) } ASM_OUTPUT_DEF (asm_out_file, name, IDENTIFIER_POINTER (target)); + TREE_ASM_WRITTEN (decl) = 1; #else warning ("alias definitions not supported in this configuration"); #endif |