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]

[patch] elf32-sh.c R_SH_DIR8WPN relocs



The reloc change is needed to fix some assemble/link failures I saw
(specifically, it complained about an unsigned reloc with a negative
fixup); the validation part is a bonus.

2001-03-12  DJ Delorie  <dj@redhat.com>

	* elf32-sh.c (sh_elf_relocate_section): Only relocation
	R_SH_DIR8WP* relocs if they're against external symbols, else
	they're just for relaxing.  Validate the reloc values.

Index: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.27
diff -p -3 -r1.27 elf32-sh.c
*** bfd/elf32-sh.c	2001/03/08 21:04:00	1.27
--- bfd/elf32-sh.c	2001/03/12 19:20:44
*************** sh_elf_relocate_section (output_bfd, inf
*** 3029,3042 ****
  	  break;
  
  	case R_SH_IND12W:
  	case R_SH_DIR8WPN:
  	case R_SH_DIR8WPZ:
  	case R_SH_DIR8WPL:
! 	  /* These should normally be handled by the assembler, but at
! 	     least IND12W is generated by ourselves, so we must deal
! 	     with it.  */
! 	  relocation -= 4;
! 	  goto final_link_relocate;
  
  	default:
  	  bfd_set_error (bfd_error_bad_value);
--- 3029,3069 ----
  	  break;
  
  	case R_SH_IND12W:
+ 	  relocation -= 4;
+ 	  goto final_link_relocate;
+ 
  	case R_SH_DIR8WPN:
  	case R_SH_DIR8WPZ:
  	case R_SH_DIR8WPL:
! 	  /* If the reloc is against the start of this section, then
! 	     the assembler has already taken care of it and the reloc
! 	     is here only to assist in relaxing.  If the reloc is not
! 	     against the start of this section, then it's against an
! 	     external symbol and we must deal with it ourselves.  */
! 	  if (input_section->output_section->vma + input_section->output_offset
! 	      != relocation)
! 	    {
! 	      int disp = (relocation
! 			  - input_section->output_section->vma
! 			  - input_section->output_offset
! 			  - rel->r_offset);
! 	      int mask = 0;
! 	      switch ((int)r_type)
! 		{
! 		case R_SH_DIR8WPN:
! 		case R_SH_DIR8WPZ: mask = 1; break;
! 		case R_SH_DIR8WPL: mask = 3; break;
! 		}
! 	      if (disp & mask)
! 		{
! 		  bfd_set_error (bfd_error_bad_value);
! 		  return false;
! 		}
! 	      relocation -= 4;
! 	      goto final_link_relocate;
! 	    }
! 	  r = bfd_reloc_ok;
! 	  break;
  
  	default:
  	  bfd_set_error (bfd_error_bad_value);


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