[RFA] Document/add historic BSD options to strip and size
Jason R Thorpe
thorpej@wasabisystems.com
Sun Jan 20 17:23:00 GMT 2002
Hi folks...
The following patch does two things:
* Documents the -d alias for --strip-debug in strip
* Adds the -t (and --totals) option to size
The size -t option prints the totals of all listed objects when
using the Berkeley-style output format, like so:
p5064:thorpej 101$ /usr/local/gnu/bin/size -t uipc*.o
text data bss dec hex filename
2056 0 0 2056 808 uipc_domain.o
10008 16 0 10024 2728 uipc_mbuf.o
2040 0 0 2040 7f8 uipc_mbuf2.o
40 208 0 248 f8 uipc_proto.o
10984 16 0 11000 2af8 uipc_socket.o
7096 0 0 7096 1bb8 uipc_socket2.o
10008 0 0 10008 2718 uipc_syscalls.o
9048 128 0 9176 23d8 uipc_usrreq.o
51280 368 0 51648 c9c0 (TOTALS)
p5064:thorpej 102$
OK to commit?
* objcopy.c (strip_usage): Document -d as an alias
--strip-debug.
* size.c: Update copyright years.
(usage): Document [-t | --totals] options.
(long_options): Add --totals option.
(main): If the [-t | --totals] option is specified and
the output format is Berkeley-style, print the total
text, data, and bss sizes of all objects listed.
(print_berkeley_format): If the [-t | --totals] option
is specified, track the total text, data, and bss
sizes.
* doc/binutils.texi (size): Document [-t | --totals] options.
(strip): Document -d as an alias for --strip-debug.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
-------------- next part --------------
Index: objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.34
diff -c -r1.34 objcopy.c
*** objcopy.c 2002/01/15 17:18:53 1.34
--- objcopy.c 2002/01/20 23:49:47
***************
*** 438,444 ****
-p --preserve-dates Copy modified/access timestamps to the output\n\
-R --remove-section <name> Remove section <name> from the output\n\
-s --strip-all Remove all symbol and relocation information\n\
! -g -S --strip-debug Remove all debugging symbols\n\
--strip-unneeded Remove all symbols not needed by relocations\n\
-N --strip-symbol <name> Do not copy symbol <name>\n\
-K --keep-symbol <name> Only copy symbol <name>\n\
--- 438,444 ----
-p --preserve-dates Copy modified/access timestamps to the output\n\
-R --remove-section <name> Remove section <name> from the output\n\
-s --strip-all Remove all symbol and relocation information\n\
! -g -S -d --strip-debug Remove all debugging symbols\n\
--strip-unneeded Remove all symbols not needed by relocations\n\
-N --strip-symbol <name> Do not copy symbol <name>\n\
-K --keep-symbol <name> Only copy symbol <name>\n\
Index: size.c
===================================================================
RCS file: /cvs/src/src/binutils/size.c,v
retrieving revision 1.9
diff -c -r1.9 size.c
*** size.c 2001/12/18 08:22:30 1.9
--- size.c 2002/01/20 23:49:47
***************
*** 1,6 ****
/* size.c -- report size of various sections of an executable file.
! Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
! Free Software Foundation, Inc.
This file is part of GNU Binutils.
--- 1,6 ----
/* size.c -- report size of various sections of an executable file.
! Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
! 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils.
***************
*** 48,53 ****
--- 48,58 ----
int show_version = 0;
int show_help = 0;
+ int show_totals = 0;
+ static bfd_size_type total_bsssize;
+ static bfd_size_type total_datasize;
+ static bfd_size_type total_textsize;
+
/* Program exit status. */
int return_code = 0;
***************
*** 79,85 ****
fprintf (stream, _("\
Usage: %s [-A | --format=sysv | -B | --format=berkeley]\n\
[-o | --radix=8 | -d | --radix=10 | -h | --radix=16]\n\
! [-V | --version] [--target=bfdname] [--help] [file...]\n"),
program_name);
#if BSD_DEFAULT
fputs (_("default is --format=berkeley\n"), stream);
--- 84,91 ----
fprintf (stream, _("\
Usage: %s [-A | --format=sysv | -B | --format=berkeley]\n\
[-o | --radix=8 | -d | --radix=10 | -h | --radix=16]\n\
! [-V | --version] [--target=bfdname] [--help] \n\
! [--totals | -t] [file...]\n"),
program_name);
#if BSD_DEFAULT
fputs (_("default is --format=berkeley\n"), stream);
***************
*** 99,104 ****
--- 105,111 ----
{"target", required_argument, 0, 202},
{"version", no_argument, &show_version, 1},
{"help", no_argument, &show_help, 1},
+ {"totals", no_argument, &show_totals, 1},
{0, no_argument, 0, 0}
};
***************
*** 127,133 ****
bfd_init ();
set_default_bfd_target ();
! while ((c = getopt_long (argc, argv, "ABVdfox", long_options,
(int *) 0)) != EOF)
switch (c)
{
--- 134,140 ----
bfd_init ();
set_default_bfd_target ();
! while ((c = getopt_long (argc, argv, "ABVdfotx", long_options,
(int *) 0)) != EOF)
switch (c)
{
***************
*** 193,198 ****
--- 200,208 ----
case 'o':
radix = octal;
break;
+ case 't':
+ show_totals = 1;
+ break;
case 'f': /* FIXME : For sysv68, `-f' means `full format', i.e.
`[fname:] M(.text) + N(.data) + O(.bss) + P(.comment) = Q'
where `fname: ' appears only if there are >= 2 input files,
***************
*** 220,225 ****
--- 230,249 ----
for (; optind < argc;)
display_file (argv[optind++]);
+ if (show_totals && berkeley_format)
+ {
+ bfd_size_type total = total_textsize + total_datasize + total_bsssize;
+
+ rprint_number (7, total_textsize);
+ putchar('\t');
+ rprint_number (7, total_datasize);
+ putchar('\t');
+ rprint_number (7, total_bsssize);
+ printf (((radix == octal) ? "\t%7lo\t%7lx\t" : "\t%7lu\t%7lx\t"),
+ (unsigned long) total, (unsigned long) total);
+ fputs ("(TOTALS)\n", stdout);
+ }
+
return return_code;
}
***************
*** 427,432 ****
--- 451,463 ----
#endif
total = textsize + datasize + bsssize;
+
+ if (show_totals)
+ {
+ total_textsize += textsize;
+ total_datasize += datasize;
+ total_bsssize += bsssize;
+ }
rprint_number (7, textsize);
putchar ('\t');
Index: doc/binutils.texi
===================================================================
RCS file: /cvs/src/src/binutils/doc/binutils.texi,v
retrieving revision 1.14
diff -c -r1.14 binutils.texi
*** binutils.texi 2002/01/15 17:18:53 1.14
--- binutils.texi 2002/01/20 23:49:56
***************
*** 1758,1763 ****
--- 1758,1764 ----
@c man begin SYNOPSIS size
size [@option{-A}|@option{-B}|@option{--format=}@var{compatibility}]
[@option{--help}] [@option{-d}|@option{-o}|@option{-x}|@option{--radix=}@var{number}]
+ [@option{-t}|@option{--totals}]
[@option{--target=}@var{bfdname}] [@option{-V}|@option{--version}]
[@var{objfile}@dots{}]
@c man end
***************
*** 1840,1845 ****
--- 1841,1850 ----
radices; decimal and hexadecimal for @option{-d} or @option{-x} output, or
octal and hexadecimal if you're using @option{-o}.
+ @item -t
+ @itemx --totals
+ Show totals of all objects listed (Berkeley format listing mode only).
+
@item --target=@var{bfdname}
@cindex object code format
Specify that the object-code format for @var{objfile} is
***************
*** 1971,1977 ****
strip [@option{-F} @var{bfdname} |@option{--target=}@var{bfdname} ]
[@option{-I} @var{bfdname} |@option{--input-target=}@var{bfdname} ]
[@option{-O} @var{bfdname} |@option{--output-target=}@var{bfdname} ]
! [@option{-s}|@option{--strip-all}] [@option{-S}|@option{-g}|@option{--strip-debug}]
[@option{-K} @var{symbolname} |@option{--keep-symbol=}@var{symbolname} ]
[@option{-N} @var{symbolname} |@option{--strip-symbol=}@var{symbolname} ]
[@option{-x}|@option{--discard-all} ] [@option{-X} |@option{--discard-locals}]
--- 1976,1982 ----
strip [@option{-F} @var{bfdname} |@option{--target=}@var{bfdname} ]
[@option{-I} @var{bfdname} |@option{--input-target=}@var{bfdname} ]
[@option{-O} @var{bfdname} |@option{--output-target=}@var{bfdname} ]
! [@option{-s}|@option{--strip-all}] [@option{-S}|@option{-g}|@option{-d}|@option{--strip-debug}]
[@option{-K} @var{symbolname} |@option{--keep-symbol=}@var{symbolname} ]
[@option{-N} @var{symbolname} |@option{--strip-symbol=}@var{symbolname} ]
[@option{-x}|@option{--discard-all} ] [@option{-X} |@option{--discard-locals}]
***************
*** 2028,2033 ****
--- 2033,2039 ----
@item -g
@itemx -S
+ @itemx -d
@itemx --strip-debug
Remove debugging symbols only.
More information about the Binutils
mailing list