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]

Re: H8S Bug when using -relax for h8300-elf


Hi Shrinivas,

> When I build following program with -relax option of the linker, the
> linker crashes.
> 
> --------------------- The program ----------------------
> 	.h8300s
> 	.global _start
> _start:
> 	mov.b	r2l,@0xFFFFBD
> 	rts
> 
> ---------------------------------------------------------
> 
> Command line
> 
> $ /home/kpit/usr/h8300-elf20030324/bin/h8300-elf-as test.s -o test.o
> $ /home/kpit/usr/h8300-elf20030324/bin/h8300-elf-ld -relax -mh8300self test.o
> Segmentation fault (core dumped)

Thanks for reporting this bug.

Please could you try out the patch below and let me know if it works
for you ?

Cheers
        Nick

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]