From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 13755 invoked from network); 8 Aug 1998 22:29:40 -0000 Received: from dot.cygnus.com (205.180.230.224) by mail2.redhat.com with SMTP; 8 Aug 1998 22:29:40 -0000 Received: (from rth@localhost) by dot.cygnus.com (8.8.5/8.8.5) id PAA29149; Sat, 8 Aug 1998 15:29:39 -0700 Message-ID: <19980808152939.A29135@dot.cygnus.com> Date: Sat, 8 Aug 1998 15:29:39 -0700 From: Richard Henderson To: Eric Ding , axp-list@redhat.com Cc: gafton@redhat.com Subject: Re: BUG: probs with resolving functions in shared library Reply-To: Richard Henderson References: <199808051616.MAA23543@tuxedo> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.91.1i In-Reply-To: <199808051616.MAA23543@tuxedo>; from Eric Ding on Wed, Aug 05, 1998 at 12:16:57PM -0400 On Wed, Aug 05, 1998 at 12:16:57PM -0400, Eric Ding wrote: > While #2 is an acceptable workaround in my test case, it indicates to me > that there's a significant linker (?) bug that I can't work around in the > case of the software I'm actually porting (Applixware). Any thoughts? > Am I doing something wrong? No, you are doing nothing wrong. This is a bug in binutils. Here is a patch. r~ * elf64-alpha.c (alpha_elf_dynamic_symbol_p): Undef weak symbols are always dynamic. (elf64_alpha_calc_dynrel_sizes): Allow enough room for RELATIVE .got relocs in -Bsymbolic shared objects. Index: elf64-alpha.c =================================================================== RCS file: /cvs/cvsfiles/devo/bfd/elf64-alpha.c,v retrieving revision 1.33 diff -u -p -r1.33 elf64-alpha.c --- elf64-alpha.c 1998/07/21 01:54:28 1.33 +++ elf64-alpha.c 1998/08/08 22:13:39 @@ -229,7 +229,8 @@ struct alpha_elf_link_hash_table (((info)->shared && !(info)->symbolic && (h)->dynindx != -1) \ || (((h)->elf_link_hash_flags \ & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR)) \ - == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))) + == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR)) \ + || (h)->root.type == bfd_link_hash_undefweak) /* Create an entry in a Alpha ELF linker hash table. */ @@ -3137,39 +3138,31 @@ elf64_alpha_calc_dynrel_sizes (h, info) /* If the symbol is dynamic, we'll need all the relocations in their natural form. If it has been forced local, we'll need the same - number of RELATIVE relocations. */ - if (alpha_elf_dynamic_symbol_p (&h->root, info) - || (info->shared && h->root.dynindx == -1)) - { - struct alpha_elf_reloc_entry *relent; - - for (relent = h->reloc_entries; relent; relent = relent->next) - { - relent->srel->_raw_size += - sizeof (Elf64_External_Rela) * relent->count; - } + number of RELATIVE relocations. + Except, don't add a .got reloc if we're not using a .plt entry. */ - /* Only add a .rela.got entry if we're not using a .plt entry. */ - if (h->root.plt.offset == MINUS_ONE) + if ((alpha_elf_dynamic_symbol_p (&h->root, info) + || info->shared) + && h->root.plt.offset == MINUS_ONE) + { + bfd *dynobj = elf_hash_table(info)->dynobj; + struct alpha_elf_got_entry *gotent; + bfd_size_type count = 0; + asection *srel; + + for (gotent = h->got_entries; gotent ; gotent = gotent->next) + count++; + if (count > 0) { - bfd *dynobj = elf_hash_table(info)->dynobj; - struct alpha_elf_got_entry *gotent; - bfd_size_type count = 0; - asection *srel; - - for (gotent = h->got_entries; gotent ; gotent = gotent->next) - count++; - if (count > 0) - { - srel = bfd_get_section_by_name (dynobj, ".rela.got"); - BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf64_External_Rela) * count; - } + srel = bfd_get_section_by_name (dynobj, ".rela.got"); + BFD_ASSERT (srel != NULL); + srel->_raw_size += sizeof (Elf64_External_Rela) * count; } } - /* Otherwise, shared objects require RELATIVE relocs for all REFQUAD + + /* Shared objects require at least RELATIVE relocs for all REFQUAD and REFLONG relocations. */ - else if (info->shared) + if (info->shared) { struct alpha_elf_reloc_entry *relent; @@ -3610,7 +3603,8 @@ elf64_alpha_relocate_section (output_bfd /* If the symbol has been forced local, output a RELATIVE reloc, otherwise it will be handled in finish_dynamic_symbol. */ - if (info->shared && h->root.dynindx == -1) + if (info->shared + && !alpha_elf_dynamic_symbol_p (&h->root, info)) { Elf_Internal_Rela outrel;