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

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