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

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