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]

Prevent h8300-elf core dump when encountering absolute relocs


Hi Guys,

  I am applying the patch developed to prevent the h8300-elf toolchain
  from crashing when encountering absolute relocs.  See the thread
  started here for more details:

    http://sources.redhat.com/ml/binutils/2003-04/msg00508.html

  I am not applying the patch to the branch, since it is currently
  incomplete.  It stops the seg fault, but it does not relax the
  relocation.

Cheers
        Nick

2003-04-30  Nick Clifton  <nickc@redhat.com>

	* elf32-h8300.c (elf32_h8_relax_section): Do not crash when
	encountering relocs against the *ABS* section.

Index: bfd/elf32-h8300.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-h8300.c,v
retrieving revision 1.22
diff -c -3 -p -w -r1.22 elf32-h8300.c
*** bfd/elf32-h8300.c	24 Apr 2003 12:36:06 -0000	1.22
--- bfd/elf32-h8300.c	25 Apr 2003 11:35:57 -0000
*************** elf32_h8_relax_section (abfd, sec, link_
*** 778,786 ****
  
  	  isym = isymbuf + ELF32_R_SYM (irel->r_info);
  	  sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
! 	  symval = (isym->st_value
! 		    + sym_sec->output_section->vma
! 		    + sym_sec->output_offset);
  	}
        else
  	{
--- 778,789 ----
  
  	  isym = isymbuf + ELF32_R_SYM (irel->r_info);
  	  sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
! 	  symval = isym->st_value;
! 	  /* If the reloc is absolute, it will not have
! 	     a symbol or section associated with it.  */
! 	  if (sym_sec)
! 	    symval += sym_sec->output_section->vma
! 	      + sym_sec->output_offset;
  	}
        else
  	{
*************** elf32_h8_relax_section (abfd, sec, link_
*** 1082,1087 ****
--- 1085,1091 ----
  		    && value >= 0xffff00
  		    && value <= 0xffffff))
  	      {
+ 		bfd_boolean skip = FALSE;
  		unsigned char code;
  
  		/* Note that we've changed the relocs, section contents,
*************** elf32_h8_relax_section (abfd, sec, link_
*** 1099,1114 ****
  
  		code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
  
! 		if ((code & 0xf0) == 0x00)
! 		  bfd_put_8 (abfd,
! 			     (code & 0xf) | 0x20,
  			     contents + irel->r_offset - 2);
! 		else if ((code & 0xf0) == 0x80)
! 		  bfd_put_8 (abfd,
! 			     (code & 0xf) | 0x30,
  			     contents + irel->r_offset - 2);
! 		else
  		  abort ();
  
  		/* Fix the relocation's type.  */
  		irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
--- 1103,1129 ----
  
  		code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
  
! 		switch (code & 0xf0)
! 		  {
! 		  case 0x00:
! 		    bfd_put_8 (abfd, (code & 0xf) | 0x20,
  			       contents + irel->r_offset - 2);
! 		    break;
! 		  case 0x80:
! 		    bfd_put_8 (abfd, (code & 0xf) | 0x30,
  			       contents + irel->r_offset - 2);
! 		    break;
! 		  case 0x20:
! 		  case 0xa0:
! 		    /* Skip 32bit versions.  */
! 		    skip = TRUE;
! 		    break;
! 		  default:
  		    abort ();
+ 		  }
+ 
+ 		if (skip)
+ 		  break;
  
  		/* Fix the relocation's type.  */
  		irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),




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