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]

[commit] SPU i-icache: Fix "relocation overflow" errors


Hello,

with software icache, the SPU linker will add the set ID into the high
bits of relocation values computed for code symbols, so that they refer
to the IA instead of the LSA.  However, with certain relocation types
this will cause "relocation overflow" messages.

Note that there are various situations where we want to allow even a
LSA reference to code in another section:

- If we had a relocation for an originally cross-section branch, but the
  linker chose to place both input sections into the same cache line, so
  the branch becomes a regular intra-section branch.

- A branch hint for a branch that goes to another cache line
  The *hint* should always point to the target location in local store;
  as soon as the branch (that goes initially to the stub) gets rewritten,
  the hint is then automatically correct.

- Loading the address of text-section embedded data
  When accessing embedded data, e.g. a jump table, the *load* from
  the table must reside in the same cache line as the table.  But the
  instruction that loads the *address* of the table can itself reside in
  another section.

The following patch fixes those issues by providing the set ID only for
those relocations that actually refer to the high bits.  All other
relocations are resolved to just the local store address.  This eliminates
the warning in the above cases.

Tested on spu-elf with no regressions.
Approved off-line by Alan Modra; committed to mainline.

Bye,
Ulrich


ChangeLog:

	* elf32-spu.c (spu_elf_relocate_section): Only encode overlay index
	into addresses for relocation types that look at high bits.  Remove
	special handling of relocation overflow warnings.

diff -urNp src.orig/bfd/elf32-spu.c src/bfd/elf32-spu.c
--- src.orig/bfd/elf32-spu.c	2009-05-13 15:02:27.000000000 +0200
+++ src/bfd/elf32-spu.c	2009-05-13 15:05:20.000000000 +0200
@@ -4697,7 +4697,6 @@ spu_elf_relocate_section (bfd *output_bf
       bfd_reloc_status_type r;
       bfd_boolean unresolved_reloc;
       bfd_boolean warned;
-      bfd_boolean overlay_encoded;
       enum _stub_type stub_type;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
@@ -4782,7 +4781,6 @@ spu_elf_relocate_section (bfd *output_bf
       is_ea_sym = (ea != NULL
 		   && sec != NULL
 		   && sec->output_section == ea);
-      overlay_encoded = FALSE;
 
       /* If this symbol is in an overlay area, we may need to relocate
 	 to the overlay stub.  */
@@ -4820,6 +4818,8 @@ spu_elf_relocate_section (bfd *output_bf
 	{
 	  /* For soft icache, encode the overlay index into addresses.  */
 	  if (htab->params->ovly_flavour == ovly_soft_icache
+	      && (r_type == R_SPU_ADDR16_HI
+		  || r_type == R_SPU_ADDR32 || r_type == R_SPU_REL32)
 	      && !is_ea_sym)
 	    {
 	      unsigned int ovl = overlay_index (sec);
@@ -4827,7 +4827,6 @@ spu_elf_relocate_section (bfd *output_bf
 		{
 		  unsigned int set_id = ((ovl - 1) >> htab->num_lines_log2) + 1;
 		  relocation += set_id << 18;
-		  overlay_encoded = TRUE;
 		}
 	    }
 	}
@@ -4880,11 +4879,6 @@ spu_elf_relocate_section (bfd *output_bf
 	  switch (r)
 	    {
 	    case bfd_reloc_overflow:
-	      /* FIXME: We don't want to warn on most references
-		 within an overlay to itself, but this may silence a
-		 warning that should be reported.  */
-	      if (overlay_encoded && sec == input_section)
-		break;
 	      if (!((*info->callbacks->reloc_overflow)
 		    (info, (h ? &h->root : NULL), sym_name, howto->name,
 		     (bfd_vma) 0, input_bfd, input_section, rel->r_offset)))
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]