Blame SOURCES/gdb-rhbz1125820-ppc64le-enablement-15of37.patch

2c2fa1
commit afe397ea85a3d09d936c93328a1f6bf640577cf3
2c2fa1
Author: Alan Modra <amodra@gmail.com>
2c2fa1
Date:   Wed Nov 6 10:20:52 2013 +1030
2c2fa1
2c2fa1
    Correct elf64-ppc.c handling of protected symbols
2c2fa1
    
2c2fa1
    Some places in elf64-ppc.c carelessly used SYMBOL_CALLS_LOCAL when
2c2fa1
    the proper test is SYMBOL_REFERENCES_LOCAL for cases where we take the
2c2fa1
    address of a protected symbol.  This works OK for function descriptors
2c2fa1
    but not for ELFv2.  Setting symbols to their global entry stub a
2c2fa1
    little earlier is to ensure _bfd_elf_hash_symbol allows such symbols
2c2fa1
    in .gnu.hash.
2c2fa1
    
2c2fa1
    	* elf64-ppc.c (ppc64_elf_edit_toc): Use SYMBOL_REFERENCES_LOCAL
2c2fa1
    	here, not SYMBOL_CALLS_LOCAL.
2c2fa1
    	(ppc64_elf_relocate_section): Likewise.
2c2fa1
    	(size_global_entry_stubs): Set undefined symbols on their global
2c2fa1
    	entry stubs here..
2c2fa1
    	(build_global_entry_stubs): ..rather than here.
2c2fa1
    	(ppc64_elf_build_stubs): Don't reset glink->size before calling
2c2fa1
    	build_global_entry_stubs.
2c2fa1
2c2fa1
Index: gdb-7.6.1/bfd/elf64-ppc.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/bfd/elf64-ppc.c
2c2fa1
+++ gdb-7.6.1/bfd/elf64-ppc.c
2c2fa1
@@ -8496,7 +8496,7 @@ ppc64_elf_edit_toc (struct bfd_link_info
2c2fa1
 		  || discarded_section (sym_sec))
2c2fa1
 		continue;
2c2fa1
 
2c2fa1
-	      if (!SYMBOL_CALLS_LOCAL (info, h))
2c2fa1
+	      if (!SYMBOL_REFERENCES_LOCAL (info, h))
2c2fa1
 		continue;
2c2fa1
 
2c2fa1
 	      if (h != NULL)
2c2fa1
@@ -9344,7 +9344,13 @@ size_global_entry_stubs (struct elf_link
2c2fa1
     if (pent->plt.offset != (bfd_vma) -1
2c2fa1
 	&& pent->addend == 0)
2c2fa1
       {
2c2fa1
+	/* For ELFv2, if this symbol is not defined in a regular file
2c2fa1
+	   and we are not generating a shared library or pie, then we
2c2fa1
+	   need to define the symbol in the executable on a call stub.
2c2fa1
+	   This is to avoid text relocations.  */
2c2fa1
 	s->size = (s->size + 15) & -16;
2c2fa1
+	h->root.u.def.section = s;
2c2fa1
+	h->root.u.def.value = s->size;
2c2fa1
 	s->size += 16;
2c2fa1
 	break;
2c2fa1
       }
2c2fa1
@@ -12183,13 +12189,6 @@ build_global_entry_stubs (struct elf_lin
2c2fa1
 	asection *plt;
2c2fa1
 	bfd_vma off;
2c2fa1
 
2c2fa1
-	/* For ELFv2, if this symbol is not defined in a regular file
2c2fa1
-	   and we are not generating a shared library or pie, then we
2c2fa1
-	   need to define the symbol in the executable on a call stub.
2c2fa1
-	   This is to avoid text relocations.  */
2c2fa1
-	h->root.u.def.section = s;
2c2fa1
-	h->root.u.def.value = s->size;
2c2fa1
-	s->size += 16;
2c2fa1
 	p = s->contents + h->root.u.def.value;
2c2fa1
 	plt = htab->plt;
2c2fa1
 	if (!htab->elf.dynamic_sections_created
2c2fa1
@@ -12383,10 +12382,7 @@ ppc64_elf_build_stubs (bfd_boolean emit_
2c2fa1
 
2c2fa1
       /* Build .glink global entry stubs.  */
2c2fa1
       if (htab->glink->size > htab->glink->rawsize)
2c2fa1
-	{
2c2fa1
-	  htab->glink->size = (htab->glink->rawsize + 15) & -16;
2c2fa1
-	  elf_link_hash_traverse (&htab->elf, build_global_entry_stubs, info);
2c2fa1
-	}
2c2fa1
+	elf_link_hash_traverse (&htab->elf, build_global_entry_stubs, info);
2c2fa1
     }
2c2fa1
 
2c2fa1
   if (htab->brlt->size != 0)
2c2fa1
@@ -13624,7 +13620,7 @@ ppc64_elf_relocate_section (bfd *output_
2c2fa1
 		    if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared,
2c2fa1
 							  &h->elf)
2c2fa1
 			|| (info->shared
2c2fa1
-			    && SYMBOL_CALLS_LOCAL (info, &h->elf)))
2c2fa1
+			    && SYMBOL_REFERENCES_LOCAL (info, &h->elf)))
2c2fa1
 		      /* This is actually a static link, or it is a
2c2fa1
 			 -Bsymbolic link and the symbol is defined
2c2fa1
 			 locally, or the symbol was forced to be local
2c2fa1
@@ -14003,7 +13999,7 @@ ppc64_elf_relocate_section (bfd *output_
2c2fa1
 
2c2fa1
 	      if (skip)
2c2fa1
 		memset (&outrel, 0, sizeof outrel);
2c2fa1
-	      else if (!SYMBOL_CALLS_LOCAL (info, &h->elf)
2c2fa1
+	      else if (!SYMBOL_REFERENCES_LOCAL (info, &h->elf)
2c2fa1
 		       && !is_opd
2c2fa1
 		       && r_type != R_PPC64_TOC)
2c2fa1
 		{