Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 5031 - nm --size-sort can report bogus sizes on .o files.
nm --size-sort can report bogus sizes on .o files.
Product: Red Hat Linux
Classification: Retired
Component: binutils (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Cristian Gafton
Depends On:
  Show dependency treegraph
Reported: 1999-09-09 15:53 EDT by Nalin Dahyabhai
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-02-04 12:39:36 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jim Kingdon 1999-09-09 15:53:45 EDT
(reported by Bill Nottingham).

This is a bug whereby nm --size-sort will sometimes
think that a symbol extends to the end of the current
section, when it really is smaller than that.
Enclosed is a test case and a fix.

[kingdon@porky tmp]$ cat hello.c
int y = 50;

static int bar (void) { printf ("hello, world\n"); return 0;

main (int argc, char **argv)
  return bar ();
[kingdon@porky tmp]$ gcc -c -o hello.o hello.c
[kingdon@porky tmp]$ nm --size-sort hello.o
00000004 D y
00000010 T main
00000028 t bar
[kingdon@porky tmp]$ nm-new --size-sort hello.o
00000004 D y
00000010 T main
00000018 t bar
[kingdon@porky tmp]$

1999-09-09  Jim Kingdon  <http://developer.redhat.com>

        * nm.c (size_forward1): Only sort by address if the
symbols are in
        the same section.

--- nm.c~       Sat Feb 20 19:56:56 1999
+++ nm.c        Thu Sep  9 15:33:12 1999
@@ -726,11 +726,19 @@
   if (bfd_is_und_section (ys))
     abort ();

-  if (valueof (x) != valueof (y))
-    return valueof (x) < valueof (y) ? -1 : 1;
   if (xs->vma != ys->vma)
     return xs->vma < ys->vma ? -1 : 1;
+  /* We want to sort by address (or symbol name or
whatever) only
+     within a given section (e.g. in .o files several
sections will be
+     mapped to address zero and we want all the symbols in
one section
+     to be together when we go to compute sizes).  */
+  if (xs != ys)
+    return strcmp (bfd_section_name (sort_bfd, xs),
+                  bfd_section_name (sort_bfd, ys));
+  if (valueof (x) != valueof (y))
+    return valueof (x) < valueof (y) ? -1 : 1;

   xn = bfd_asymbol_name (x);
   yn = bfd_asymbol_name (y);
Comment 1 Jim Kingdon 1999-09-10 11:24:59 EDT
Submitted to binutils maintainers at

This isn't important enough to need a new RPM before it makes it
into a binutils release.
Comment 2 Cristian Gafton 2000-02-04 12:39:59 EST
Fixed in the current devel tree (patch applied, I have no idea why the binutils
dudes have not integrate it yet)

Note You need to log in before you can comment on or make changes to this bug.