This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: binutils is broken on Linux/alpha.


On Sat, Sep 29, 2001 at 05:50:26PM -0700, H . J . Lu wrote:
> This change is wrong or incomplete. You cannot do
> -      dir->plt.offset = ind->plt.offset;
> -      ind->plt.offset = (bfd_vma) -1;
> +      dir->plt.refcount = ind->plt.refcount;
> +      ind->plt.refcount = 0;

Oops.  Yes, it's plain wrong, and the error doesn't show up when building
cross tools, at least in the testsuite.  We really should set
ind->plt.refcount to the hash table init_refcount value, but the hash
table isn't immediately available here.  Fortunately, I think this trick
will work.

(The other approach to fixing the problem is to set refcounts to -1 here,
and change all the new refcount tests in check_relocs to test for <= 0,
rather than testing for == 0)

	* elf.c (_bfd_elf_link_hash_copy_indirect): Set ind refcounts to
	the old dir refcount, so we indirectly set them to init_refcount.
	Short-circuit asserts when we've just verified they are true.

-- 
Alan Modra

Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.95
diff -u -p -r1.95 elf.c
--- elf.c	2001/09/29 06:21:58	1.95
+++ elf.c	2001/09/30 02:49:31
@@ -992,6 +992,8 @@ void
 _bfd_elf_link_hash_copy_indirect (dir, ind)
      struct elf_link_hash_entry *dir, *ind;
 {
+  bfd_signed_vma tmp;
+
   /* Copy down any references that we may have already seen to the
      symbol which just became indirect.  */
 
@@ -1004,19 +1006,23 @@ _bfd_elf_link_hash_copy_indirect (dir, i
 
   /* Copy over the global and procedure linkage table refcount entries.
      These may have been already set up by a check_relocs routine.  */
-  if (dir->got.refcount <= 0)
+  tmp = dir->got.refcount;
+  if (tmp <= 0)
     {
       dir->got.refcount = ind->got.refcount;
-      ind->got.refcount = 0;
+      ind->got.refcount = tmp;
     }
-  BFD_ASSERT (ind->got.refcount <= 0);
+  else
+    BFD_ASSERT (ind->got.refcount <= 0);
 
-  if (dir->plt.refcount <= 0)
+  tmp = dir->plt.refcount;
+  if (tmp <= 0)
     {
       dir->plt.refcount = ind->plt.refcount;
-      ind->plt.refcount = 0;
+      ind->plt.refcount = tmp;
     }
-  BFD_ASSERT (ind->plt.refcount <= 0);
+  else
+    BFD_ASSERT (ind->plt.refcount <= 0);
 
   if (dir->dynindx == -1)
     {
@@ -1025,7 +1031,8 @@ _bfd_elf_link_hash_copy_indirect (dir, i
       ind->dynindx = -1;
       ind->dynstr_index = 0;
     }
-  BFD_ASSERT (ind->dynindx == -1);
+  else
+    BFD_ASSERT (ind->dynindx == -1);
 }
 
 void


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]