size.c revision 130561
133965Sjdp/* size.c -- report size of various sections of an executable file. 2130561Sobrien Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 3130561Sobrien 2002, 2003 Free Software Foundation, Inc. 433965Sjdp 589857Sobrien This file is part of GNU Binutils. 633965Sjdp 789857Sobrien This program is free software; you can redistribute it and/or modify 889857Sobrien it under the terms of the GNU General Public License as published by 989857Sobrien the Free Software Foundation; either version 2 of the License, or 1089857Sobrien (at your option) any later version. 1133965Sjdp 1289857Sobrien This program is distributed in the hope that it will be useful, 1389857Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 1489857Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1589857Sobrien GNU General Public License for more details. 1633965Sjdp 1789857Sobrien You should have received a copy of the GNU General Public License 1889857Sobrien along with this program; if not, write to the Free Software 1989857Sobrien Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 2033965Sjdp 2133965Sjdp/* Extensions/incompatibilities: 2233965Sjdp o - BSD output has filenames at the end. 2333965Sjdp o - BSD output can appear in different radicies. 2433965Sjdp o - SysV output has less redundant whitespace. Filename comes at end. 2533965Sjdp o - SysV output doesn't show VMA which is always the same as the PMA. 2633965Sjdp o - We also handle core files. 2733965Sjdp o - We also handle archives. 2833965Sjdp If you write shell scripts which manipulate this info then you may be 2989857Sobrien out of luck; there's no --compatibility or --pedantic option. */ 3033965Sjdp 3133965Sjdp#include "bfd.h" 3233965Sjdp#include "bucomm.h" 3333965Sjdp#include "libiberty.h" 3491041Sobrien#include "getopt.h" 3533965Sjdp 3633965Sjdp#ifndef BSD_DEFAULT 3733965Sjdp#define BSD_DEFAULT 1 3833965Sjdp#endif 3933965Sjdp 4033965Sjdp/* Program options. */ 4133965Sjdp 4233965Sjdpenum 4333965Sjdp { 4433965Sjdp decimal, octal, hex 4589857Sobrien } 4689857Sobrienradix = decimal; 4789857Sobrien 4833965Sjdpint berkeley_format = BSD_DEFAULT; /* 0 means use AT&T-style output. */ 4933965Sjdpint show_version = 0; 5033965Sjdpint show_help = 0; 5189857Sobrienint show_totals = 0; 5233965Sjdp 5389857Sobrienstatic bfd_size_type total_bsssize; 5489857Sobrienstatic bfd_size_type total_datasize; 5589857Sobrienstatic bfd_size_type total_textsize; 5689857Sobrien 5733965Sjdp/* Program exit status. */ 5833965Sjdpint return_code = 0; 5933965Sjdp 6038889Sjdpstatic char *target = NULL; 6133965Sjdp 6289857Sobrien/* Static declarations. */ 6333965Sjdp 64130561Sobrienstatic void usage (FILE *, int); 65130561Sobrienstatic void display_file (char *); 66130561Sobrienstatic void display_bfd (bfd *); 67130561Sobrienstatic void display_archive (bfd *); 68130561Sobrienstatic int size_number (bfd_size_type); 6938889Sjdp#if 0 70130561Sobrienstatic void lprint_number (int, bfd_size_type); 7138889Sjdp#endif 72130561Sobrienstatic void rprint_number (int, bfd_size_type); 73130561Sobrienstatic void print_berkeley_format (bfd *); 74130561Sobrienstatic void sysv_internal_sizer (bfd *, asection *, void *); 75130561Sobrienstatic void sysv_internal_printer (bfd *, asection *, void *); 76130561Sobrienstatic void print_sysv_format (bfd *); 77130561Sobrienstatic void print_sizes (bfd * file); 78130561Sobrienstatic void berkeley_sum (bfd *, sec_ptr, void *); 7933965Sjdp 8033965Sjdpstatic void 81130561Sobrienusage (FILE *stream, int status) 8233965Sjdp{ 8389857Sobrien fprintf (stream, _("Usage: %s [option(s)] [file(s)]\n"), program_name); 8489857Sobrien fprintf (stream, _(" Displays the sizes of sections inside binary files\n")); 85104834Sobrien fprintf (stream, _(" If no input file(s) are specified, a.out is assumed\n")); 8689857Sobrien fprintf (stream, _(" The options are:\n\ 8789857Sobrien -A|-B --format={sysv|berkeley} Select output style (default is %s)\n\ 88130561Sobrien -o|-d|-x --radix={8|10|16} Display numbers in octal, decimal or hex\n\ 8989857Sobrien -t --totals Display the total sizes (Berkeley only)\n\ 9089857Sobrien --target=<bfdname> Set the binary file format\n\ 9189857Sobrien -h --help Display this information\n\ 9289857Sobrien -v --version Display the program's version\n\ 9389857Sobrien\n"), 9433965Sjdp#if BSD_DEFAULT 9589857Sobrien "berkeley" 9633965Sjdp#else 9789857Sobrien "sysv" 9833965Sjdp#endif 9989857Sobrien); 10033965Sjdp list_supported_targets (program_name, stream); 10133965Sjdp if (status == 0) 10260484Sobrien fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO); 10333965Sjdp exit (status); 10433965Sjdp} 10533965Sjdp 10633965Sjdpstruct option long_options[] = 10733965Sjdp{ 10833965Sjdp {"format", required_argument, 0, 200}, 10933965Sjdp {"radix", required_argument, 0, 201}, 11033965Sjdp {"target", required_argument, 0, 202}, 11189857Sobrien {"totals", no_argument, &show_totals, 1}, 11233965Sjdp {"version", no_argument, &show_version, 1}, 11333965Sjdp {"help", no_argument, &show_help, 1}, 11433965Sjdp {0, no_argument, 0, 0} 11533965Sjdp}; 11633965Sjdp 117130561Sobrienint main (int, char **); 11889857Sobrien 11933965Sjdpint 120130561Sobrienmain (int argc, char **argv) 12133965Sjdp{ 12233965Sjdp int temp; 12333965Sjdp int c; 12433965Sjdp 12560484Sobrien#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) 12660484Sobrien setlocale (LC_MESSAGES, ""); 12760484Sobrien#endif 12889857Sobrien#if defined (HAVE_SETLOCALE) 12989857Sobrien setlocale (LC_CTYPE, ""); 13089857Sobrien#endif 13160484Sobrien bindtextdomain (PACKAGE, LOCALEDIR); 13260484Sobrien textdomain (PACKAGE); 13360484Sobrien 13433965Sjdp program_name = *argv; 13533965Sjdp xmalloc_set_program_name (program_name); 13633965Sjdp 13733965Sjdp bfd_init (); 13833965Sjdp set_default_bfd_target (); 13933965Sjdp 14089857Sobrien while ((c = getopt_long (argc, argv, "ABHhVvdfotx", long_options, 14133965Sjdp (int *) 0)) != EOF) 14233965Sjdp switch (c) 14333965Sjdp { 14433965Sjdp case 200: /* --format */ 14533965Sjdp switch (*optarg) 14633965Sjdp { 14733965Sjdp case 'B': 14833965Sjdp case 'b': 14933965Sjdp berkeley_format = 1; 15033965Sjdp break; 15133965Sjdp case 'S': 15233965Sjdp case 's': 15333965Sjdp berkeley_format = 0; 15433965Sjdp break; 15533965Sjdp default: 15660484Sobrien non_fatal (_("invalid argument to --format: %s"), optarg); 15733965Sjdp usage (stderr, 1); 15833965Sjdp } 15933965Sjdp break; 16033965Sjdp 16133965Sjdp case 202: /* --target */ 16233965Sjdp target = optarg; 16333965Sjdp break; 16433965Sjdp 16533965Sjdp case 201: /* --radix */ 16633965Sjdp#ifdef ANSI_LIBRARIES 16733965Sjdp temp = strtol (optarg, NULL, 10); 16833965Sjdp#else 16933965Sjdp temp = atol (optarg); 17033965Sjdp#endif 17133965Sjdp switch (temp) 17233965Sjdp { 17333965Sjdp case 10: 17433965Sjdp radix = decimal; 17533965Sjdp break; 17633965Sjdp case 8: 17733965Sjdp radix = octal; 17833965Sjdp break; 17933965Sjdp case 16: 18033965Sjdp radix = hex; 18133965Sjdp break; 18233965Sjdp default: 18360484Sobrien non_fatal (_("Invalid radix: %s\n"), optarg); 18433965Sjdp usage (stderr, 1); 18533965Sjdp } 18633965Sjdp break; 18733965Sjdp 18833965Sjdp case 'A': 18933965Sjdp berkeley_format = 0; 19033965Sjdp break; 19133965Sjdp case 'B': 19233965Sjdp berkeley_format = 1; 19333965Sjdp break; 19489857Sobrien case 'v': 19533965Sjdp case 'V': 19633965Sjdp show_version = 1; 19733965Sjdp break; 19833965Sjdp case 'd': 19933965Sjdp radix = decimal; 20033965Sjdp break; 20133965Sjdp case 'x': 20233965Sjdp radix = hex; 20333965Sjdp break; 20433965Sjdp case 'o': 20533965Sjdp radix = octal; 20633965Sjdp break; 20789857Sobrien case 't': 20889857Sobrien show_totals = 1; 20989857Sobrien break; 21077298Sobrien case 'f': /* FIXME : For sysv68, `-f' means `full format', i.e. 21177298Sobrien `[fname:] M(.text) + N(.data) + O(.bss) + P(.comment) = Q' 21277298Sobrien where `fname: ' appears only if there are >= 2 input files, 21377298Sobrien and M, N, O, P, Q are expressed in decimal by default, 21477298Sobrien hexa or octal if requested by `-x' or `-o'. 21577298Sobrien Just to make things interesting, Solaris also accepts -f, 21677298Sobrien which prints out the size of each allocatable section, the 21777298Sobrien name of the section, and the total of the section sizes. */ 21877298Sobrien /* For the moment, accept `-f' silently, and ignore it. */ 21977298Sobrien break; 22033965Sjdp case 0: 22133965Sjdp break; 22289857Sobrien case 'h': 22389857Sobrien case 'H': 22433965Sjdp case '?': 22533965Sjdp usage (stderr, 1); 22633965Sjdp } 22733965Sjdp 22833965Sjdp if (show_version) 22933965Sjdp print_version ("size"); 23033965Sjdp if (show_help) 23133965Sjdp usage (stdout, 0); 23233965Sjdp 23333965Sjdp if (optind == argc) 23433965Sjdp display_file ("a.out"); 23533965Sjdp else 23633965Sjdp for (; optind < argc;) 23733965Sjdp display_file (argv[optind++]); 23833965Sjdp 23989857Sobrien if (show_totals && berkeley_format) 24089857Sobrien { 24189857Sobrien bfd_size_type total = total_textsize + total_datasize + total_bsssize; 24289857Sobrien 24389857Sobrien rprint_number (7, total_textsize); 24489857Sobrien putchar('\t'); 24589857Sobrien rprint_number (7, total_datasize); 24689857Sobrien putchar('\t'); 24789857Sobrien rprint_number (7, total_bsssize); 24889857Sobrien printf (((radix == octal) ? "\t%7lo\t%7lx\t" : "\t%7lu\t%7lx\t"), 24989857Sobrien (unsigned long) total, (unsigned long) total); 25089857Sobrien fputs ("(TOTALS)\n", stdout); 25189857Sobrien } 25289857Sobrien 25333965Sjdp return return_code; 25433965Sjdp} 25533965Sjdp 25633965Sjdp/* Display stats on file or archive member ABFD. */ 25733965Sjdp 25833965Sjdpstatic void 259130561Sobriendisplay_bfd (bfd *abfd) 26033965Sjdp{ 26133965Sjdp char **matching; 26233965Sjdp 26333965Sjdp if (bfd_check_format (abfd, bfd_archive)) 26433965Sjdp /* An archive within an archive. */ 26533965Sjdp return; 26633965Sjdp 26733965Sjdp if (bfd_check_format_matches (abfd, bfd_object, &matching)) 26833965Sjdp { 26933965Sjdp print_sizes (abfd); 27033965Sjdp printf ("\n"); 27133965Sjdp return; 27233965Sjdp } 27333965Sjdp 27433965Sjdp if (bfd_get_error () == bfd_error_file_ambiguously_recognized) 27533965Sjdp { 27633965Sjdp bfd_nonfatal (bfd_get_filename (abfd)); 27733965Sjdp list_matching_formats (matching); 27833965Sjdp free (matching); 27933965Sjdp return_code = 3; 28033965Sjdp return; 28133965Sjdp } 28233965Sjdp 28333965Sjdp if (bfd_check_format_matches (abfd, bfd_core, &matching)) 28433965Sjdp { 28589857Sobrien const char *core_cmd; 28633965Sjdp 28733965Sjdp print_sizes (abfd); 28833965Sjdp fputs (" (core file", stdout); 28933965Sjdp 29033965Sjdp core_cmd = bfd_core_file_failing_command (abfd); 29133965Sjdp if (core_cmd) 29233965Sjdp printf (" invoked as %s", core_cmd); 29333965Sjdp 29433965Sjdp puts (")\n"); 29533965Sjdp return; 29633965Sjdp } 29733965Sjdp 29833965Sjdp bfd_nonfatal (bfd_get_filename (abfd)); 29933965Sjdp 30033965Sjdp if (bfd_get_error () == bfd_error_file_ambiguously_recognized) 30133965Sjdp { 30233965Sjdp list_matching_formats (matching); 30333965Sjdp free (matching); 30433965Sjdp } 30533965Sjdp 30633965Sjdp return_code = 3; 30733965Sjdp} 30833965Sjdp 30933965Sjdpstatic void 310130561Sobriendisplay_archive (bfd *file) 31133965Sjdp{ 31233965Sjdp bfd *arfile = (bfd *) NULL; 31399461Sobrien bfd *last_arfile = (bfd *) NULL; 31433965Sjdp 31533965Sjdp for (;;) 31633965Sjdp { 31733965Sjdp bfd_set_error (bfd_error_no_error); 31833965Sjdp 31933965Sjdp arfile = bfd_openr_next_archived_file (file, arfile); 32033965Sjdp if (arfile == NULL) 32133965Sjdp { 32233965Sjdp if (bfd_get_error () != bfd_error_no_more_archived_files) 32333965Sjdp { 32433965Sjdp bfd_nonfatal (bfd_get_filename (file)); 32533965Sjdp return_code = 2; 32633965Sjdp } 32733965Sjdp break; 32833965Sjdp } 32933965Sjdp 33033965Sjdp display_bfd (arfile); 33199461Sobrien 33299461Sobrien if (last_arfile != NULL) 33399461Sobrien bfd_close (last_arfile); 33499461Sobrien last_arfile = arfile; 33533965Sjdp } 33699461Sobrien 33799461Sobrien if (last_arfile != NULL) 33899461Sobrien bfd_close (last_arfile); 33933965Sjdp} 34033965Sjdp 34133965Sjdpstatic void 342130561Sobriendisplay_file (char *filename) 34333965Sjdp{ 344130561Sobrien bfd *file; 34589857Sobrien 346130561Sobrien if (get_file_size (filename) < 1) 347130561Sobrien return; 348130561Sobrien 349130561Sobrien file = bfd_openr (filename, target); 35033965Sjdp if (file == NULL) 35133965Sjdp { 35233965Sjdp bfd_nonfatal (filename); 35333965Sjdp return_code = 1; 35433965Sjdp return; 35533965Sjdp } 35633965Sjdp 357130561Sobrien if (bfd_check_format (file, bfd_archive)) 35833965Sjdp display_archive (file); 35933965Sjdp else 36033965Sjdp display_bfd (file); 36133965Sjdp 362130561Sobrien if (!bfd_close (file)) 36333965Sjdp { 36433965Sjdp bfd_nonfatal (filename); 36533965Sjdp return_code = 1; 36633965Sjdp return; 36733965Sjdp } 36833965Sjdp} 36933965Sjdp 37033965Sjdp/* This is what lexical functions are for. */ 37133965Sjdp 37238889Sjdpstatic int 373130561Sobriensize_number (bfd_size_type num) 37438889Sjdp{ 37538889Sjdp char buffer[40]; 37689857Sobrien 37738889Sjdp sprintf (buffer, 37838889Sjdp (radix == decimal ? "%lu" : 37938889Sjdp ((radix == octal) ? "0%lo" : "0x%lx")), 38038889Sjdp (unsigned long) num); 38138889Sjdp 38238889Sjdp return strlen (buffer); 38338889Sjdp} 38438889Sjdp 38538889Sjdp#if 0 38638889Sjdp 38738889Sjdp/* This is not used. */ 38838889Sjdp 38933965Sjdpstatic void 390130561Sobrienlprint_number (int width, bfd_size_type num) 39133965Sjdp{ 39238889Sjdp char buffer[40]; 39389857Sobrien 39438889Sjdp sprintf (buffer, 39538889Sjdp (radix == decimal ? "%lu" : 39638889Sjdp ((radix == octal) ? "0%lo" : "0x%lx")), 39738889Sjdp (unsigned long) num); 39838889Sjdp 39938889Sjdp printf ("%-*s", width, buffer); 40033965Sjdp} 40133965Sjdp 40238889Sjdp#endif 40338889Sjdp 40433965Sjdpstatic void 405130561Sobrienrprint_number (int width, bfd_size_type num) 40633965Sjdp{ 40738889Sjdp char buffer[40]; 40889857Sobrien 40938889Sjdp sprintf (buffer, 41038889Sjdp (radix == decimal ? "%lu" : 41138889Sjdp ((radix == octal) ? "0%lo" : "0x%lx")), 41238889Sjdp (unsigned long) num); 41338889Sjdp 41438889Sjdp printf ("%*s", width, buffer); 41533965Sjdp} 41633965Sjdp 41733965Sjdpstatic bfd_size_type bsssize; 41833965Sjdpstatic bfd_size_type datasize; 41933965Sjdpstatic bfd_size_type textsize; 42033965Sjdp 42133965Sjdpstatic void 422130561Sobrienberkeley_sum (bfd *abfd ATTRIBUTE_UNUSED, sec_ptr sec, 423130561Sobrien void *ignore ATTRIBUTE_UNUSED) 42433965Sjdp{ 42533965Sjdp flagword flags; 42633965Sjdp bfd_size_type size; 42733965Sjdp 42833965Sjdp flags = bfd_get_section_flags (abfd, sec); 42933965Sjdp if ((flags & SEC_ALLOC) == 0) 43033965Sjdp return; 43133965Sjdp 43233965Sjdp size = bfd_get_section_size_before_reloc (sec); 43333965Sjdp if ((flags & SEC_CODE) != 0 || (flags & SEC_READONLY) != 0) 43433965Sjdp textsize += size; 43533965Sjdp else if ((flags & SEC_HAS_CONTENTS) != 0) 43633965Sjdp datasize += size; 43733965Sjdp else 43833965Sjdp bsssize += size; 43933965Sjdp} 44033965Sjdp 441104834Sobrienstatic void 442130561Sobrienprint_berkeley_format (bfd *abfd) 44333965Sjdp{ 44433965Sjdp static int files_seen = 0; 44533965Sjdp bfd_size_type total; 44633965Sjdp 44733965Sjdp bsssize = 0; 44833965Sjdp datasize = 0; 44933965Sjdp textsize = 0; 45033965Sjdp 451130561Sobrien bfd_map_over_sections (abfd, berkeley_sum, NULL); 45233965Sjdp 45333965Sjdp if (files_seen++ == 0) 45433965Sjdp#if 0 45533965Sjdp /* Intel doesn't like bss/stk because they don't have core files. */ 45638889Sjdp puts ((radix == octal) ? " text\t data\tbss/stk\t oct\t hex\tfilename" : 45738889Sjdp " text\t data\tbss/stk\t dec\t hex\tfilename"); 45833965Sjdp#else 45938889Sjdp puts ((radix == octal) ? " text\t data\t bss\t oct\t hex\tfilename" : 46038889Sjdp " text\t data\t bss\t dec\t hex\tfilename"); 46133965Sjdp#endif 46233965Sjdp 46333965Sjdp total = textsize + datasize + bsssize; 46433965Sjdp 46589857Sobrien if (show_totals) 46689857Sobrien { 46789857Sobrien total_textsize += textsize; 46889857Sobrien total_datasize += datasize; 46989857Sobrien total_bsssize += bsssize; 47089857Sobrien } 47189857Sobrien 47238889Sjdp rprint_number (7, textsize); 47338889Sjdp putchar ('\t'); 47438889Sjdp rprint_number (7, datasize); 47538889Sjdp putchar ('\t'); 47638889Sjdp rprint_number (7, bsssize); 47738889Sjdp printf (((radix == octal) ? "\t%7lo\t%7lx\t" : "\t%7lu\t%7lx\t"), 47833965Sjdp (unsigned long) total, (unsigned long) total); 47933965Sjdp 48033965Sjdp fputs (bfd_get_filename (abfd), stdout); 48189857Sobrien 48233965Sjdp if (bfd_my_archive (abfd)) 48333965Sjdp printf (" (ex %s)", bfd_get_filename (bfd_my_archive (abfd))); 48433965Sjdp} 48533965Sjdp 48633965Sjdp/* I REALLY miss lexical functions! */ 48733965Sjdpbfd_size_type svi_total = 0; 48838889Sjdpbfd_vma svi_maxvma = 0; 48938889Sjdpint svi_namelen = 0; 49038889Sjdpint svi_vmalen = 0; 49138889Sjdpint svi_sizelen = 0; 49233965Sjdp 49333965Sjdpstatic void 494130561Sobriensysv_internal_sizer (bfd *file ATTRIBUTE_UNUSED, sec_ptr sec, 495130561Sobrien void *ignore ATTRIBUTE_UNUSED) 49638889Sjdp{ 49738889Sjdp bfd_size_type size = bfd_section_size (file, sec); 49889857Sobrien 49989857Sobrien if ( ! bfd_is_abs_section (sec) 50089857Sobrien && ! bfd_is_com_section (sec) 50189857Sobrien && ! bfd_is_und_section (sec)) 50238889Sjdp { 50338889Sjdp int namelen = strlen (bfd_section_name (file, sec)); 50489857Sobrien 50538889Sjdp if (namelen > svi_namelen) 50638889Sjdp svi_namelen = namelen; 50738889Sjdp 50838889Sjdp svi_total += size; 50989857Sobrien 51038889Sjdp if (bfd_section_vma (file, sec) > svi_maxvma) 51138889Sjdp svi_maxvma = bfd_section_vma (file, sec); 51238889Sjdp } 51338889Sjdp} 51438889Sjdp 51538889Sjdpstatic void 516130561Sobriensysv_internal_printer (bfd *file ATTRIBUTE_UNUSED, sec_ptr sec, 517130561Sobrien void *ignore ATTRIBUTE_UNUSED) 51833965Sjdp{ 51933965Sjdp bfd_size_type size = bfd_section_size (file, sec); 52089857Sobrien 52189857Sobrien if ( ! bfd_is_abs_section (sec) 52289857Sobrien && ! bfd_is_com_section (sec) 52389857Sobrien && ! bfd_is_und_section (sec)) 52433965Sjdp { 52533965Sjdp svi_total += size; 52633965Sjdp 52738889Sjdp printf ("%-*s ", svi_namelen, bfd_section_name (file, sec)); 52838889Sjdp rprint_number (svi_sizelen, size); 52938889Sjdp printf (" "); 53038889Sjdp rprint_number (svi_vmalen, bfd_section_vma (file, sec)); 53133965Sjdp printf ("\n"); 53233965Sjdp } 53333965Sjdp} 53433965Sjdp 53533965Sjdpstatic void 536130561Sobrienprint_sysv_format (bfd *file) 53733965Sjdp{ 53889857Sobrien /* Size all of the columns. */ 53933965Sjdp svi_total = 0; 54038889Sjdp svi_maxvma = 0; 54138889Sjdp svi_namelen = 0; 542130561Sobrien bfd_map_over_sections (file, sysv_internal_sizer, NULL); 54338889Sjdp svi_vmalen = size_number ((bfd_size_type)svi_maxvma); 54489857Sobrien 54538889Sjdp if ((size_t) svi_vmalen < sizeof ("addr") - 1) 54638889Sjdp svi_vmalen = sizeof ("addr")-1; 54733965Sjdp 54838889Sjdp svi_sizelen = size_number (svi_total); 54938889Sjdp if ((size_t) svi_sizelen < sizeof ("size") - 1) 55038889Sjdp svi_sizelen = sizeof ("size")-1; 55138889Sjdp 55238889Sjdp svi_total = 0; 55333965Sjdp printf ("%s ", bfd_get_filename (file)); 55489857Sobrien 55533965Sjdp if (bfd_my_archive (file)) 55633965Sjdp printf (" (ex %s)", bfd_get_filename (bfd_my_archive (file))); 55733965Sjdp 55838889Sjdp printf (":\n%-*s %*s %*s\n", svi_namelen, "section", 55938889Sjdp svi_sizelen, "size", svi_vmalen, "addr"); 56089857Sobrien 561130561Sobrien bfd_map_over_sections (file, sysv_internal_printer, NULL); 56233965Sjdp 56338889Sjdp printf ("%-*s ", svi_namelen, "Total"); 56438889Sjdp rprint_number (svi_sizelen, svi_total); 56533965Sjdp printf ("\n\n"); 56633965Sjdp} 56733965Sjdp 56833965Sjdpstatic void 569130561Sobrienprint_sizes (bfd *file) 57033965Sjdp{ 57133965Sjdp if (berkeley_format) 57233965Sjdp print_berkeley_format (file); 57333965Sjdp else 57433965Sjdp print_sysv_format (file); 57533965Sjdp} 576