diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-01-24 14:27:27 +0000 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-02-08 11:07:24 +0000 |
commit | 46cbf38dc3a7c6d0e339f95d56590711b06427a1 (patch) | |
tree | 361adf72cc40b99e01f6c73e6ce906ec9d52a38e /binutils/doc/binutils.texi | |
parent | 482f3505d1b62cbcf46ffed54807fad0d91c8f09 (diff) | |
download | gdb-46cbf38dc3a7c6d0e339f95d56590711b06427a1.zip gdb-46cbf38dc3a7c6d0e339f95d56590711b06427a1.tar.gz gdb-46cbf38dc3a7c6d0e339f95d56590711b06427a1.tar.bz2 |
binutils: Add new GNU format mode to `size` utility
The size tool currently defaults to berkeley format output. However,
this output format has a weird quirk, read-only data is counted
against the text sections, not the data sections.
The code offers no real explanation for why this is, but I'm reluctant
to change it for two reasons, first, I'm assuming it probably makes
sense in some case that I'm not thinking of (maybe a target where
sections are not marked executable, and so there's no distinction
between read-only data and code), and second, the code has been this
way for at least 20 years, I worry that changing things now might
cause more confusion than it solves.
This commit then introduces a new output format for the size tool,
this new format displays the results in a similar manor to the
berkeley format, but counts read-only data in the data column, and
only executable sections are counted in the text column.
Given that this is a brand new output format I've gone ahead and
simplified things a little, while the berkeley format displays the
total twice, once in decimal and once in hex, the new display format
just displays the total in decimal. Of course, there's still the
'--radix' option which can be used to display all the results in
hexadecimal or octal.
I've called the new format 'gnu', so '--format=gnu' or '-G' are used
to access it.
binutils/ChangeLog:
* size.c (berkeley_format): Delete.
(enum output_format): New enum.
(selected_output_format): New variable.
(usage): Update to mention GNU format.
(main): Update to extract options, and select format as needed.
Handle GNU format where needed.
(berkeley_sum): Renamed to...
(berkeley_or_gnu_sum): ...this, and updated to handle both formats.
(berkeley_format): Renamed to...
(berkeley_or_gnu_format): ...this, and updated to handle both
formats.
(print_sizes): Handle GNU format.
* doc/binutils.texi (size): Document new GNU format.
* testsuite/binutils-all/size.exp: Add test of extended
functionality.
* NEWS: Mention new functionality.
Diffstat (limited to 'binutils/doc/binutils.texi')
-rw-r--r-- | binutils/doc/binutils.texi | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index 1137dce..01f1e5f 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -2877,7 +2877,7 @@ ar(1), nm(1), and the Info entries for @file{binutils}. @smallexample @c man begin SYNOPSIS size -size [@option{-A}|@option{-B}|@option{--format=}@var{compatibility}] +size [@option{-A}|@option{-B}|@option{-G}|@option{--format=}@var{compatibility}] [@option{--help}] [@option{-d}|@option{-o}|@option{-x}|@option{--radix=}@var{number}] [@option{--common}] @@ -2906,13 +2906,16 @@ The command-line options have the following meanings: @table @env @item -A @itemx -B +@itemx -G @itemx --format=@var{compatibility} @cindex @command{size} display format Using one of these options, you can choose whether the output from @sc{gnu} @command{size} resembles output from System V @command{size} (using @option{-A}, or @option{--format=sysv}), or Berkeley @command{size} (using @option{-B}, or @option{--format=berkeley}). The default is the one-line format similar to -Berkeley's. +Berkeley's. Alternatively, you can choose the GNU format output +(using @option{-G}, or @option{--format=gnu}), this is similar to +Berkeley's output format, but sizes are counted differently. @c Bonus for doc-source readers: you can also say --format=strange (or @c anything else that starts with 's') for sysv, and --format=boring (or @c anything else that starts with 'b') for Berkeley. @@ -2926,6 +2929,24 @@ $ size --format=Berkeley ranlib size 294880 81920 11888 388688 5ee50 size @end smallexample +The Berkeley style output counts read only data in the @code{text} +column, not in the @code{data} column, the @code{dec} and @code{hex} +columns both display the sum of the @code{text}, @code{data}, and +@code{bss} columns in decimal and hexadecimal respectively. + +The GNU format counts read only data in the @code{data} column, not +the @code{text} column, and only displays the sum of the @code{text}, +@code{data}, and @code{bss} columns once, in the @code{total} column. +The @option{--radix} option can be used to change the number base for +all columns. Here is the same data displayed with GNU conventions: + +@smallexample +$ size --format=GNU ranlib size + text data bss total filename + 279880 96920 11592 388392 ranlib + 279880 96920 11888 388688 size +@end smallexample + @noindent This is the same data, but displayed closer to System V conventions: @@ -2966,11 +2987,11 @@ octal and hexadecimal if you're using @option{-o}. @item --common Print total size of common symbols in each file. When using Berkeley -format these are included in the bss size. +or GNU format these are included in the bss size. @item -t @itemx --totals -Show totals of all objects listed (Berkeley format listing mode only). +Show totals of all objects listed (Berkeley or GNU format mode only). @item --target=@var{bfdname} @cindex object code format |