Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Richard Henderson <rth@dot.cygnus.com>
To: Eric Ding <ericding@applix.com>, axp-list@redhat.com
Cc: gafton@redhat.com
Subject: Re: BUG: probs with resolving functions in shared library
Date: Sat, 8 Aug 1998 15:29:39 -0700	[thread overview]
Message-ID: <19980808152939.A29135@dot.cygnus.com> (raw)
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;
 


  reply	other threads:[~1998-08-08 22:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-08-05 16:16 BUG: probs with resolving functions in shared library Eric Ding
1998-08-08 22:29 ` Richard Henderson [this message]
1998-08-10 15:54   ` Eric Ding
1998-08-10 17:52     ` Richard Henderson
1998-08-10 19:51       ` Eric Ding
1998-08-12 17:07   ` Eric Ding
1998-08-12 17:31     ` Applix? Port? (was re: BUG...) Keith Baker
1998-08-12 21:08       ` Eric Ding
  -- strict thread matches above, loose matches on Subject: below --
1998-08-05 22:48 BUG: probs with resolving functions in shared library Quant-X Alpha Linux Support
1998-08-06  2:38 ` Eric Ding
1998-08-06 12:59   ` Quant-X Alpha Linux Support
1998-08-06 16:30     ` Eric Ding
1998-08-06 21:24       ` Quant-X Alpha Linux Support
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox