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]

Re: Shared library debugging


On Mon, Feb 04, 2002 at 04:40:45PM -0600, Steve Munroe wrote:
> While running glibc for PPC64 "make check" ./nss/test-netdb fails with a
> segfault.
[snip]
> But looking at the dynamic section from libresolv.so we find that TEXTREL
> is not included:

glibc/resolv/res_debug.c declares a number of "const struct res_sym"
arrays, and these have a field that is a pointer to a string.  The
strings and the structures both end up in the rodata section, and
because the string pointer is to a local sym which is reduced to a
section sym, we hit a binutils bug.

I'm committing the following fix.

bfd/ChangeLog
	* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Check for relocs
	against section syms in readonly sections.  Don't do the global
	sym check if we find one.
	* elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
	* elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise.
	* elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
	(elf_s390_grok_prstatus): Add missing prototype.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.25
diff -u -p -r1.25 elf64-ppc.c
--- elf64-ppc.c	2002/01/31 04:13:14	1.25
+++ elf64-ppc.c	2002/02/04 23:47:44
@@ -2995,10 +2995,12 @@ ppc64_elf_size_dynamic_sections (output_
 		     linker script /DISCARD/, so we'll be discarding
 		     the relocs too.  */
 		}
-	      else
+	      else if (p->count != 0)
 		{
 		  srel = elf_section_data (p->sec)->sreloc;
 		  srel->_raw_size += p->count * sizeof (Elf64_External_Rela);
+		  if ((p->sec->output_section->flags & SEC_READONLY) != 0)
+		    info->flags |= DF_TEXTREL;
 		}
 	    }
 	}
@@ -3135,7 +3137,9 @@ ppc64_elf_size_dynamic_sections (output_
 
 	  /* If any dynamic relocs apply to a read-only section,
 	     then we need a DT_TEXTREL entry.  */
-	  elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, (PTR) info);
+	  if ((info->flags & DF_TEXTREL) == 0)
+	    elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
+				    (PTR) info);
 
 	  if ((info->flags & DF_TEXTREL) != 0)
 	    {
Index: bfd/elf64-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-s390.c,v
retrieving revision 1.18
diff -u -p -r1.18 elf64-s390.c
--- elf64-s390.c	2002/01/29 11:14:35	1.18
+++ elf64-s390.c	2002/02/04 23:47:46
@@ -1418,10 +1418,12 @@ elf_s390_size_dynamic_sections (output_b
 		     linker script /DISCARD/, so we'll be discarding
 		     the relocs too.  */
 		}
-	      else
+	      else if (p->count != 0)
 		{
 		  srela = elf_section_data (p->sec)->sreloc;
 		  srela->_raw_size += p->count * sizeof (Elf64_External_Rela);
+		  if ((p->sec->output_section->flags & SEC_READONLY) != 0)
+		    info->flags |= DF_TEXTREL;
 		}
 	    }
 	}
@@ -1543,7 +1545,9 @@ elf_s390_size_dynamic_sections (output_b
 
 	  /* If any dynamic relocs apply to a read-only section,
 	     then we need a DT_TEXTREL entry.  */
-	  elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, (PTR) info);
+	  if ((info->flags & DF_TEXTREL) == 0)
+	    elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
+				    (PTR) info);
 
 	  if ((info->flags & DF_TEXTREL) != 0)
 	    {
Index: bfd/elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.63
diff -u -p -r1.63 elf32-i386.c
--- elf32-i386.c	2002/01/29 11:14:35	1.63
+++ elf32-i386.c	2002/02/04 23:47:48
@@ -1500,10 +1500,12 @@ elf_i386_size_dynamic_sections (output_b
 		     linker script /DISCARD/, so we'll be discarding
 		     the relocs too.  */
 		}
-	      else
+	      else if (p->count != 0)
 		{
 		  srel = elf_section_data (p->sec)->sreloc;
 		  srel->_raw_size += p->count * sizeof (Elf32_External_Rel);
+		  if ((p->sec->output_section->flags & SEC_READONLY) != 0)
+		    info->flags |= DF_TEXTREL;
 		}
 	    }
 	}
@@ -1625,7 +1627,9 @@ elf_i386_size_dynamic_sections (output_b
 
 	  /* If any dynamic relocs apply to a read-only section,
 	     then we need a DT_TEXTREL entry.  */
-	  elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, (PTR) info);
+	  if ((info->flags & DF_TEXTREL) == 0)
+	    elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
+				    (PTR) info);
 
 	  if ((info->flags & DF_TEXTREL) != 0)
 	    {
Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.69
diff -u -p -r1.69 elf32-hppa.c
--- elf32-hppa.c	2002/01/21 10:29:08	1.69
+++ elf32-hppa.c	2002/02/04 23:47:50
@@ -2329,10 +2329,12 @@ elf32_hppa_size_dynamic_sections (output
 		     linker script /DISCARD/, so we'll be discarding
 		     the relocs too.  */
 		}
-	      else
+	      else if (p->count != 0)
 		{
 		  srel = elf_section_data (p->sec)->sreloc;
 		  srel->_raw_size += p->count * sizeof (Elf32_External_Rela);
+		  if ((p->sec->output_section->flags & SEC_READONLY) != 0)
+		    info->flags |= DF_TEXTREL;
 		}
 	    }
 	}
@@ -2505,7 +2507,9 @@ elf32_hppa_size_dynamic_sections (output
 
 	  /* If any dynamic relocs apply to a read-only section,
 	     then we need a DT_TEXTREL entry.  */
-	  elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, (PTR) info);
+	  if ((info->flags & DF_TEXTREL) == 0)
+	    elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
+				    (PTR) info);
 
 	  if ((info->flags & DF_TEXTREL) != 0)
 	    {
Index: bfd/elf32-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-s390.c,v
retrieving revision 1.19
diff -u -p -r1.19 elf32-s390.c
--- elf32-s390.c	2002/01/29 11:14:35	1.19
+++ elf32-s390.c	2002/02/04 23:47:54
@@ -69,6 +69,7 @@ static enum elf_reloc_type_class elf_s39
 static boolean elf_s390_finish_dynamic_sections
   PARAMS ((bfd *, struct bfd_link_info *));
 static boolean elf_s390_object_p PARAMS ((bfd *));
+static boolean elf_s390_grok_prstatus PARAMS ((bfd *, Elf_Internal_Note *));
 
 #define USE_RELA 1		/* We want RELA relocations, not REL.  */
 
@@ -1439,10 +1440,12 @@ elf_s390_size_dynamic_sections (output_b
 		     linker script /DISCARD/, so we'll be discarding
 		     the relocs too.  */
 		}
-	      else
+	      else if (p->count != 0)
 		{
 		  srela = elf_section_data (p->sec)->sreloc;
 		  srela->_raw_size += p->count * sizeof (Elf32_External_Rela);
+		  if ((p->sec->output_section->flags & SEC_READONLY) != 0)
+		    info->flags |= DF_TEXTREL;
 		}
 	    }
 	}
@@ -1564,7 +1567,9 @@ elf_s390_size_dynamic_sections (output_b
 
 	  /* If any dynamic relocs apply to a read-only section,
 	     then we need a DT_TEXTREL entry.  */
-	  elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, (PTR) info);
+	  if ((info->flags & DF_TEXTREL) == 0)
+	    elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
+				    (PTR) info);
 
 	  if ((info->flags & DF_TEXTREL) != 0)
 	    {


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