2003-04-30 H.J. Lu <hjl@gnu.org>
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 1 May 2003 00:40:41 +0000 (00:40 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 1 May 2003 00:40:41 +0000 (00:40 +0000)
* objdump.c (only): Change it to char **.
(only_size): New.
(only_used): New.
(disassemble_data): Check only as an array.
(dump_data): Likewise.
(dump_relocs): Likewise.
(main): Treat only as an array.

binutils/ChangeLog
binutils/objdump.c

index 5df0dc8d36cc26a939057e8154af83bb82c6822f..807421d7eaa4ffbe295772e5a2dbe79edc2233f9 100644 (file)
@@ -1,3 +1,13 @@
+2003-04-30  H.J. Lu <hjl@gnu.org>
+
+       * objdump.c (only): Change it to char **.
+       (only_size): New.
+       (only_used): New.
+       (disassemble_data): Check only as an array.
+       (dump_data): Likewise.
+       (dump_relocs): Likewise.
+       (main): Treat only as an array.
+
 2003-04-24  Dimitrie O. Paun <dpaun@rogers.com>
 
         * doc/binutils.texi: Fix the documentation for the -fo option.
index 3c927bd7ae952a054d64ca8c5aaeedf362baf7fc..f17286c9b45bf355fb2db0ee4a004b2f5cc2f0ee 100644 (file)
@@ -67,7 +67,9 @@ static bfd_boolean disassemble;               /* -d */
 static bfd_boolean disassemble_all;    /* -D */
 static int disassemble_zeroes;         /* --disassemble-zeroes */
 static bfd_boolean formats_info;       /* -i */
-static char *only;                     /* -j secname */
+static char **only;                    /* -j secname */
+static size_t only_size = 0;
+static size_t only_used = 0;
 static int wide_output;                        /* -w */
 static bfd_vma start_address = (bfd_vma) -1; /* --start-address */
 static bfd_vma stop_address = (bfd_vma) -1;  /* --stop-address */
@@ -1628,8 +1630,18 @@ disassemble_data (abfd)
              && only == NULL
              && (section->flags & SEC_CODE) == 0))
        continue;
-      if (only != (char *) NULL && strcmp (only, section->name) != 0)
-       continue;
+
+      if (only != NULL)
+       {
+         size_t i;
+
+         for (i = 0; i < only_used; i++)
+           if (strcmp (only [i], section->name) == 0)
+             break;
+
+         if (i == only_used)
+           continue;
+       }
 
       if ((section->flags & SEC_RELOC) != 0
 #ifndef DISASSEMBLER_NEEDS_RELOCS
@@ -2221,9 +2233,13 @@ dump_data (abfd)
        section->next)
     {
       int onaline = 16;
+      size_t i;
 
-      if (only == (char *) NULL ||
-         strcmp (only, section->name) == 0)
+      for (i = 0; i < only_used; i++)
+       if (strcmp (only [i], section->name) == 0)
+         break;
+
+      if (only_used == 0 || i != only_used)
        {
          if (section->flags & SEC_HAS_CONTENTS)
            {
@@ -2286,7 +2302,7 @@ dump_data (abfd)
 
                  bfd_sprintf_vma (abfd, buf, (addr_offset + section->vma));
                  count = strlen (buf);
-                 if (count >= sizeof (buf))
+                 if ((size_t) count >= sizeof (buf))
                    abort ();
                  putchar (' ');
                  while (count < width)
@@ -2411,7 +2427,13 @@ dump_relocs (abfd)
 
       if (only)
        {
-         if (strcmp (only, a->name))
+         size_t i;
+
+         for (i = 0; i < only_used; i++)
+           if (strcmp (only [i], a->name) == 0)
+             break;
+
+         if (i == only_used)
            continue;
        }
       else if ((a->flags & SEC_RELOC) == 0)
@@ -2641,7 +2663,18 @@ main (argc, argv)
          disassembler_options = optarg;
          break;
        case 'j':
-         only = optarg;
+         if (only == NULL)
+           {
+             only_size = 8;
+             only = (char **) xmalloc (only_size * sizeof (char *));
+           }
+         else if (only_used == only_size)
+           {
+             only_size += 8;
+             only = (char **) xrealloc (only,
+                                        only_size * sizeof (char *));
+           }
+         only [only_used++] = optarg;
          break;
        case 'l':
          with_line_numbers = TRUE;