This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: elflink.c assertion failure during glibc build
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Tue, 16 Mar 2004 09:43:00 -0800
- Subject: Re: elflink.c assertion failure during glibc build
- References: <20040316122341.GV3822@sunsite.ms.mff.cuni.cz>
On Tue, Mar 16, 2004 at 01:23:41PM +0100, Jakub Jelinek wrote:
> Hi!
>
> cat > 1.c <<EOF
> int __attribute__((weak)) foo (void) { return 1; }
> EOF
> cat > 2.c <<EOF
> int old_foo (void) { return 2; }
> int new_foo (void) { return 3; }
> asm (".symver old_foo, foo@GLIBC_2.0");
> asm (".symver new_foo, foo@@GLIBC_2.3.4");
> EOF
> gcc -O2 -fpic -r -o test.o 1.c 2.c
>
> (simplified testcase from glibc on PPC{,64}) gives:
> ld: BFD 2.15.90 20040312 assertion fail ../../bfd/elflink.c:1391
> (on all arches I've tried).
>
This patch works for me.
H.J.
----
2004-03-16 H.J. Lu <hongjiu.lu@intel.com>
* elflink.c (_bfd_elf_add_default_symbol): Clear the
ELF_LINK_HASH_DEF_REGULAR bit if the existing definition is
weak.
--- bfd/elflink.c.weak 2004-03-08 10:01:51.000000000 -0800
+++ bfd/elflink.c 2004-03-16 09:21:49.000000000 -0800
@@ -1325,6 +1325,10 @@ _bfd_elf_add_default_symbol (bfd *abfd,
if (! override)
{
+ /* If the existing definition is weak, we pretend it never
+ existed to avoid the assertion later. */
+ if (hi->root.type == bfd_link_hash_defweak)
+ hi->elf_link_hash_flags &= ~ELF_LINK_HASH_DEF_REGULAR;
bh = &hi->root;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, shortname, BSF_INDIRECT, bfd_ind_section_ptr,