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]

Re: Warning in elf32-sh.c


Hi Ben,

: This patch eliminates a warning in elf32-sh.c.  I'm not sure if it's the
: right fix or not -- this code always suffered from a potential infinite
: loop.
: 
: Ben
: 
: 
: @@ -789,7 +1100,7 @@
:      {
:        bfd_vma start0 = start - 4;
: 
: -      while (start0 >= 0 && IS_PPI (contents + start0))
: +      while (IS_PPI (contents + start0))
:         start0 -= 2;
:        start0 = start - 2 - ((start - start0) & 2);
:        start = start0 - cum_diff - 2;


I think a better patch would be this:


Index: elf32-sh.c
===================================================================
RCS file: /cvs/src//src/bfd/elf32-sh.c,v
retrieving revision 1.22
diff -p -r1.22 elf32-sh.c
*** elf32-sh.c	2000/11/11 06:43:42	1.22
--- elf32-sh.c	2000/11/21 19:44:08
*************** sh_elf_reloc_loop (r_type, input_bfd, in
*** 789,795 ****
      {
        bfd_vma start0 = start - 4;
  
!       while (start0 >= 0 && IS_PPI (contents + start0))
  	  start0 -= 2;
        start0 = start - 2 - ((start - start0) & 2);
        start = start0 - cum_diff - 2;
--- 789,795 ----
      {
        bfd_vma start0 = start - 4;
  
!       while (start0 && IS_PPI (contents + start0))
  	  start0 -= 2;
        start0 = start - 2 - ((start - start0) & 2);
        start = start0 - cum_diff - 2;


Which removes the possibilty of an infinite loop, and more closely
matches the intentions of the original programmer.  I will check this
version into the sources.

Cheers
	Nick

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