public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: tidy bfd/coff-maxq.c
@ 2006-05-09  6:09 Ben Elliston
  0 siblings, 0 replies; only message in thread
From: Ben Elliston @ 2006-05-09  6:09 UTC (permalink / raw)
  To: binutils; +Cc: Inderpreet Singh

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.  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-05-09  2:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-09  6:09 PATCH: tidy bfd/coff-maxq.c Ben Elliston

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).