This is the mail archive of the binutils@sourceware.cygnus.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 for elf32-mips.c



These patches (checked in) should fix another couple of thinkos
discovered by Ralf's mips-linux-gnu testing.  Ralf, just out of
curiousity, do you think that Linux/GNU will move to the N32/64-bit
ABIs at some point?  Or do you plan on sticking with the IRIX5-like
ABI for the forseeable future?

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

1999-08-02  Mark Mitchell  <mark@codesourcery.com>

	* elf32-mips.c (_bfd_mips_elf_relocate_section): Handle R_MIPS_26
	and R_MIPS16_26 relocations correctly when relocating.
	(_bfd_mips_elf_check_relocs): Don't assume that R_MIPS_CALL_HI16
	and R_MIPS_CALL_LO16 are for global symbols.
	
Index: elf32-mips.c
===================================================================
RCS file: /cvs/binutils/binutils/bfd/elf32-mips.c,v
retrieving revision 1.39
diff -c -p -r1.39 elf32-mips.c
*** elf32-mips.c	1999/08/01 22:45:06	1.39
--- elf32-mips.c	1999/08/03 06:00:31
*************** _bfd_mips_elf_relocate_section (output_b
*** 6552,6557 ****
--- 6552,6562 ----
  			    | ((addend & 0x7e00000) >> 16)
  			    | (addend & 0x1f));
  		}
+ 	      else if (r_type == R_MIPS16_26 
+ 		       || r_type == R_MIPS16_26)
+ 		/* The addend is stored without its two least
+ 		   significant bits (which are always zero.)  */
+ 		addend <<= 2;
  	    }
  	  else
  	    addend = rel->r_addend;
*************** _bfd_mips_elf_relocate_section (output_b
*** 6590,6595 ****
--- 6595,6605 ----
  	     The subsequent R_MIPS_LO16 will handle the low-order bits.  */
  	  if (r_type == R_MIPS_HI16 || r_type == R_MIPS_GOT16)
  	    addend >>= 16;
+ 	  /* If the relocation is for an R_MIPS_26 relocation, then
+ 	     the two low-order bits are not stored in the object file;
+ 	     they are implicitly zero.  */
+ 	  else if (r_type == R_MIPS_26 || r_type == R_MIPS16_26)
+ 	    addend >>= 2;
  
  	  if (rela_relocation_p)
  	    /* If this is a RELA relocation, just update the addend.
*************** _bfd_mips_elf_check_relocs (abfd, info, 
*** 7373,7388 ****
  
  	case R_MIPS_CALL_HI16:
  	case R_MIPS_CALL_LO16:
! 	  /* This symbol requires a global offset table entry.  */
! 	  if (!mips_elf_record_global_got_symbol (h, info, g))
! 	    return false;
! 
! 	  /* We need a stub, not a plt entry for the undefined
! 	     function.  But we record it as if it needs plt.  See
! 	     elf_adjust_dynamic_symbol in elflink.h.  */
! 	  h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
! 	  h->type = STT_FUNC;
  
  	  break;
  
  	case R_MIPS_GOT16:
--- 7383,7400 ----
  
  	case R_MIPS_CALL_HI16:
  	case R_MIPS_CALL_LO16:
! 	  if (h != NULL)
! 	    {
! 	      /* This symbol requires a global offset table entry.  */
! 	      if (!mips_elf_record_global_got_symbol (h, info, g))
! 		return false;
  
+ 	      /* We need a stub, not a plt entry for the undefined
+ 		 function.  But we record it as if it needs plt.  See
+ 		 elf_adjust_dynamic_symbol in elflink.h.  */
+ 	      h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+ 	      h->type = STT_FUNC;
+ 	    }
  	  break;
  
  	case R_MIPS_GOT16:

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