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]

Your patch to elf32-cris.c on 2001-10-21


AFAIK, this patch (these patches, two revisions):

2001-10-21  H.J. Lu <hjl@gnu.org>

	* elf32-cris.c (cris_reloc_type_lookup): Use int for index.

Index: elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.13
retrieving revision 1.15
diff -c -p -r1.13 -r1.15
*** elf32-cris.c	2001/09/29 06:21:59	1.13
--- elf32-cris.c	2001/10/21 07:23:24	1.15
*************** cris_reloc_type_lookup (abfd, code)
*** 437,446 ****
       bfd * abfd ATTRIBUTE_UNUSED;
       bfd_reloc_code_real_type code;
  {
!   unsigned int i;
  
    for (i = sizeof (cris_reloc_map) / sizeof (cris_reloc_map[0]);
!        --i;)
      if (cris_reloc_map [i].bfd_reloc_val == code)
        return & cris_elf_howto_table [cris_reloc_map[i].cris_reloc_val];
  
--- 437,446 ----
       bfd * abfd ATTRIBUTE_UNUSED;
       bfd_reloc_code_real_type code;
  {
!   int i;
  
    for (i = sizeof (cris_reloc_map) / sizeof (cris_reloc_map[0]);
!        --i >= 0;)
      if (cris_reloc_map [i].bfd_reloc_val == code)
        return & cris_elf_howto_table [cris_reloc_map[i].cris_reloc_val];
  

was/were neither reviewed nor approved.  Also, the ChangeLog
entry isn't complete; you didn't just change the type of i.  I
tweaked your ChangeLog entry accordingly, adding "Cover index 0".

Did you consider the fix obvious and just forgot to send a
report with your analysis?  Do you have a test-case where the
bug actually causes problems?  I'd appreciate that, because it
seems there must either be invalid input or more than one bug
for this case to happen.  R_ELF_NONE (while valid) should not
appear in any input or output.  I'm guessing this happens
because of some effect of combreloc, but I shouldn't need to
*guess* what that bug might be.  By now you should know better
that checking in changes without approval.  Considering your
track record, one would expect you'd be quite a bit more
cautious about what you consider obvious.

Anyway, I prefer another solution, keeping the variable i
unsigned.  Things look clearer when making the for-loop have the
canonical form, as follows (committed).  FWIW, the same
construct (before your changes) exists in elf32-fr30.c (from
where I originally got most of this code) and elf32-openrisc.c.

	* elf32-cris.c (cris_reloc_type_lookup): Change loop to use
	unsigned, increasing index.

Index: elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.15
diff -p -c -r1.15 elf32-cris.c
*** elf32-cris.c	2001/10/21 07:23:24	1.15
--- elf32-cris.c	2001/10/24 03:24:57
*************** cris_reloc_type_lookup (abfd, code)
*** 437,446 ****
       bfd * abfd ATTRIBUTE_UNUSED;
       bfd_reloc_code_real_type code;
  {
!   int i;
  
!   for (i = sizeof (cris_reloc_map) / sizeof (cris_reloc_map[0]);
!        --i >= 0;)
      if (cris_reloc_map [i].bfd_reloc_val == code)
        return & cris_elf_howto_table [cris_reloc_map[i].cris_reloc_val];
  
--- 437,445 ----
       bfd * abfd ATTRIBUTE_UNUSED;
       bfd_reloc_code_real_type code;
  {
!   unsigned int i;
  
!   for (i = 0; i < sizeof (cris_reloc_map) / sizeof (cris_reloc_map[0]); i++)
      if (cris_reloc_map [i].bfd_reloc_val == code)
        return & cris_elf_howto_table [cris_reloc_map[i].cris_reloc_val];
  

brgds, H-P


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