public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* bfd target lists
@ 2002-10-15  4:29 Alan Modra
  2002-10-15  4:32 ` Alan Modra
  2002-11-06 14:16 ` Andrew Cagney
  0 siblings, 2 replies; 4+ messages in thread
From: Alan Modra @ 2002-10-15  4:29 UTC (permalink / raw)
  To: binutils, gdb-patches

If anyone has taken a close look at the list of targets printed by
say, objdump --help, when compiled with --enable-targets=all, you
may have noticed that the default target is mentioned twice.

This patch corrects the situation, but since this may affect gdb
I'd like some comment from the gdb camp before I commit the change.

	* targets.c (bfd_target_list): Don't return the default
	target twice.

Index: bfd/targets.c
===================================================================
RCS file: /cvs/src/src/bfd/targets.c,v
retrieving revision 1.78
diff -u -p -r1.78 targets.c
--- bfd/targets.c	9 Oct 2002 19:03:57 -0000	1.78
+++ bfd/targets.c	15 Oct 2002 07:24:00 -0000
@@ -1279,7 +1279,9 @@ bfd_target_list ()
     return NULL;
 
   for (target = &bfd_target_vector[0]; *target != NULL; target++)
-    *(name_ptr++) = (*target)->name;
+    if (target == &bfd_target_vector[0]
+	|| *target != bfd_target_vector[0])
+      *name_ptr++ = (*target)->name;
 
   return name_list;
 }

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: bfd target lists
  2002-10-15  4:29 bfd target lists Alan Modra
@ 2002-10-15  4:32 ` Alan Modra
  2002-11-06 14:16 ` Andrew Cagney
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Modra @ 2002-10-15  4:32 UTC (permalink / raw)
  To: binutils

On Tue, Oct 15, 2002 at 08:59:51PM +0930, Alan Modra wrote:
> If anyone has taken a close look at the list of targets printed by
> say, objdump --help, when compiled with --enable-targets=all, you
> may have noticed that the default target is mentioned twice.

And this is the bit that will make the previous patch work for
objdump and other binutils.

	* bucomm.c (list_supported_targets): Use bfd_target_list.

Committing mainline.

Index: binutils/bucomm.c
===================================================================
RCS file: /cvs/src/src/binutils/bucomm.c,v
retrieving revision 1.15
diff -u -p -r1.15 bucomm.c
--- binutils/bucomm.c	8 Jun 2002 07:38:30 -0000	1.15
+++ binutils/bucomm.c	15 Oct 2002 07:43:12 -0000
@@ -128,16 +128,18 @@ list_supported_targets (name, f)
      const char *name;
      FILE *f;
 {
-  extern const bfd_target *const *bfd_target_vector;
   int t;
+  const char **targ_names = bfd_target_list ();
 
   if (name == NULL)
     fprintf (f, _("Supported targets:"));
   else
     fprintf (f, _("%s: supported targets:"), name);
-  for (t = 0; bfd_target_vector[t] != NULL; t++)
-    fprintf (f, " %s", bfd_target_vector[t]->name);
+
+  for (t = 0; targ_names[t] != NULL; t++)
+    fprintf (f, " %s", targ_names[t]);
   fprintf (f, "\n");
+  free (targ_names);
 }
 
 /* List the supported architectures.  */

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: bfd target lists
  2002-10-15  4:29 bfd target lists Alan Modra
  2002-10-15  4:32 ` Alan Modra
@ 2002-11-06 14:16 ` Andrew Cagney
  2002-11-06 14:48   ` Alan Modra
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2002-11-06 14:16 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils, gdb-patches

> If anyone has taken a close look at the list of targets printed by
> say, objdump --help, when compiled with --enable-targets=all, you
> may have noticed that the default target is mentioned twice.
> 
> This patch corrects the situation, but since this may affect gdb
> I'd like some comment from the gdb camp before I commit the change.
> 
> 	* targets.c (bfd_target_list): Don't return the default
> 	target twice.
> 
> Index: bfd/targets.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/targets.c,v
> retrieving revision 1.78
> diff -u -p -r1.78 targets.c
> --- bfd/targets.c	9 Oct 2002 19:03:57 -0000	1.78
> +++ bfd/targets.c	15 Oct 2002 07:24:00 -0000
> @@ -1279,7 +1279,9 @@ bfd_target_list ()
>      return NULL;
>  
>    for (target = &bfd_target_vector[0]; *target != NULL; target++)
> -    *(name_ptr++) = (*target)->name;
> +    if (target == &bfd_target_vector[0]
> +	|| *target != bfd_target_vector[0])
> +      *name_ptr++ = (*target)->name;
>  
>    return name_list;
>  }

Turned out to be harmless, thanks for remembering us :-)

BTW, how does:
	*name_ptr++ = &bfd_target_vector[0]->name;
	for (target = &bfd_target_vector[1]; *target != NULL; target++)
	  if (*target != bfd_target_vector[0])
	    *name_ptr++ = (*target)->name;
look.

Andrew


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: bfd target lists
  2002-11-06 14:16 ` Andrew Cagney
@ 2002-11-06 14:48   ` Alan Modra
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2002-11-06 14:48 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: binutils, gdb-patches

On Wed, Nov 06, 2002 at 05:16:20PM -0500, Andrew Cagney wrote:
> BTW, how does:
> 	*name_ptr++ = &bfd_target_vector[0]->name;
> 	for (target = &bfd_target_vector[1]; *target != NULL; target++)
> 	  if (*target != bfd_target_vector[0])
> 	    *name_ptr++ = (*target)->name;
> look.

I wouldn't complain.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-11-06 22:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-15  4:29 bfd target lists Alan Modra
2002-10-15  4:32 ` Alan Modra
2002-11-06 14:16 ` Andrew Cagney
2002-11-06 14:48   ` Alan Modra

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).