(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; } int 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);
Submitted to binutils maintainers at http://sourceware.cygnus.com/ml/binutils/1999-q3/msg00633.html This isn't important enough to need a new RPM before it makes it into a binutils release.
Fixed in the current devel tree (patch applied, I have no idea why the binutils dudes have not integrate it yet)