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]
Other format: [Raw text]

More --gc-sections problems


As revealed by an abort I placed in ppc64_elf_gc_sweep_hook, we weren't
looking in the right symbol for plt and got refcounts.  I guess this
didn't matter so much when we only supported --gc-sections when linking
statically.

	* elf64-ppc.c (ppc64_elf_gc_sweep_hook): Follow indirect and warning
	symbols.
	* elf32-arm.c (elf32_arm_gc_sweep_hook): Likewise.
	* elf32-cris.c (cris_elf_gc_sweep_hook): Likewise.
	* elf32-hppa.c (elf32_hppa_gc_sweep_hook): Likewise.
	* elf32-i386.c (elf_i386_gc_sweep_hook): Likewise.
	* elf32-m32r.c (m32r_elf_gc_sweep_hook): Likewise.
	* elf32-m68k.c (elf_m68k_gc_sweep_hook): Likewise.
	* elf32-ppc.c (ppc_elf_gc_sweep_hook): Likewise.
	* elf32-s390.c (elf_s390_gc_sweep_hook): Likewise.
	* elf32-sh.c (sh_elf_gc_sweep_hook): Likewise.
	* elf32-sparc.c (elf32_sparc_gc_sweep_hook): Likewise.
	* elf32-vax.c (elf_vax_gc_sweep_hook): Likewise.
	* elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Likewise.
	* elf64-s390.c (elf_s390_gc_sweep_hook): Likewise.
	* elf64-x86-64.c (elf64_x86_64_gc_sweep_hook): Likewise.

Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.15
diff -u -p -r1.15 elf32-arm.c
--- bfd/elf32-arm.c	6 Jan 2005 16:18:20 -0000	1.15
+++ bfd/elf32-arm.c	11 Jan 2005 08:22:57 -0000
@@ -3843,8 +3843,6 @@ elf32_arm_gc_sweep_hook (bfd *          
   struct elf_link_hash_entry **sym_hashes;
   bfd_signed_vma *local_got_refcounts;
   const Elf_Internal_Rela *rel, *relend;
-  unsigned long r_symndx;
-  struct elf_link_hash_entry *h;
   struct elf32_arm_link_hash_table * globals;
 
   globals = elf32_arm_hash_table (info);
@@ -3858,8 +3856,19 @@ elf32_arm_gc_sweep_hook (bfd *          
   relend = relocs + sec->reloc_count;
   for (rel = relocs; rel < relend; rel++)
     {
+      unsigned long r_symndx;
+      struct elf_link_hash_entry *h = NULL;
       int r_type;
 
+      r_symndx = ELF32_R_SYM (rel->r_info);
+      if (r_symndx >= symtab_hdr->sh_info)
+	{
+	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	  while (h->root.type == bfd_link_hash_indirect
+		 || h->root.type == bfd_link_hash_warning)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+	}
+
       r_type = ELF32_R_TYPE (rel->r_info);
 #ifndef OLD_ARM_ABI
       r_type = arm_real_reloc_type (globals, r_type);
@@ -3870,10 +3879,8 @@ elf32_arm_gc_sweep_hook (bfd *          
 #ifndef OLD_ARM_ABI
 	case R_ARM_GOT_PREL:
 #endif
-	  r_symndx = ELF32_R_SYM (rel->r_info);
-	  if (r_symndx >= symtab_hdr->sh_info)
+	  if (h != NULL)
 	    {
-	      h = sym_hashes[r_symndx - symtab_hdr->sh_info];
 	      if (h->got.refcount > 0)
 		h->got.refcount -= 1;
 	    }
@@ -3896,14 +3903,12 @@ elf32_arm_gc_sweep_hook (bfd *          
 	case R_ARM_THM_PC22:
 	  /* Should the interworking branches be here also?  */
 
-	  r_symndx = ELF32_R_SYM (rel->r_info);
-	  if (r_symndx >= symtab_hdr->sh_info)
+	  if (h != NULL)
 	    {
 	      struct elf32_arm_link_hash_entry *eh;
 	      struct elf32_arm_relocs_copied **pp;
 	      struct elf32_arm_relocs_copied *p;
 
-	      h = sym_hashes[r_symndx - symtab_hdr->sh_info];
 	      eh = (struct elf32_arm_link_hash_entry *) h;
 
 	      if (h->plt.refcount > 0)
Index: bfd/elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.60
diff -u -p -r1.60 elf32-cris.c
--- bfd/elf32-cris.c	4 Nov 2004 14:57:43 -0000	1.60
+++ bfd/elf32-cris.c	11 Jan 2005 08:22:59 -0000
@@ -1984,16 +1984,23 @@ cris_elf_gc_sweep_hook (abfd, info, sec,
   for (rel = relocs; rel < relend; rel++)
     {
       unsigned long r_symndx;
-      struct elf_link_hash_entry *h;
+      struct elf_link_hash_entry *h = NULL;
+
+      r_symndx = ELF32_R_SYM (rel->r_info);
+      if (r_symndx >= symtab_hdr->sh_info)
+	{
+	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	  while (h->root.type == bfd_link_hash_indirect
+		 || h->root.type == bfd_link_hash_warning)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+	}
 
       switch (ELF32_R_TYPE (rel->r_info))
 	{
 	case R_CRIS_16_GOT:
 	case R_CRIS_32_GOT:
-	  r_symndx = ELF32_R_SYM (rel->r_info);
-	  if (r_symndx >= symtab_hdr->sh_info)
+	  if (h != NULL)
 	    {
-	      h = sym_hashes[r_symndx - symtab_hdr->sh_info];
 	      if (h->got.refcount > 0)
 		{
 		  --h->got.refcount;
@@ -2027,23 +2034,22 @@ cris_elf_gc_sweep_hook (abfd, info, sec,
 	case R_CRIS_16_GOTPLT:
 	case R_CRIS_32_GOTPLT:
 	  /* For local symbols, treat these like GOT relocs.  */
-	  r_symndx = ELF32_R_SYM (rel->r_info);
-	  if (r_symndx < symtab_hdr->sh_info)
+	  if (h == NULL)
 	    goto local_got_reloc;
 	  /* Fall through.  */
+
 	case R_CRIS_32_PLT_GOTREL:
 	  /* FIXME: We don't garbage-collect away the .got section.  */
 	  if (local_got_refcounts != NULL)
 	    local_got_refcounts[-1]--;
 	  /* Fall through.  */
+
 	case R_CRIS_8_PCREL:
 	case R_CRIS_16_PCREL:
 	case R_CRIS_32_PCREL:
 	case R_CRIS_32_PLT_PCREL:
-	  r_symndx = ELF32_R_SYM (rel->r_info);
-	  if (r_symndx >= symtab_hdr->sh_info)
+	  if (h != NULL)
 	    {
-	      h = sym_hashes[r_symndx - symtab_hdr->sh_info];
 	      if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
 		  && h->plt.refcount > 0)
 		--h->plt.refcount;
Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.124
diff -u -p -r1.124 elf32-hppa.c
--- bfd/elf32-hppa.c	30 Nov 2004 00:50:36 -0000	1.124
+++ bfd/elf32-hppa.c	11 Jan 2005 08:23:01 -0000
@@ -1537,6 +1537,9 @@ elf32_hppa_gc_sweep_hook (bfd *abfd,
 	  struct elf32_hppa_dyn_reloc_entry *p;
 
 	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	  while (h->root.type == bfd_link_hash_indirect
+		 || h->root.type == bfd_link_hash_warning)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
 	  eh = (struct elf32_hppa_link_hash_entry *) h;
 
 	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
Index: bfd/elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.130
diff -u -p -r1.130 elf32-i386.c
--- bfd/elf32-i386.c	21 Oct 2004 15:28:21 -0000	1.130
+++ bfd/elf32-i386.c	11 Jan 2005 08:23:03 -0000
@@ -1248,6 +1248,9 @@ elf_i386_gc_sweep_hook (bfd *abfd,
 	  struct elf_i386_dyn_relocs *p;
 
 	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	  while (h->root.type == bfd_link_hash_indirect
+		 || h->root.type == bfd_link_hash_warning)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
 	  eh = (struct elf_i386_link_hash_entry *) h;
 
 	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
Index: bfd/elf32-m32r.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m32r.c,v
retrieving revision 1.54
diff -u -p -r1.54 elf32-m32r.c
--- bfd/elf32-m32r.c	21 Oct 2004 15:28:23 -0000	1.54
+++ bfd/elf32-m32r.c	11 Jan 2005 08:23:06 -0000
@@ -4341,8 +4341,6 @@ m32r_elf_gc_sweep_hook (abfd, info, sec,
   struct elf_link_hash_entry **sym_hashes;
   bfd_signed_vma *local_got_refcounts;
   const Elf_Internal_Rela *rel, *relend;
-  unsigned long r_symndx;
-  struct elf_link_hash_entry *h;
 
   elf_section_data (sec)->local_dynrel = NULL;
 
@@ -4352,84 +4350,91 @@ m32r_elf_gc_sweep_hook (abfd, info, sec,
 
   relend = relocs + sec->reloc_count;
   for (rel = relocs; rel < relend; rel++)
-    switch (ELF32_R_TYPE (rel->r_info))
-      {
-      case R_M32R_GOT16_HI_ULO:
-      case R_M32R_GOT16_HI_SLO:
-      case R_M32R_GOT16_LO:
-      case R_M32R_GOTOFF:
-      case R_M32R_GOTOFF_HI_ULO:
-      case R_M32R_GOTOFF_HI_SLO:
-      case R_M32R_GOTOFF_LO:
-      case R_M32R_GOT24:
-      case R_M32R_GOTPC_HI_ULO:
-      case R_M32R_GOTPC_HI_SLO:
-      case R_M32R_GOTPC_LO:
-      case R_M32R_GOTPC24:
-	r_symndx = ELF32_R_SYM (rel->r_info);
-	if (r_symndx >= symtab_hdr->sh_info)
-	  {
-	    h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-	    if (h->got.refcount > 0)
-	      h->got.refcount--;
-	  }
-	else
-	  {
-	    if (local_got_refcounts && local_got_refcounts[r_symndx] > 0)
-	      local_got_refcounts[r_symndx]--;
-	  }
-        break;
-
-      case R_M32R_16_RELA:
-      case R_M32R_24_RELA:
-      case R_M32R_32_RELA:
-      case R_M32R_HI16_ULO_RELA:
-      case R_M32R_HI16_SLO_RELA:
-      case R_M32R_LO16_RELA:
-      case R_M32R_SDA16_RELA:
-      case R_M32R_18_PCREL_RELA:
-      case R_M32R_26_PCREL_RELA:
-        r_symndx = ELF32_R_SYM (rel->r_info);
-        if (r_symndx >= symtab_hdr->sh_info)
-          {
-            struct elf_m32r_link_hash_entry *eh;
-            struct elf_m32r_dyn_relocs **pp;
-            struct elf_m32r_dyn_relocs *p;
-
-            h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-
-            if (!info->shared && h->plt.refcount > 0)
-              h->plt.refcount -= 1;
-
-            eh = (struct elf_m32r_link_hash_entry *) h;
+    {
+      unsigned long r_symndx;
+      struct elf_link_hash_entry *h = NULL;
 
-            for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
-              if (p->sec == sec)
-                {
-                  if (ELF32_R_TYPE (rel->r_info) == R_M32R_26_PCREL_RELA
-                      || ELF32_R_TYPE (rel->r_info) == R_M32R_26_PCREL_RELA)
-                    p->pc_count -= 1;
-                  p->count -= 1;
-                  if (p->count == 0)
-                    *pp = p->next;
-                  break;
-                }
-          }
-        break;
+      r_symndx = ELF32_R_SYM (rel->r_info);
+      if (r_symndx >= symtab_hdr->sh_info)
+	{
+	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	  while (h->root.type == bfd_link_hash_indirect
+		 || h->root.type == bfd_link_hash_warning)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+	}
 
-      case R_M32R_26_PLTREL:
-	r_symndx = ELF32_R_SYM (rel->r_info);
-	if (r_symndx >= symtab_hdr->sh_info)
-	  {
-	    h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-	    if (h->plt.refcount > 0)
-	      h->plt.refcount--;
-	  }
-	break;
-
-      default:
-	break;
-      }
+      switch (ELF32_R_TYPE (rel->r_info))
+	{
+	case R_M32R_GOT16_HI_ULO:
+	case R_M32R_GOT16_HI_SLO:
+	case R_M32R_GOT16_LO:
+	case R_M32R_GOTOFF:
+	case R_M32R_GOTOFF_HI_ULO:
+	case R_M32R_GOTOFF_HI_SLO:
+	case R_M32R_GOTOFF_LO:
+	case R_M32R_GOT24:
+	case R_M32R_GOTPC_HI_ULO:
+	case R_M32R_GOTPC_HI_SLO:
+	case R_M32R_GOTPC_LO:
+	case R_M32R_GOTPC24:
+	  if (h != NULL)
+	    {
+	      if (h->got.refcount > 0)
+		h->got.refcount--;
+	    }
+	  else
+	    {
+	      if (local_got_refcounts && local_got_refcounts[r_symndx] > 0)
+		local_got_refcounts[r_symndx]--;
+	    }
+	  break;
+
+	case R_M32R_16_RELA:
+	case R_M32R_24_RELA:
+	case R_M32R_32_RELA:
+	case R_M32R_HI16_ULO_RELA:
+	case R_M32R_HI16_SLO_RELA:
+	case R_M32R_LO16_RELA:
+	case R_M32R_SDA16_RELA:
+	case R_M32R_18_PCREL_RELA:
+	case R_M32R_26_PCREL_RELA:
+	  if (h != NULL)
+	    {
+	      struct elf_m32r_link_hash_entry *eh;
+	      struct elf_m32r_dyn_relocs **pp;
+	      struct elf_m32r_dyn_relocs *p;
+
+	      if (!info->shared && h->plt.refcount > 0)
+		h->plt.refcount -= 1;
+
+	      eh = (struct elf_m32r_link_hash_entry *) h;
+
+	      for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
+		if (p->sec == sec)
+		  {
+		    if (ELF32_R_TYPE (rel->r_info) == R_M32R_26_PCREL_RELA
+			|| ELF32_R_TYPE (rel->r_info) == R_M32R_26_PCREL_RELA)
+		      p->pc_count -= 1;
+		    p->count -= 1;
+		    if (p->count == 0)
+		      *pp = p->next;
+		    break;
+		  }
+	    }
+	  break;
+
+	case R_M32R_26_PLTREL:
+	  if (h != NULL)
+	    {
+	      if (h->plt.refcount > 0)
+		h->plt.refcount--;
+	    }
+	  break;
+
+	default:
+	  break;
+	}
+    }
 
   return TRUE;
 }
Index: bfd/elf32-m68k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68k.c,v
retrieving revision 1.71
diff -u -p -r1.71 elf32-m68k.c
--- bfd/elf32-m68k.c	7 Nov 2004 10:51:45 -0000	1.71
+++ bfd/elf32-m68k.c	11 Jan 2005 08:23:07 -0000
@@ -835,7 +835,16 @@ elf_m68k_gc_sweep_hook (abfd, info, sec,
   for (rel = relocs; rel < relend; rel++)
     {
       unsigned long r_symndx;
-      struct elf_link_hash_entry *h;
+      struct elf_link_hash_entry *h = NULL;
+
+      r_symndx = ELF32_R_SYM (rel->r_info);
+      if (r_symndx >= symtab_hdr->sh_info)
+	{
+	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	  while (h->root.type == bfd_link_hash_indirect
+		 || h->root.type == bfd_link_hash_warning)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+	}
 
       switch (ELF32_R_TYPE (rel->r_info))
 	{
@@ -845,10 +854,8 @@ elf_m68k_gc_sweep_hook (abfd, info, sec,
 	case R_68K_GOT8O:
 	case R_68K_GOT16O:
 	case R_68K_GOT32O:
-	  r_symndx = ELF32_R_SYM (rel->r_info);
-	  if (r_symndx >= symtab_hdr->sh_info)
+	  if (h != NULL)
 	    {
-	      h = sym_hashes[r_symndx - symtab_hdr->sh_info];
 	      if (h->got.refcount > 0)
 		{
 		  --h->got.refcount;
@@ -888,10 +895,8 @@ elf_m68k_gc_sweep_hook (abfd, info, sec,
 	case R_68K_8:
 	case R_68K_16:
 	case R_68K_32:
-	  r_symndx = ELF32_R_SYM (rel->r_info);
-	  if (r_symndx >= symtab_hdr->sh_info)
+	  if (h != NULL)
 	    {
-	      h = sym_hashes[r_symndx - symtab_hdr->sh_info];
 	      if (h->plt.refcount > 0)
 		--h->plt.refcount;
 	    }
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.131
diff -u -p -r1.131 elf32-ppc.c
--- bfd/elf32-ppc.c	10 Dec 2004 14:04:56 -0000	1.131
+++ bfd/elf32-ppc.c	11 Jan 2005 08:23:10 -0000
@@ -4075,6 +4075,9 @@ ppc_elf_gc_sweep_hook (bfd *abfd,
 	  struct ppc_elf_link_hash_entry *eh;
 
 	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	  while (h->root.type == bfd_link_hash_indirect
+		 || h->root.type == bfd_link_hash_warning)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
 	  eh = (struct ppc_elf_link_hash_entry *) h;
 
 	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
Index: bfd/elf32-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-s390.c,v
retrieving revision 1.67
diff -u -p -r1.67 elf32-s390.c
--- bfd/elf32-s390.c	21 Oct 2004 15:28:24 -0000	1.67
+++ bfd/elf32-s390.c	11 Jan 2005 08:23:12 -0000
@@ -1437,6 +1437,9 @@ elf_s390_gc_sweep_hook (abfd, info, sec,
 	  struct elf_s390_dyn_relocs *p;
 
 	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	  while (h->root.type == bfd_link_hash_indirect
+		 || h->root.type == bfd_link_hash_warning)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
 	  eh = (struct elf_s390_link_hash_entry *) h;
 
 	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
Index: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.117
diff -u -p -r1.117 elf32-sh.c
--- bfd/elf32-sh.c	28 Oct 2004 12:00:17 -0000	1.117
+++ bfd/elf32-sh.c	11 Jan 2005 08:23:15 -0000
@@ -6082,14 +6082,14 @@ sh_elf_gc_sweep_hook (bfd *abfd, struct 
 	  struct elf_sh_dyn_relocs *p;
 
 	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-#ifdef INCLUDE_SHMEDIA
 	  while (h->root.type == bfd_link_hash_indirect
 		 || h->root.type == bfd_link_hash_warning)
 	    {
+#ifdef INCLUDE_SHMEDIA
 	      seen_stt_datalabel |= h->type == STT_DATALABEL;
+#endif
 	      h = (struct elf_link_hash_entry *) h->root.u.i.link;
 	    }
-#endif
 	  eh = (struct elf_sh_link_hash_entry *) h;
 	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
 	    if (p->sec == sec)
Index: bfd/elf32-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sparc.c,v
retrieving revision 1.78
diff -u -p -r1.78 elf32-sparc.c
--- bfd/elf32-sparc.c	9 Jan 2005 19:49:22 -0000	1.78
+++ bfd/elf32-sparc.c	11 Jan 2005 08:23:16 -0000
@@ -1345,6 +1345,9 @@ elf32_sparc_gc_sweep_hook (abfd, info, s
 	  struct elf32_sparc_dyn_relocs *p;
 
 	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	  while (h->root.type == bfd_link_hash_indirect
+		 || h->root.type == bfd_link_hash_warning)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
 	  eh = (struct elf32_sparc_link_hash_entry *) h;
 	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
 	    if (p->sec == sec)
Index: bfd/elf32-vax.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-vax.c,v
retrieving revision 1.25
diff -u -p -r1.25 elf32-vax.c
--- bfd/elf32-vax.c	21 Oct 2004 15:28:25 -0000	1.25
+++ bfd/elf32-vax.c	11 Jan 2005 08:23:18 -0000
@@ -904,18 +904,22 @@ elf_vax_gc_sweep_hook (abfd, info, sec, 
   for (rel = relocs; rel < relend; rel++)
     {
       unsigned long r_symndx;
-      struct elf_link_hash_entry *h;
+      struct elf_link_hash_entry *h = NULL;
+
+      r_symndx = ELF32_R_SYM (rel->r_info);
+      if (r_symndx >= symtab_hdr->sh_info)
+	{
+	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	  while (h->root.type == bfd_link_hash_indirect
+		 || h->root.type == bfd_link_hash_warning)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+	}
 
       switch (ELF32_R_TYPE (rel->r_info))
 	{
 	case R_VAX_GOT32:
-	  r_symndx = ELF32_R_SYM (rel->r_info);
-	  if (r_symndx >= symtab_hdr->sh_info)
-	    {
-	      h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-	      if (h->got.refcount > 0)
-		--h->got.refcount;
-	    }
+	  if (h != NULL && h->got.refcount > 0)
+	    --h->got.refcount;
 	  break;
 
 	case R_VAX_PLT32:
@@ -925,13 +929,8 @@ elf_vax_gc_sweep_hook (abfd, info, sec, 
 	case R_VAX_8:
 	case R_VAX_16:
 	case R_VAX_32:
-	  r_symndx = ELF32_R_SYM (rel->r_info);
-	  if (r_symndx >= symtab_hdr->sh_info)
-	    {
-	      h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-	      if (h->plt.refcount > 0)
-		--h->plt.refcount;
-	    }
+	  if (h != NULL && h->plt.refcount > 0)
+	    --h->plt.refcount;
 	  break;
 
 	default:
Index: bfd/elf32-xtensa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v
retrieving revision 1.40
diff -u -p -r1.40 elf32-xtensa.c
--- bfd/elf32-xtensa.c	19 Nov 2004 00:28:58 -0000	1.40
+++ bfd/elf32-xtensa.c	11 Jan 2005 08:23:23 -0000
@@ -1039,7 +1039,12 @@ elf_xtensa_gc_sweep_hook (bfd *abfd,
 
       r_symndx = ELF32_R_SYM (rel->r_info);
       if (r_symndx >= symtab_hdr->sh_info)
-	h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	{
+	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	  while (h->root.type == bfd_link_hash_indirect
+		 || h->root.type == bfd_link_hash_warning)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+	}
 
       r_type = ELF32_R_TYPE (rel->r_info);
       switch (r_type)
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.184
diff -u -p -r1.184 elf64-ppc.c
--- bfd/elf64-ppc.c	6 Jan 2005 09:03:52 -0000	1.184
+++ bfd/elf64-ppc.c	11 Jan 2005 08:23:27 -0000
@@ -4989,6 +4989,9 @@ ppc64_elf_gc_sweep_hook (bfd *abfd, stru
 	  struct ppc_dyn_relocs *p;
 
 	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	  while (h->root.type == bfd_link_hash_indirect
+		 || h->root.type == bfd_link_hash_warning)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
 	  eh = (struct ppc_link_hash_entry *) h;
 
 	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
Index: bfd/elf64-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-s390.c,v
retrieving revision 1.67
diff -u -p -r1.67 elf64-s390.c
--- bfd/elf64-s390.c	21 Oct 2004 15:28:26 -0000	1.67
+++ bfd/elf64-s390.c	11 Jan 2005 08:23:29 -0000
@@ -1402,6 +1402,9 @@ elf_s390_gc_sweep_hook (abfd, info, sec,
 	  struct elf_s390_dyn_relocs *p;
 
 	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	  while (h->root.type == bfd_link_hash_indirect
+		 || h->root.type == bfd_link_hash_warning)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
 	  eh = (struct elf_s390_link_hash_entry *) h;
 
 	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
Index: bfd/elf64-x86-64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v
retrieving revision 1.87
diff -u -p -r1.87 elf64-x86-64.c
--- bfd/elf64-x86-64.c	21 Oct 2004 15:28:26 -0000	1.87
+++ bfd/elf64-x86-64.c	11 Jan 2005 08:23:31 -0000
@@ -1043,6 +1043,9 @@ elf64_x86_64_gc_sweep_hook (bfd *abfd, s
 	  struct elf64_x86_64_dyn_relocs *p;
 
 	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	  while (h->root.type == bfd_link_hash_indirect
+		 || h->root.type == bfd_link_hash_warning)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
 	  eh = (struct elf64_x86_64_link_hash_entry *) h;
 
 	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)


-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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