From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Lance Taylor To: hjl@nynexst.com Cc: gas2@cygnus.com Subject: Re: A weak symbol bug in gas-950819 Date: Mon, 21 Aug 1995 08:14:00 -0000 Message-id: <199508211514.LAA17943@sanguine.cygnus.com> References: X-SW-Source: 1995/msg00155.html From: hjl@nynexst.com (H.J. Lu) Date: Sun, 20 Aug 1995 21:50:49 -0400 (EDT) There is a weak symbol bug in gas-950819. The old snapshots failed to pick up the real definition under certain circumstances. gas-950819 failed to set the weak symbol to zero. I'm not sure what you mean when you say that it failed to set the weak symbol to zero. I do see from your test case that the linker has a bug in the way it handles an undefined weak reference followed by a weak reference. I've checked in the appended patch, which should fix the problem. BTW, what an ELF linker should do with the symbol "xxx" in ld .... -lfoo -lbar where a real "xxx" is defined in libfoo.a, a weak one is defined in libbar.a and "xxx" is referenced in libbar.a only? The linker processes libraries sequentially. Assuming that there is no mention of "xxx" before libfoo.a, and assuming that the definition of "xxx" is not brought in from libfoo.a for some other reason, libfoo.a is irrelevant to this case. Ian Index: linker.c =================================================================== RCS file: /rel/cvsfiles/devo/bfd/linker.c,v retrieving revision 1.58 diff -p -r1.58 linker.c *** linker.c 1995/07/13 18:14:17 1.58 --- linker.c 1995/08/21 15:09:20 *************** enum link_action *** 1321,1327 **** static const enum link_action link_action[8][8] = { /* current\prev new undef undefw def defw com indr warn */ ! /* UNDEF_ROW */ {UND, NOACT, NOACT, REF, REF, NOACT, REFC, WARNC }, /* UNDEFW_ROW */ {WEAK, NOACT, NOACT, REF, REF, NOACT, REFC, WARNC }, /* DEF_ROW */ {DEF, DEF, DEF, MDEF, DEF, CDEF, MDEF, CYCLE }, /* DEFW_ROW */ {DEFW, DEFW, DEFW, NOACT, NOACT, NOACT, NOACT, CYCLE }, --- 1321,1327 ---- static const enum link_action link_action[8][8] = { /* current\prev new undef undefw def defw com indr warn */ ! /* UNDEF_ROW */ {UND, NOACT, UND, REF, REF, NOACT, REFC, WARNC }, /* UNDEFW_ROW */ {WEAK, NOACT, NOACT, REF, REF, NOACT, REFC, WARNC }, /* DEF_ROW */ {DEF, DEF, DEF, MDEF, DEF, CDEF, MDEF, CYCLE }, /* DEFW_ROW */ {DEFW, DEFW, DEFW, NOACT, NOACT, NOACT, NOACT, CYCLE }, Index: elflink.h =================================================================== RCS file: /rel/cvsfiles/devo/bfd/elflink.h,v retrieving revision 1.9 diff -p -r1.9 elflink.h *** elflink.h 1995/08/14 15:57:17 1.9 --- elflink.h 1995/08/21 15:09:22 *************** elf_link_add_archive_symbols (abfd, info *** 155,161 **** continue; if (h->root.type != bfd_link_hash_undefined) { ! defined[i] = true; continue; } --- 155,162 ---- continue; if (h->root.type != bfd_link_hash_undefined) { ! if (h->root.type != bfd_link_hash_undefweak) ! defined[i] = true; continue; }