This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [BUG] nm --size-sort doesn't print the size
- From: Elias Athanasopoulos <elathan at phys dot uoa dot gr>
- To: Bradley Baetz <bbaetz at acm dot org>
- Cc: binutils at sources dot redhat dot com
- Date: Sun, 16 Mar 2003 10:23:47 +0200
- Subject: Re: [BUG] nm --size-sort doesn't print the size
- References: <20030316065638.GA18875@mango.home>
On Sun, Mar 16, 2003 at 05:56:38PM +1100, Bradley Baetz wrote:
> The nm manpage says:
>
> --size-sort
> Sort symbols by size. The size is computed as the difference
> between the value of the symbol and the value of the symbol with
> the next higher value. The size of the symbol is printed, rather
> than the value.
The documentation has been changed, but it is still wrong. I have attached
a patch that makes nm to behave as the current documentation states.
> mozilla uses this as part of some tools to determine the size of various
> subroutines. -S doesn't work in 2.11.90, so we can't use that - is there
2.11.90 embeds the old behaviour of nm, which is workable for you.
> and reverting that patch fixes this problem. Was this change in behaviour
> done on purpose?
The change was made so as all the formats operate in a cosistent way; dump
the symbol's value : size.
I think the patch below fixes your problem, but IMHO this kind of behaviour
is not logical; the documentation part should be changed instead.
Elias
ChangeLog
2003-03-16 Elias Athanasopoulos <elathan at phys dot uoa dot gr>
nm.c (print_symbol_info_bsd): Print the symbol's size instead of the
symbol's value when --size-sort is used, unless -S is used.
===================================================================
RCS file: /home/anteater/bucvs/src/binutils/nm.c,v
retrieving revision 1.3
diff -u -r1.3 /home/anteater/bucvs/src/binutils/nm.c
--- /home/anteater/bucvs/src/binutils/nm.c 2003/03/16 07:36:41 1.3
+++ /home/anteater/bucvs/src/binutils/nm.c 2003/03/16 08:18:39
@@ -1538,8 +1538,13 @@
printf (" ");
}
else
- {
- print_value (abfd, SYM_VALUE (info));
+ {
+ /* When we sort by size we print the size of the
+ symbol instead of its value, unless -S is used. */
+ if (sort_by_size && !print_size)
+ print_value (abfd, SYM_SIZE (info));
+ else
+ print_value (abfd, SYM_VALUE (info));
if (print_size && SYM_SIZE (info))
{