This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
patch to fix undefined weak symbols fixes emacs!!!
- To: gcc-bugs at gcc dot gnu dot org, Franz dot Sirl-kernel at lauterbach dot com
- Subject: patch to fix undefined weak symbols fixes emacs!!!
- From: Jack Howarth <howarth at bromo dot med dot uc dot edu>
- Date: Wed, 14 Mar 2001 00:57:17 -0500 (EST)
Franz,
I tried your proposed patch for gcc 2.95.3 that resolves the undefined
weak symbol problems we have been seeing. Not only does the resulting
gcc fix the problem with slrn in current glibc cvs but it fixes that
strange long-standing problem we had building emacs on linuxppc! I am
now able to remove the -G0 compiler and linker flags from our emacs
patches and the build completes without any segfaults of temacs during
the build. I guess this emacs build problem was another manifestion
of the undefined weak symbol problem in gcc. Your proposed patch should
definitely go into gcc 2.95.3 release.
Jack
---------------------------------------------------------------------
Index: gcc/rtl.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtl.h,v
retrieving revision 1.105.4.3
diff -u -p -r1.105.4.3 rtl.h
--- gcc/rtl.h 2001/01/25 14:03:22 1.105.4.3
+++ gcc/rtl.h 2001/03/13 01:03:58
@@ -168,7 +168,8 @@ typedef struct rtx_def
either changing how we compute the frame address or saving and
restoring registers in the prologue and epilogue.
1 in a MEM if the MEM refers to a scalar, rather than a member of
- an aggregate. */
+ an aggregate.
+ 1 in a SYMBOL_REF if the symbol is weak. */
unsigned frame_related : 1;
/* The first element of the operands of this rtx.
The number of operands and their types are controlled
@@ -661,6 +662,9 @@ extern char *note_insn_name[];
/* 1 means a SYMBOL_REF has been the library function in emit_library_call. */ #define SYMBOL_REF_USED(RTX) ((RTX)->used)
+/* 1 means a SYMBOL_REF is weak. */
+#define SYMBOL_REF_WEAK(RTX) ((RTX)->frame_related)
+
/* For an INLINE_HEADER rtx, FIRST_FUNCTION_INSN is the first insn
of the function that is not involved in copying parameters to
pseudo-registers. FIRST_PARM_INSN is the very first insn of
Index: gcc/rtlanal.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtlanal.c,v
retrieving revision 1.36.4.2
diff -u -p -r1.36.4.2 rtlanal.c
--- gcc/rtlanal.c 2001/01/25 14:03:22 1.36.4.2
+++ gcc/rtlanal.c 2001/03/13 01:04:00
@@ -136,11 +136,9 @@ rtx_addr_can_trap_p (x)
switch (code)
{
case SYMBOL_REF:
+ return SYMBOL_REF_WEAK (x);
+
case LABEL_REF:
- /* SYMBOL_REF is problematic due to the possible presence of
- a #pragma weak, but to say that loads from symbols can trap is
- *very* costly. It's not at all clear what's best here. For
- now, we ignore the impact of #pragma weak. */
return 0;
case REG:
Index: gcc/varasm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/varasm.c,v
retrieving revision 1.59.4.6
diff -u -p -r1.59.4.6 varasm.c
--- gcc/varasm.c 2001/01/25 14:03:24 1.59.4.6
+++ gcc/varasm.c 2001/03/13 01:04:04
@@ -723,6 +723,8 @@ make_decl_rtl (decl, asmspec, top_level)
Also handle vars declared register invalidly. */
if (DECL_RTL (decl) == 0)
{
+ rtx x;
+
/* Can't use just the variable's own name for a variable
whose scope is less than the whole file.
Concatenate a distinguishing number. */
@@ -752,8 +754,10 @@ make_decl_rtl (decl, asmspec, top_level)
new_name, strlen (new_name));
}
- DECL_RTL (decl) = gen_rtx_MEM (DECL_MODE (decl),
- gen_rtx_SYMBOL_REF (Pmode, name));
+ x = gen_rtx_SYMBOL_REF (Pmode, name);
+ SYMBOL_REF_WEAK (x) = DECL_WEAK (decl);
+ DECL_RTL (decl) = gen_rtx_MEM (DECL_MODE (decl), x);
+
MEM_ALIAS_SET (DECL_RTL (decl)) = get_alias_set (decl);
/* If this variable is to be treated as volatile, show its