This is the mail archive of the binutils@sourceware.org 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]

PATCH: tidy bfd/coff-maxq.c


Hi Inderpreet,

This untested patch tidies up a few things in bfd/coff-maxq.c.

First, there is an unused local variable in coff_maxq20_reloc, which
is simple enough.

Second, the loop in maxq_reloc_type_lookup appears to be buggy.  The
maximum loop count is correctly computed by ARRAY_SIZE (...), but the
current array element is never referenced in the loop body.  All the
loop will do is switch on `code' on the first loop iteration and
return.  My patch eliminates the loop (and all associated variables
and types), but this is almost certainly wrong.

diff -w output follows.  Please use the patch as you see fit.

Cheers, Ben


Index: coff-maxq.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-maxq.c,v
retrieving revision 1.3
diff -u -p -w -r1.3 coff-maxq.c
--- coff-maxq.c 4 May 2005 15:53:02 -0000       1.3
+++ coff-maxq.c 9 May 2006 02:00:28 -0000
@@ -82,7 +82,6 @@ coff_maxq20_reloc (bfd *      abfd,
                   bfd *      output_bfd    ATTRIBUTE_UNUSED,
                   char **    error_message ATTRIBUTE_UNUSED)
 {
-  reloc_howto_type *howto = NULL;
   unsigned char *addr = NULL;
   unsigned long x = 0;
   long call_addr = 0;
@@ -96,7 +95,6 @@ coff_maxq20_reloc (bfd *      abfd,
 
   if (data && reloc_entry)
     {
-      howto = reloc_entry->howto;
       addr = (unsigned char *) data + reloc_entry->address;
       call_addr = call_addr - call_addr;
       call_addr = get_symbol_value (symbol_in);
@@ -374,34 +372,10 @@ static reloc_howto_type howto_table[] =
   EMPTY_HOWTO (10),
 };
 
-/* Map BFD reloc types to MAXQ COFF reloc types.  */
-
-typedef struct maxq_reloc_map
-{
-  bfd_reloc_code_real_type  bfd_reloc_val;
-  unsigned int              maxq_reloc_val;
-  reloc_howto_type *        table;
-}
-reloc_map;
-
-static const reloc_map maxq_reloc_map[] =
-{
-  {BFD_RELOC_16_PCREL_S2, SHORT_JUMP, howto_table},
-  {BFD_RELOC_16,          LONG_JUMP,  howto_table},
-};
-
 static reloc_howto_type *
 maxq_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
                        bfd_reloc_code_real_type code)
 {
-  unsigned int i;
-
-  for (i = 0; i < ARRAY_SIZE (maxq_reloc_map); i++)
-    {
-      const reloc_map *entry;
-
-      entry = maxq_reloc_map + i;
-
       switch (code)
        {
          /* SHORT JUMP */
@@ -433,9 +407,6 @@ maxq_reloc_type_lookup (bfd * abfd ATTRI
        }
     }
 
-  return NULL;
-}
-
 #define coff_bfd_reloc_type_lookup maxq_reloc_type_lookup
 
 /* Perform any necessary magic to the addend in a reloc entry.  */


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