This is the mail archive of the binutils@sourceware.org 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]

_SPUEAR_ table generated by embedspu incorrect


Fixes a problem with _SPUEAR_ symbols in overlays.  Since these
symbols are supposed to allow the PPU to invoke an SPU function,
we need to adjust them to point at the overlay stub so that the
overlay is loaded if necessary.

bfd/
	* elf32-spu.c (spu_elf_output_symbol_hook): New function.
	(elf_backend_link_output_symbol_hook): Define.
ld/testsuite/
	* ld-spu/ovl2.d: Update.

Index: bfd/elf32-spu.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-spu.c,v
retrieving revision 1.9
diff -u -p -r1.9 elf32-spu.c
--- bfd/elf32-spu.c	26 Mar 2007 12:50:09 -0000	1.9
+++ bfd/elf32-spu.c	5 Apr 2007 06:38:32 -0000
@@ -1590,6 +1590,47 @@ spu_elf_relocate_section (bfd *output_bf
   return ret;
 }
 
+/* Adjust _SPUEAR_ syms to point at their overlay stubs.  */
+
+static bfd_boolean
+spu_elf_output_symbol_hook (struct bfd_link_info *info,
+			    const char *sym_name ATTRIBUTE_UNUSED,
+			    Elf_Internal_Sym *sym,
+			    asection *sym_sec ATTRIBUTE_UNUSED,
+			    struct elf_link_hash_entry *h)
+{
+  struct spu_link_hash_table *htab = spu_hash_table (info);
+
+  if (!info->relocatable
+      && htab->num_overlays != 0
+      && h != NULL
+      && (h->root.type == bfd_link_hash_defined
+	  || h->root.type == bfd_link_hash_defweak)
+      && h->def_regular
+      && strncmp (h->root.root.string, "_SPUEAR_", 8) == 0)
+    {
+      static Elf_Internal_Rela zero_rel;
+      char *stub_name = spu_stub_name (h->root.u.def.section, h, &zero_rel);
+      struct spu_stub_hash_entry *sh;
+
+      if (stub_name == NULL)
+	return FALSE;
+      sh = (struct spu_stub_hash_entry *)
+	bfd_hash_lookup (&htab->stub_hash_table, stub_name, FALSE, FALSE);
+      free (stub_name);
+      if (sh == NULL)
+	return TRUE;
+      sym->st_shndx
+	= _bfd_elf_section_from_bfd_section (htab->stub->output_section->owner,
+					     htab->stub->output_section);
+      sym->st_value = (htab->stub->output_section->vma
+		       + htab->stub->output_offset
+		       + sh->off);
+    }
+
+  return TRUE;
+}
+
 static int spu_plugin = 0;
 
 void
@@ -1830,6 +1871,7 @@ spu_elf_section_processing (bfd *abfd AT
 #define elf_backend_gc_mark_hook		spu_elf_gc_mark_hook
 #define elf_backend_relocate_section		spu_elf_relocate_section
 #define elf_backend_symbol_processing		spu_elf_backend_symbol_processing
+#define elf_backend_link_output_symbol_hook	spu_elf_output_symbol_hook
 #define bfd_elf32_new_section_hook		spu_elf_new_section_hook
 #define bfd_elf32_bfd_link_hash_table_create	spu_elf_link_hash_table_create
 #define bfd_elf32_bfd_link_hash_table_free	spu_elf_link_hash_table_free
Index: ld/testsuite/ld-spu/ovl2.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-spu/ovl2.d,v
retrieving revision 1.1
diff -u -p -r1.1 ovl2.d
--- ld/testsuite/ld-spu/ovl2.d	27 Mar 2007 08:36:27 -0000	1.1
+++ ld/testsuite/ld-spu/ovl2.d	5 Apr 2007 06:38:33 -0000
@@ -33,7 +33,7 @@ Disassembly of section \.text:
  138:	42 00 00 ce 	ila	\$78,1
  13c:	32 00 08 80 	br	180 <__ovly_load>	# 180
 
-00000140 <00000000\.ovl_call\._SPUEAR_f1_a2>:
+00000140 <_SPUEAR_f1_a2>:
  140:	42 02 00 4f 	ila	\$79,1024	# 400
  144:	40 20 00 00 	nop	\$0
  148:	42 00 01 4e 	ila	\$78,2
@@ -46,7 +46,7 @@ Disassembly of section \.ov_a1:
 	\.\.\.
 Disassembly of section \.ov_a2:
 
-00000400 <_SPUEAR_f1_a2>:
+00000400 <f1_a2>:
  400:	32 7f a2 00 	br	110 <longjmp>	# 110
 			400: SPU_REL16	longjmp
 	\.\.\.

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