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]

powerpc64 @tocbase


This change allows PowerPC64 ELF assembly to specify the TOC base of
a given function, something that is useful now that the linker sets up
multiple TOC sections.  Syntax chosen is

	.quad	symbol@tocbase

The symbol must have a definition in a regular file.  ie. This doesn't
allow you to specify the TOC base of some function in a shared lib.


bfd/ChangeLog
	* elf64-ppc.c (ppc64_elf_relocate_section): Accept a symbol on
	R_PPC64_TOC relocs.

gas/ChangeLog
	* config/tc-ppc.c (ppc_elf_suffix): Don't remove symbols other than
	".TOC." from PPC64_TOC relocs.

Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.108
diff -u -p -r1.108 elf64-ppc.c
--- bfd/elf64-ppc.c	17 Jun 2003 14:22:46 -0000	1.108
+++ bfd/elf64-ppc.c	18 Jun 2003 02:57:31 -0000
@@ -7305,12 +7305,7 @@ ppc64_elf_relocate_section (output_bfd, 
       unresolved_reloc = FALSE;
       warned = FALSE;
 
-      if (r_type == R_PPC64_TOC)
-	{
-	  /* Relocation value is TOC base.  */
-	  relocation = TOCstart + htab->stub_group[input_section->id].toc_off;
-	}
-      else if (r_symndx < symtab_hdr->sh_info)
+      if (r_symndx < symtab_hdr->sh_info)
 	{
 	  /* It's a local symbol.  */
 	  sym = local_syms + r_symndx;
@@ -8080,6 +8075,17 @@ ppc64_elf_relocate_section (output_bfd, 
 	    }
 	  break;
 
+	case R_PPC64_TOC:
+	  /* Relocation value is TOC base.  */
+	  relocation = TOCstart;
+	  if (r_symndx == 0)
+	    relocation += htab->stub_group[input_section->id].toc_off;
+	  else if (sec != NULL && !unresolved_reloc)
+	    relocation += htab->stub_group[sec->id].toc_off;
+	  else
+	    unresolved_reloc = TRUE;
+	  goto dodyn2;
+
 	  /* TOC16 relocs.  We want the offset relative to the TOC base,
 	     which is the address of the start of the TOC plus 0x8000.
 	     The TOC consists of sections .got, .toc, .tocbss, and .plt,
@@ -8186,7 +8192,7 @@ ppc64_elf_relocate_section (output_bfd, 
 	    break;
 	  /* Fall thru.  */
 
-	case R_PPC64_TOC:
+	dodyn2:
 	  if ((input_section->flags & SEC_ALLOC) == 0)
 	    break;
 
@@ -8247,7 +8253,8 @@ ppc64_elf_relocate_section (output_bfd, 
 		memset (&outrel, 0, sizeof outrel);
 	      else if (h != NULL
 		       && !SYMBOL_REFERENCES_LOCAL (info, h)
-		       && !is_opd)
+		       && !is_opd
+		       && r_type != R_PPC64_TOC)
 		outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
 	      else
 		{
Index: gas/config/tc-ppc.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ppc.c,v
retrieving revision 1.73
diff -u -p -r1.73 tc-ppc.c
--- gas/config/tc-ppc.c	17 Jun 2003 00:14:24 -0000	1.73
+++ gas/config/tc-ppc.c	18 Jun 2003 02:57:51 -0000
@@ -1613,11 +1613,11 @@ ppc_elf_suffix (str_p, exp_p)
 	*str_p = str;
 
 	if (reloc == (int) BFD_RELOC_PPC64_TOC
-	    && exp_p->X_op == O_symbol)
+	    && exp_p->X_op == O_symbol
+	    && strcmp (S_GET_NAME (exp_p->X_add_symbol), ".TOC.") == 0)
 	  {
-	    /* This reloc type ignores the symbol.  Change the symbol
-	       so that the dummy .TOC. symbol can be omitted from the
-	       object file.  */
+	    /* Change the symbol so that the dummy .TOC. symbol can be
+	       omitted from the object file.  */
 	    exp_p->X_add_symbol = &abs_symbol;
 	  }
 

-- 
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]