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: fix some bugs in bfd/coff-maxq.c


Hi Inderpreet,

I ran a static analysis over bfd some time ago and found the following
problems with the MAXQ port.  Now, my changes may not be correct -- I
am just cleaning up.  It may be that I have found unintended bugs, in
which case you may throw some of the changes away and fix the problems
for real. ;-)

The first two hunks are simple: `hotwo' is unused.

The next two hunks remove some types and variables that are unused
because the loop over maxq_reloc_map does nothing!  In its only
iteration, there is a switch on `code' (an incoming argument) that
returns in all cases.  This seems wrong.  My patch just removes it
all.  :-)

I've include a patch generated by `diff -w' so that you can see the
changes more clearly.

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 24 Oct 2006 06:46:50 -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]