}
/* Merge the storage class information. */
+ DECL_WEAK (newdecl) |= DECL_WEAK (olddecl);
/* For functions, static overrides non-static. */
if (TREE_CODE (newdecl) == FUNCTION_DECL)
{
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
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)
#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
/* 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
#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
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__ */
#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. */
#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
/* 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"
#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
#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)
#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
} 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
#include "tconfig.h"
#include "machmode.h"
+#include "defaults.h"
#ifndef L_trampoline
#include <stddef.h>
#endif
#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. */
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;
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);
}
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);
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);
}
/* 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)
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;
{
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
{
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
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. */
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);
}
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
}
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