This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] nm.c elf size support
- From: Elias Athanasopoulos <eathan at otenet dot gr>
- To: binutils at sources dot redhat dot com
- Date: Mon, 3 Jun 2002 21:46:39 +0300
- Subject: [PATCH] nm.c elf size support
Inspired by the following comment (from nm.c):
/* Sort the symbols by size. We guess the size by assuming that the
difference between the address of a symbol and the address of the
next higher symbol is the size. FIXME: ELF actually stores a size
with each symbol. We should use it. */
I wrote the attached patch. When using the patch, nm(1) reports the same
symbol size as readelf(1) and objdump(1) do.
I'm afraid that including elf-bfd.h it might not be the best option. Also,
if the goto is a problem I can change it.
Elias
2002-6-3 Elias Athanasopoulos <eathan@otenet.gr>
* nm.c: support symbol size of the elf target.
--- nm.c.orig Thu May 16 18:18:33 2002
+++ nm.c Mon Jun 3 21:30:45 2002
@@ -28,6 +28,7 @@
#include "aout/ranlib.h"
#include "demangle.h"
#include "libiberty.h"
+#include "elf-bfd.h"
/* When sorting by size, we use this structure to hold the size and a
pointer to the minisymbol. */
@@ -841,8 +842,8 @@
/* Sort the symbols by size. We guess the size by assuming that the
difference between the address of a symbol and the address of the
- next higher symbol is the size. FIXME: ELF actually stores a size
- with each symbol. We should use it. */
+ next higher symbol is the size. ELF actually stores a size
+ with each symbol. We use that. */
static long
sort_symbols_by_size (abfd, dynamic, minisyms, symcount, size, symsizesp)
@@ -902,6 +903,12 @@
else
next = NULL;
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
+ {
+ sz = ((elf_symbol_type *) sym)->internal_elf_sym.st_size;
+ goto skip_counting;
+ }
+
sec = bfd_get_section (sym);
if (bfd_is_com_section (sec))
@@ -917,6 +924,7 @@
- valueof (sym));
}
+ skip_counting:
if (sz != 0)
{
symsizes->minisym = (const PTR) from;