From: Nick Clifton Date: Mon, 24 Mar 2003 11:28:35 +0000 (+0000) Subject: Move display_info() function into bucomm.c X-Git-Tag: binutils-2_14-branchpoint~406 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=06d86cf78eeb35897934df3c12e1024f305b2540;p=external%2Fbinutils.git Move display_info() function into bucomm.c --- diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 7fce876..e1c79ed 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,20 @@ +2003-03-24 Elias Athanasopoulos + + * objdump.c (endian_string): Move to bucomm.c. + (display_info): Likewise. + (display_target_list): Likewise. + (display_info_table): Likewise. + (display_target_tables): Likewise. + (main): Assign the return value of display_info to exit_status. + * bucomm.c: Include bfdver.h and libbfd.h + (display_target_list): Call bfd_nonfatal instead of nonfatal and + return 0 on a non-fatal error, 1 on success. + (display_info_table): Likewise. + * bucomm.h (display_info): Provide a prototype. + * Makefile.am (bucomm.o): Add dependencies on bfdver.h and + libbfd.h. + * Makefile.in: Regenerate. + 2003-03-22 Danny Smith * dlltool.c (gen_def_file): Put demangled name comments on diff --git a/binutils/Makefile.am b/binutils/Makefile.am index 2c1b515..1d52738 100644 --- a/binutils/Makefile.am +++ b/binutils/Makefile.am @@ -381,7 +381,8 @@ binemul.o: binemul.c binemul.h ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/fopen-same.h bucomm.o: bucomm.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h $(INCDIR)/libiberty.h bucomm.h config.h \ - $(INCDIR)/bin-bugs.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h + $(INCDIR)/bin-bugs.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h \ + ../bfd/bfdver.h $(BFDDIR)/libbfd.h budemang.o: budemang.c config.h ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h $(INCDIR)/libiberty.h $(INCDIR)/demangle.h \ budemang.h diff --git a/binutils/Makefile.in b/binutils/Makefile.in index 286d842..d0cd26e 100644 --- a/binutils/Makefile.in +++ b/binutils/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am +# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am # Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -442,7 +442,7 @@ configure.in deflex.c defparse.c nlmheader.c rclex.c rcparse.c DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best SOURCES = $(nlmconv_SOURCES) $(srconv_SOURCES) $(sysdump_SOURCES) $(coffdump_SOURCES) $(dlltool_SOURCES) $(windres_SOURCES) $(dllwrap_SOURCES) $(size_SOURCES) $(objdump_SOURCES) $(ar_SOURCES) $(strings_SOURCES) $(ranlib_SOURCES) $(objcopy_SOURCES) $(addr2line_SOURCES) $(readelf_SOURCES) $(nm_new_SOURCES) $(strip_new_SOURCES) $(cxxfilt_SOURCES) OBJECTS = $(nlmconv_OBJECTS) $(srconv_OBJECTS) $(sysdump_OBJECTS) $(coffdump_OBJECTS) $(dlltool_OBJECTS) $(windres_OBJECTS) $(dllwrap_OBJECTS) $(size_OBJECTS) $(objdump_OBJECTS) $(ar_OBJECTS) $(strings_OBJECTS) $(ranlib_OBJECTS) $(objcopy_OBJECTS) $(addr2line_OBJECTS) $(readelf_OBJECTS) $(nm_new_OBJECTS) $(strip_new_OBJECTS) $(cxxfilt_OBJECTS) @@ -870,7 +870,7 @@ distclean-generic: -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: - -test -z "arlex.cdeflex.crclex.carparse.harparse.cdefparse.hdefparse.cnlmheader.hnlmheader.crcparse.hrcparse.c" || rm -f arlex.c deflex.c rclex.c arparse.h arparse.c defparse.h defparse.c nlmheader.h nlmheader.c rcparse.h rcparse.c + -test -z "arlexldeflexlrclexlarparseharparsecdefparsehdefparsecnlmheaderhnlmheadercrcparsehrcparsec" || rm -f arlexl deflexl rclexl arparseh arparsec defparseh defparsec nlmheaderh nlmheaderc rcparseh rcparsec mostlyclean-am: mostlyclean-hdr mostlyclean-binPROGRAMS \ mostlyclean-noinstPROGRAMS mostlyclean-compile \ mostlyclean-libtool mostlyclean-tags \ @@ -1109,7 +1109,8 @@ binemul.o: binemul.c binemul.h ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/fopen-same.h bucomm.o: bucomm.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h $(INCDIR)/libiberty.h bucomm.h config.h \ - $(INCDIR)/bin-bugs.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h + $(INCDIR)/bin-bugs.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h \ + ../bfd/bfdver.h $(BFDDIR)/libbfd.h budemang.o: budemang.c config.h ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h $(INCDIR)/libiberty.h $(INCDIR)/demangle.h \ budemang.h diff --git a/binutils/bucomm.c b/binutils/bucomm.c index 9609aee..237f934 100644 --- a/binutils/bucomm.c +++ b/binutils/bucomm.c @@ -1,5 +1,5 @@ /* bucomm.c -- Bin Utils COMmon code. - Copyright 1991, 1992, 1993, 1994, 1995, 1997, 1998, 2000, 2001, 2002 + Copyright 1991, 1992, 1993, 1994, 1995, 1997, 1998, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -23,9 +23,11 @@ loaded, but for now it's not necessary. */ #include "bfd.h" +#include "bfdver.h" #include "libiberty.h" #include "bucomm.h" #include "filenames.h" +#include "libbfd.h" #include #include /* ctime, maybe time_t */ @@ -35,8 +37,13 @@ typedef long time_t; #endif #endif + +static const char * endian_string PARAMS ((enum bfd_endian)); +static int display_target_list PARAMS ((void)); +static int display_info_table PARAMS ((int, int)); +static int display_target_tables PARAMS ((void)); -/* Error reporting */ +/* Error reporting. */ char *program_name; @@ -161,6 +168,202 @@ list_supported_architectures (name, f) fprintf (f, "\n"); } +/* The length of the longest architecture name + 1. */ +#define LONGEST_ARCH sizeof ("powerpc:common") + +static const char * +endian_string (endian) + enum bfd_endian endian; +{ + switch (endian) + { + case BFD_ENDIAN_BIG: return "big endian"; + case BFD_ENDIAN_LITTLE: return "little endian"; + default: return "endianness unknown"; + } +} + +/* List the targets that BFD is configured to support, each followed + by its endianness and the architectures it supports. */ + +static int +display_target_list () +{ + char *dummy_name; + int t; + int ret = 1; + + dummy_name = make_temp_file (NULL); + for (t = 0; bfd_target_vector[t]; t++) + { + const bfd_target *p = bfd_target_vector[t]; + bfd *abfd = bfd_openw (dummy_name, p->name); + int a; + + printf ("%s\n (header %s, data %s)\n", p->name, + endian_string (p->header_byteorder), + endian_string (p->byteorder)); + + if (abfd == NULL) + { + bfd_nonfatal (dummy_name); + ret = 0; + continue; + } + + if (! bfd_set_format (abfd, bfd_object)) + { + if (bfd_get_error () != bfd_error_invalid_operation) + { + bfd_nonfatal (p->name); + ret = 0; + } + bfd_close_all_done (abfd); + continue; + } + + for (a = (int) bfd_arch_obscure + 1; a < (int) bfd_arch_last; a++) + if (bfd_set_arch_mach (abfd, (enum bfd_architecture) a, 0)) + printf (" %s\n", + bfd_printable_arch_mach ((enum bfd_architecture) a, 0)); + bfd_close_all_done (abfd); + } + unlink (dummy_name); + free (dummy_name); + + return ret; +} + +/* Print a table showing which architectures are supported for entries + FIRST through LAST-1 of bfd_target_vector (targets across, + architectures down). */ + +static int +display_info_table (first, last) + int first; + int last; +{ + int t; + int a; + int ret = 1; + char *dummy_name; + + /* Print heading of target names. */ + printf ("\n%*s", (int) LONGEST_ARCH, " "); + for (t = first; t < last && bfd_target_vector[t]; t++) + printf ("%s ", bfd_target_vector[t]->name); + putchar ('\n'); + + dummy_name = make_temp_file (NULL); + for (a = (int) bfd_arch_obscure + 1; a < (int) bfd_arch_last; a++) + if (strcmp (bfd_printable_arch_mach (a, 0), "UNKNOWN!") != 0) + { + printf ("%*s ", (int) LONGEST_ARCH - 1, + bfd_printable_arch_mach (a, 0)); + for (t = first; t < last && bfd_target_vector[t]; t++) + { + const bfd_target *p = bfd_target_vector[t]; + bfd_boolean ok = TRUE; + bfd *abfd = bfd_openw (dummy_name, p->name); + + if (abfd == NULL) + { + bfd_nonfatal (p->name); + ret = 0; + ok = FALSE; + } + + if (ok) + { + if (! bfd_set_format (abfd, bfd_object)) + { + if (bfd_get_error () != bfd_error_invalid_operation) + { + bfd_nonfatal (p->name); + ret = 0; + } + ok = FALSE; + } + } + + if (ok) + { + if (! bfd_set_arch_mach (abfd, a, 0)) + ok = FALSE; + } + + if (ok) + printf ("%s ", p->name); + else + { + int l = strlen (p->name); + while (l--) + putchar ('-'); + putchar (' '); + } + if (abfd != NULL) + bfd_close_all_done (abfd); + } + putchar ('\n'); + } + unlink (dummy_name); + free (dummy_name); + + return ret; +} + +/* Print tables of all the target-architecture combinations that + BFD has been configured to support. */ + +static int +display_target_tables () +{ + int t; + int columns; + int ret = 1; + char *colum; + + columns = 0; + colum = getenv ("COLUMNS"); + if (colum != NULL) + columns = atoi (colum); + if (columns == 0) + columns = 80; + + t = 0; + while (bfd_target_vector[t] != NULL) + { + int oldt = t, wid; + + wid = LONGEST_ARCH + strlen (bfd_target_vector[t]->name) + 1; + ++t; + while (wid < columns && bfd_target_vector[t] != NULL) + { + int newwid; + + newwid = wid + strlen (bfd_target_vector[t]->name) + 1; + if (newwid >= columns) + break; + wid = newwid; + ++t; + } + if (! display_info_table (oldt, t)) + ret = 0; + } + + return ret; +} + +int +display_info () +{ + printf (_("BFD header file version %s\n"), BFD_VERSION_STRING); + if (! display_target_list () || ! display_target_tables ()) + return 1; + else + return 0; +} + /* Display the archive header for an element as if it were an ls -l listing: Mode User\tGroup\tSize\tDate Name */ diff --git a/binutils/bucomm.h b/binutils/bucomm.h index 7a11ea8..2598d13 100644 --- a/binutils/bucomm.h +++ b/binutils/bucomm.h @@ -1,22 +1,22 @@ /* bucomm.h -- binutils common include file. Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2002 Free Software Foundation, Inc. + 2002, 2003 Free Software Foundation, Inc. -This file is part of GNU Binutils. + This file is part of GNU Binutils. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _BUCOMM_H #define _BUCOMM_H @@ -167,7 +167,7 @@ void set_default_bfd_target PARAMS ((void)); void list_matching_formats - PARAMS ((char **p)); + PARAMS ((char **)); void list_supported_targets PARAMS ((const char *, FILE *)); @@ -175,8 +175,11 @@ void list_supported_targets void list_supported_architectures PARAMS ((const char *, FILE *)); +int display_info + PARAMS ((void)); + void print_arelt_descr - PARAMS ((FILE *file, bfd *abfd, bfd_boolean verbose)); + PARAMS ((FILE *, bfd *, bfd_boolean)); char *make_tempname PARAMS ((char *)); @@ -188,7 +191,7 @@ extern char *program_name; /* filemode.c */ void mode_string - PARAMS ((unsigned long mode, char *buf)); + PARAMS ((unsigned long, char *)); /* version.c */ extern void print_version @@ -201,7 +204,7 @@ extern void set_times extern int smart_rename PARAMS ((const char *, const char *, int)); -/* libiberty */ +/* libiberty. */ PTR xmalloc PARAMS ((size_t)); diff --git a/binutils/objdump.c b/binutils/objdump.c index 26299cf..b641fde 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -123,21 +123,21 @@ static void usage static void nonfatal PARAMS ((const char *)); static void display_file - PARAMS ((char *filename, char *target)); + PARAMS ((char *, char *)); static void dump_section_header PARAMS ((bfd *, asection *, PTR)); static void dump_headers PARAMS ((bfd *)); static void dump_data - PARAMS ((bfd *abfd)); + PARAMS ((bfd *)); static void dump_relocs - PARAMS ((bfd *abfd)); + PARAMS ((bfd *)); static void dump_dynamic_relocs - PARAMS ((bfd * abfd)); + PARAMS ((bfd *)); static void dump_reloc_set PARAMS ((bfd *, asection *, arelent **, long)); static void dump_symbols - PARAMS ((bfd *abfd, bfd_boolean dynamic)); + PARAMS ((bfd *, bfd_boolean)); static void dump_bfd_header PARAMS ((bfd *)); static void dump_bfd_private_header @@ -145,15 +145,7 @@ static void dump_bfd_private_header static void dump_bfd PARAMS ((bfd *)); static void display_bfd - PARAMS ((bfd *abfd)); -static void display_target_list - PARAMS ((void)); -static void display_info_table - PARAMS ((int, int)); -static void display_target_tables - PARAMS ((void)); -static void display_info - PARAMS ((void)); + PARAMS ((bfd *)); static void objdump_print_value PARAMS ((bfd_vma, struct disassemble_info *, bfd_boolean)); static void objdump_print_symname @@ -176,8 +168,6 @@ static void disassemble_bytes bfd_byte *, bfd_vma, bfd_vma, arelent ***, arelent **)); static void disassemble_data PARAMS ((bfd *)); -static const char *endian_string - PARAMS ((enum bfd_endian)); static asymbol ** slurp_symtab PARAMS ((bfd *)); static asymbol ** slurp_dynamic_symtab @@ -2571,183 +2561,6 @@ dump_reloc_set (abfd, sec, relpp, relcount) } } -/* The length of the longest architecture name + 1. */ -#define LONGEST_ARCH sizeof("powerpc:common") - -static const char * -endian_string (endian) - enum bfd_endian endian; -{ - if (endian == BFD_ENDIAN_BIG) - return "big endian"; - else if (endian == BFD_ENDIAN_LITTLE) - return "little endian"; - else - return "endianness unknown"; -} - -/* List the targets that BFD is configured to support, each followed - by its endianness and the architectures it supports. */ - -static void -display_target_list () -{ - extern const bfd_target *const *bfd_target_vector; - char *dummy_name; - int t; - - dummy_name = make_temp_file (NULL); - for (t = 0; bfd_target_vector[t]; t++) - { - const bfd_target *p = bfd_target_vector[t]; - bfd *abfd = bfd_openw (dummy_name, p->name); - int a; - - printf ("%s\n (header %s, data %s)\n", p->name, - endian_string (p->header_byteorder), - endian_string (p->byteorder)); - - if (abfd == NULL) - { - nonfatal (dummy_name); - continue; - } - - if (! bfd_set_format (abfd, bfd_object)) - { - if (bfd_get_error () != bfd_error_invalid_operation) - nonfatal (p->name); - bfd_close_all_done (abfd); - continue; - } - - for (a = (int) bfd_arch_obscure + 1; a < (int) bfd_arch_last; a++) - if (bfd_set_arch_mach (abfd, (enum bfd_architecture) a, 0)) - printf (" %s\n", - bfd_printable_arch_mach ((enum bfd_architecture) a, 0)); - bfd_close_all_done (abfd); - } - unlink (dummy_name); - free (dummy_name); -} - -/* Print a table showing which architectures are supported for entries - FIRST through LAST-1 of bfd_target_vector (targets across, - architectures down). */ - -static void -display_info_table (first, last) - int first; - int last; -{ - extern const bfd_target *const *bfd_target_vector; - int t, a; - char *dummy_name; - - /* Print heading of target names. */ - printf ("\n%*s", (int) LONGEST_ARCH, " "); - for (t = first; t < last && bfd_target_vector[t]; t++) - printf ("%s ", bfd_target_vector[t]->name); - putchar ('\n'); - - dummy_name = make_temp_file (NULL); - for (a = (int) bfd_arch_obscure + 1; a < (int) bfd_arch_last; a++) - if (strcmp (bfd_printable_arch_mach (a, 0), "UNKNOWN!") != 0) - { - printf ("%*s ", (int) LONGEST_ARCH - 1, - bfd_printable_arch_mach (a, 0)); - for (t = first; t < last && bfd_target_vector[t]; t++) - { - const bfd_target *p = bfd_target_vector[t]; - bfd_boolean ok = TRUE; - bfd *abfd = bfd_openw (dummy_name, p->name); - - if (abfd == NULL) - { - nonfatal (p->name); - ok = FALSE; - } - - if (ok) - { - if (! bfd_set_format (abfd, bfd_object)) - { - if (bfd_get_error () != bfd_error_invalid_operation) - nonfatal (p->name); - ok = FALSE; - } - } - - if (ok) - { - if (! bfd_set_arch_mach (abfd, a, 0)) - ok = FALSE; - } - - if (ok) - printf ("%s ", p->name); - else - { - int l = strlen (p->name); - while (l--) - putchar ('-'); - putchar (' '); - } - if (abfd != NULL) - bfd_close_all_done (abfd); - } - putchar ('\n'); - } - unlink (dummy_name); - free (dummy_name); -} - -/* Print tables of all the target-architecture combinations that - BFD has been configured to support. */ - -static void -display_target_tables () -{ - int t, columns; - extern const bfd_target *const *bfd_target_vector; - char *colum; - - columns = 0; - colum = getenv ("COLUMNS"); - if (colum != NULL) - columns = atoi (colum); - if (columns == 0) - columns = 80; - - t = 0; - while (bfd_target_vector[t] != NULL) - { - int oldt = t, wid; - - wid = LONGEST_ARCH + strlen (bfd_target_vector[t]->name) + 1; - ++t; - while (wid < columns && bfd_target_vector[t] != NULL) - { - int newwid; - - newwid = wid + strlen (bfd_target_vector[t]->name) + 1; - if (newwid >= columns) - break; - wid = newwid; - ++t; - } - display_info_table (oldt, t); - } -} - -static void -display_info () -{ - printf (_("BFD header file version %s\n"), BFD_VERSION_STRING); - display_target_list (); - display_target_tables (); -} - int main PARAMS ((int, char **)); int @@ -2943,7 +2756,7 @@ main (argc, argv) usage (stderr, 2); if (formats_info) - display_info (); + exit_status = display_info (); else { if (optind == argc)