This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
PATCH: Support weak symbol on IRIX 6
- To: gcc at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Subject: PATCH: Support weak symbol on IRIX 6
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Fri, 1 Jun 2001 00:47:13 -0700
Could someone please tell me why ASM_OUTPUT_WEAK_ALIAS and
ASM_WEAKEN_LABEL are not enough for the weak symbol support? Here
is a patch. I also updated tm.texi to specify the undefined weak
symbol with ASM_OUTPUT_WEAK_ALIAS. I think all the current
ASM_OUTPUT_WEAK_ALIAS definitions support it.
H.J.
---
2001-05-31 H.J. Lu <hjl@gnu.org>
* c-pragma.h (ASM_OUTPUT_WEAK_ALIAS): Define if possible.
(HANDLE_PRAGMA_WEAK): Define iff ASM_WEAKEN_LABEL and
ASM_OUTPUT_WEAK_ALIAS are defined.
* config/mips/iris6.h (HANDLE_SYSV_PRAGMA): Defined as 1.
* tm.texi (ASM_OUTPUT_WEAK_ALIAS): Support the undefined weak
symbol.
* varasm.c (weak_finish): Use ASM_OUTPUT_WEAK_ALIAS.
--- gcc/c-pragma.h.weak Thu May 31 21:07:24 2001
+++ gcc/c-pragma.h Thu May 31 21:17:20 2001
@@ -22,10 +22,21 @@ Boston, MA 02111-1307, USA. */
#define _C_PRAGMA_H
#ifdef HANDLE_SYSV_PRAGMA
-/* Support #pragma weak iff ASM_WEAKEN_LABEL and ASM_OUTPUT_DEF are
- defined. */
-#if defined (ASM_WEAKEN_LABEL) && defined (ASM_OUTPUT_DEF)
+/* Support #pragma weak iff ASM_WEAKEN_LABEL and ASM_OUTPUT_WEAK_ALIAS
+ are defined. */
+#ifdef ASM_WEAKEN_LABEL
+#if !defined (ASM_OUTPUT_WEAK_ALIAS) && defined (ASM_OUTPUT_DEF)
+#define ASM_OUTPUT_WEAK_ALIAS(STREAM,NAME,VALUE) \
+ do \
+ { \
+ ASM_WEAKEN_LABEL (STREAM, NAME); \
+ if (VALUE) \
+ ASM_OUTPUT_DEF (STREAM, NAME, VALUE); \
+ } while (0)
+#endif
+#ifdef ASM_OUTPUT_WEAK_ALIAS
#define HANDLE_PRAGMA_WEAK SUPPORTS_WEAK
+#endif
#endif
/* We always support #pragma pack for SYSV pragmas. */
--- gcc/config/mips/iris6.h.weak Thu May 31 21:14:46 2001
+++ gcc/config/mips/iris6.h Thu May 31 21:14:24 2001
@@ -582,3 +582,7 @@ do { \
%{shared:-hidden_symbol __do_global_ctors,__do_global_dtors,__EH_FRAME_BEGIN__,__frame_dummy} \
-_SYSTYPE_SVR4 -woff 131 \
%{mabi=32: -32}%{mabi=n32: -n32}%{mabi=64: -64}%{!mabi*: -n32}"
+
+/* Handle #pragma weak and #pragma pack. */
+#undef HANDLE_SYSV_PRAGMA
+#define HANDLE_SYSV_PRAGMA 1
--- gcc/tm.texi.weak Thu May 31 23:07:46 2001
+++ gcc/tm.texi Thu May 31 23:11:33 2001
@@ -5930,7 +5930,8 @@ correct for most systems.
@item ASM_OUTPUT_WEAK_ALIAS (@var{stream}, @var{name}, @var{value})
A C statement to output to the stdio stream @var{stream} assembler code
which defines (equates) the weak symbol @var{name} to have the value
-@var{value}.
+@var{value}. If @var{value} is @code{NULL}, it defines @var{name} as
+an undefined weak symbol.
Define this macro if the target only supports weak aliases; define
ASM_OUTPUT_DEF instead if possible.
--- gcc/varasm.c.weak Thu May 31 21:07:00 2001
+++ gcc/varasm.c Thu May 31 21:13:49 2001
@@ -4699,11 +4699,7 @@ weak_finish ()
for (t = weak_decls; t; t = t->next)
{
if (t->name)
- {
- ASM_WEAKEN_LABEL (asm_out_file, t->name);
- if (t->value)
- ASM_OUTPUT_DEF (asm_out_file, t->name, t->value);
- }
+ ASM_OUTPUT_WEAK_ALIAS (asm_out_file, t->name, t->value);
}
}
#endif