struct size_sym
{
- const PTR minisym;
+ const void *minisym;
bfd_vma size;
};
#define SYM_SIZE(sym) \
(sym->elfinfo ? sym->elfinfo->internal_elf_sym.st_size: sym->ssize)
-static void usage
- PARAMS ((FILE *, int));
-static void set_print_radix
- PARAMS ((char *));
-static void set_output_format
- PARAMS ((char *));
-static void display_archive
- PARAMS ((bfd *));
-static bfd_boolean display_file
- PARAMS ((char *));
-static void display_rel_file
- PARAMS ((bfd *, bfd *));
-static long filter_symbols
- PARAMS ((bfd *, bfd_boolean, PTR, long, unsigned int));
+static void usage (FILE *, int);
+static void set_print_radix (char *);
+static void set_output_format (char *);
+static void display_archive (bfd *);
+static bfd_boolean display_file (char *);
+static void display_rel_file (bfd *, bfd *);
+static long filter_symbols (bfd *, bfd_boolean, void *, long, unsigned int);
static long sort_symbols_by_size
- PARAMS ((bfd *, bfd_boolean, PTR, long, unsigned int, struct size_sym **));
+ (bfd *, bfd_boolean, void *, long, unsigned int, struct size_sym **);
static void print_symbols
- PARAMS ((bfd *, bfd_boolean, PTR, long, unsigned int, bfd *));
+ (bfd *, bfd_boolean, void *, long, unsigned int, bfd *);
static void print_size_symbols
- PARAMS ((bfd *, bfd_boolean, struct size_sym *, long, bfd *));
-static void print_symname
- PARAMS ((const char *, const char *, bfd *));
-static void print_symbol
- PARAMS ((bfd *, asymbol *, bfd_vma ssize, bfd *));
-static void print_symdef_entry
- PARAMS ((bfd *));
+ (bfd *, bfd_boolean, struct size_sym *, long, bfd *);
+static void print_symname (const char *, const char *, bfd *);
+static void print_symbol (bfd *, asymbol *, bfd_vma ssize, bfd *);
+static void print_symdef_entry (bfd *);
/* The sorting functions. */
-static int numeric_forward
- PARAMS ((const PTR, const PTR));
-static int numeric_reverse
- PARAMS ((const PTR, const PTR));
-static int non_numeric_forward
- PARAMS ((const PTR, const PTR));
-static int non_numeric_reverse
- PARAMS ((const PTR, const PTR));
-static int size_forward1
- PARAMS ((const PTR, const PTR));
-static int size_forward2
- PARAMS ((const PTR, const PTR));
+static int numeric_forward (const void *, const void *);
+static int numeric_reverse (const void *, const void *);
+static int non_numeric_forward (const void *, const void *);
+static int non_numeric_reverse (const void *, const void *);
+static int size_forward1 (const void *, const void *);
+static int size_forward2 (const void *, const void *);
/* The output formatting functions. */
-static void print_object_filename_bsd
- PARAMS ((char *));
-static void print_object_filename_sysv
- PARAMS ((char *));
-static void print_object_filename_posix
- PARAMS ((char *));
-static void print_archive_filename_bsd
- PARAMS ((char *));
-static void print_archive_filename_sysv
- PARAMS ((char *));
-static void print_archive_filename_posix
- PARAMS ((char *));
-static void print_archive_member_bsd
- PARAMS ((char *, const char *));
-static void print_archive_member_sysv
- PARAMS ((char *, const char *));
-static void print_archive_member_posix
- PARAMS ((char *, const char *));
-static void print_symbol_filename_bsd
- PARAMS ((bfd *, bfd *));
-static void print_symbol_filename_sysv
- PARAMS ((bfd *, bfd *));
-static void print_symbol_filename_posix
- PARAMS ((bfd *, bfd *));
-static void print_value
- PARAMS ((bfd *, bfd_vma));
-static void print_symbol_info_bsd
- PARAMS ((struct extended_symbol_info *, bfd *));
-static void print_symbol_info_sysv
- PARAMS ((struct extended_symbol_info *, bfd *));
-static void print_symbol_info_posix
- PARAMS ((struct extended_symbol_info *, bfd *));
-static void get_relocs
- PARAMS ((bfd *, asection *, PTR));
-static const char * get_symbol_type
- PARAMS ((unsigned int));
+static void print_object_filename_bsd (char *);
+static void print_object_filename_sysv (char *);
+static void print_object_filename_posix (char *);
+static void print_archive_filename_bsd (char *);
+static void print_archive_filename_sysv (char *);
+static void print_archive_filename_posix (char *);
+static void print_archive_member_bsd (char *, const char *);
+static void print_archive_member_sysv (char *, const char *);
+static void print_archive_member_posix (char *, const char *);
+static void print_symbol_filename_bsd (bfd *, bfd *);
+static void print_symbol_filename_sysv (bfd *, bfd *);
+static void print_symbol_filename_posix (bfd *, bfd *);
+static void print_value (bfd *, bfd_vma);
+static void print_symbol_info_bsd (struct extended_symbol_info *, bfd *);
+static void print_symbol_info_sysv (struct extended_symbol_info *, bfd *);
+static void print_symbol_info_posix (struct extended_symbol_info *, bfd *);
+static void get_relocs (bfd *, asection *, void *);
+static const char * get_symbol_type (unsigned int);
/* Support for different output formats. */
struct output_fns
{
/* Print the name of an object file given on the command line. */
- void (*print_object_filename) PARAMS ((char *));
+ void (*print_object_filename) (char *);
/* Print the name of an archive file given on the command line. */
- void (*print_archive_filename) PARAMS ((char *));
+ void (*print_archive_filename) (char *);
/* Print the name of an archive member file. */
- void (*print_archive_member) PARAMS ((char *, const char *));
+ void (*print_archive_member) (char *, const char *);
/* Print the name of the file (and archive, if there is one)
containing a symbol. */
- void (*print_symbol_filename) PARAMS ((bfd *, bfd *));
+ void (*print_symbol_filename) (bfd *, bfd *);
/* Print a line of information about a symbol. */
- void (*print_symbol_info) PARAMS ((struct extended_symbol_info *, bfd *));
+ void (*print_symbol_info) (struct extended_symbol_info *, bfd *);
};
static struct output_fns formats[] =
/* Some error-reporting functions. */
static void
-usage (stream, status)
- FILE *stream;
- int status;
+usage (FILE *stream, int status)
{
fprintf (stream, _("Usage: %s [option(s)] [file(s)]\n"), program_name);
fprintf (stream, _(" List symbols in [file(s)] (a.out by default).\n"));
/* Set the radix for the symbol value and size according to RADIX. */
static void
-set_print_radix (radix)
- char *radix;
+set_print_radix (char *radix)
{
switch (*radix)
{
}
static void
-set_output_format (f)
- char *f;
+set_output_format (char *f)
{
int i;
format = &formats[i];
}
\f
-int main PARAMS ((int, char **));
+int main (int, char **);
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
int c;
int retval;
break;
case 'X':
/* Ignored for (partial) AIX compatibility. On AIX, the
- argument has values 32, 64, or 32_64, and specfies that
+ argument has values 32, 64, or 32_64, and specifies that
only 32-bit, only 64-bit, or both kinds of objects should
be examined. The default is 32. So plain AIX nm on a
library archive with both kinds of objects will ignore
if (show_version)
print_version ("nm");
+ if (sort_by_size && undefined_only)
+ {
+ non_fatal (_("Using the --size-sort and --undefined-only options together"));
+ non_fatal (_("will produce no output, since undefined symbols have no size."));
+ return 0;
+ }
+
/* OK, all options now parsed. If no filename specified, do a.out. */
if (optind == argc)
return !display_file ("a.out");
}
\f
static const char *
-get_symbol_type (type)
- unsigned int type;
+get_symbol_type (unsigned int type)
{
static char buff [32];
}
static void
-display_archive (file)
- bfd *file;
+display_archive (bfd *file)
{
bfd *arfile = NULL;
bfd *last_arfile = NULL;
}
static bfd_boolean
-display_file (filename)
- char *filename;
+display_file (char *filename)
{
bfd_boolean retval = TRUE;
bfd *file;
char **matching;
+ if (get_file_size (filename) < 1)
+ return FALSE;
+
file = bfd_openr (filename, target);
if (file == NULL)
{
specially -- i.e., their sizes are used as their "values". */
static int
-numeric_forward (P_x, P_y)
- const PTR P_x;
- const PTR P_y;
+numeric_forward (const void *P_x, const void *P_y)
{
asymbol *x, *y;
asection *xs, *ys;
}
static int
-numeric_reverse (x, y)
- const PTR x;
- const PTR y;
+numeric_reverse (const void *x, const void *y)
{
return - numeric_forward (x, y);
}
static int
-non_numeric_forward (P_x, P_y)
- const PTR P_x;
- const PTR P_y;
+non_numeric_forward (const void *P_x, const void *P_y)
{
asymbol *x, *y;
const char *xn, *yn;
}
static int
-non_numeric_reverse (x, y)
- const PTR x;
- const PTR y;
+non_numeric_reverse (const void *x, const void *y)
{
return - non_numeric_forward (x, y);
}
-static int (*(sorters[2][2])) PARAMS ((const PTR, const PTR)) =
+static int (*(sorters[2][2])) (const void *, const void *) =
{
{ non_numeric_forward, non_numeric_reverse },
{ numeric_forward, numeric_reverse }
value. */
static int
-size_forward1 (P_x, P_y)
- const PTR P_x;
- const PTR P_y;
+size_forward1 (const void *P_x, const void *P_y)
{
asymbol *x, *y;
asection *xs, *ys;
an array of size_sym structures into size order. */
static int
-size_forward2 (P_x, P_y)
- const PTR P_x;
- const PTR P_y;
+size_forward2 (const void *P_x, const void *P_y)
{
const struct size_sym *x = (const struct size_sym *) P_x;
const struct size_sym *y = (const struct size_sym *) P_y;
size. */
static long
-sort_symbols_by_size (abfd, dynamic, minisyms, symcount, size, symsizesp)
- bfd *abfd;
- bfd_boolean dynamic;
- PTR minisyms;
- long symcount;
- unsigned int size;
- struct size_sym **symsizesp;
+sort_symbols_by_size (bfd *abfd, bfd_boolean dynamic, void *minisyms,
+ long symcount, unsigned int size,
+ struct size_sym **symsizesp)
{
struct size_sym *symsizes;
bfd_byte *from, *fromend;
if (from < fromend)
{
- sym = bfd_minisymbol_to_symbol (abfd, dynamic, (const PTR) from,
+ sym = bfd_minisymbol_to_symbol (abfd, dynamic, (const void *) from,
store_sym);
if (sym == NULL)
bfd_fatal (bfd_get_filename (abfd));
{
next = bfd_minisymbol_to_symbol (abfd,
dynamic,
- (const PTR) (from + size),
+ (const void *) (from + size),
store_next);
if (next == NULL)
bfd_fatal (bfd_get_filename (abfd));
if (sz != 0)
{
- symsizes->minisym = (const PTR) from;
+ symsizes->minisym = (const void *) from;
symsizes->size = sz;
++symsizes;
}
symcount = symsizes - *symsizesp;
/* We must now sort again by size. */
- qsort ((PTR) *symsizesp, symcount, sizeof (struct size_sym), size_forward2);
+ qsort ((void *) *symsizesp, symcount, sizeof (struct size_sym), size_forward2);
return symcount;
}
/* If ARCHIVE_BFD is non-NULL, it is the archive containing ABFD. */
static void
-display_rel_file (abfd, archive_bfd)
- bfd *abfd;
- bfd *archive_bfd;
+display_rel_file (bfd *abfd, bfd *archive_bfd)
{
long symcount;
- PTR minisyms;
+ void *minisyms;
unsigned int size;
struct size_sym *symsizes;
Return the number of symbols to be printed. */
static long
-filter_symbols (abfd, dynamic, minisyms, symcount, size)
- bfd *abfd;
- bfd_boolean dynamic;
- PTR minisyms;
- long symcount;
- unsigned int size;
+filter_symbols (bfd *abfd, bfd_boolean dynamic, void *minisyms,
+ long symcount, unsigned int size)
{
bfd_byte *from, *fromend, *to;
asymbol *store;
PROGRESS (1);
- sym = bfd_minisymbol_to_symbol (abfd, dynamic, (const PTR) from, store);
+ sym = bfd_minisymbol_to_symbol (abfd, dynamic, (const void *) from, store);
if (sym == NULL)
bfd_fatal (bfd_get_filename (abfd));
demangling it if requested. */
static void
-print_symname (format, name, abfd)
- const char *format;
- const char *name;
- bfd *abfd;
+print_symname (const char *format, const char *name, bfd *abfd)
{
if (do_demangle && *name)
{
containing ABFD. */
static void
-print_symbols (abfd, dynamic, minisyms, symcount, size, archive_bfd)
- bfd *abfd;
- bfd_boolean dynamic;
- PTR minisyms;
- long symcount;
- unsigned int size;
- bfd *archive_bfd;
+print_symbols (bfd *abfd, bfd_boolean dynamic, void *minisyms, long symcount,
+ unsigned int size, bfd *archive_bfd)
{
asymbol *store;
bfd_byte *from, *fromend;
/* Print the symbols when sorting by size. */
static void
-print_size_symbols (abfd, dynamic, symsizes, symcount, archive_bfd)
- bfd *abfd;
- bfd_boolean dynamic;
- struct size_sym *symsizes;
- long symcount;
- bfd *archive_bfd;
+print_size_symbols (bfd *abfd, bfd_boolean dynamic,
+ struct size_sym *symsizes, long symcount,
+ bfd *archive_bfd)
{
asymbol *store;
struct size_sym *from, *fromend;
/* Print a single symbol. */
static void
-print_symbol (abfd, sym, ssize, archive_bfd)
- bfd *abfd;
- asymbol *sym;
- bfd_vma ssize;
- bfd *archive_bfd;
+print_symbol (bfd *abfd, asymbol *sym, bfd_vma ssize, bfd *archive_bfd)
{
+ symbol_info syminfo;
+ struct extended_symbol_info info;
+
PROGRESS (1);
(*format->print_symbol_filename) (archive_bfd, abfd);
- if (undefined_only)
- {
- if (bfd_is_und_section (bfd_get_section (sym)))
- print_symname ("%s", bfd_asymbol_name (sym), abfd);
- }
+ bfd_get_symbol_info (abfd, sym, &syminfo);
+ info.sinfo = &syminfo;
+ info.ssize = ssize;
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
+ info.elfinfo = (elf_symbol_type *) sym;
else
- {
- symbol_info syminfo;
- struct extended_symbol_info info;
-
- bfd_get_symbol_info (abfd, sym, &syminfo);
- info.sinfo = &syminfo;
- info.ssize = ssize;
- if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
- info.elfinfo = (elf_symbol_type *) sym;
- else
- info.elfinfo = NULL;
- (*format->print_symbol_info) (&info, abfd);
- }
+ info.elfinfo = NULL;
+ (*format->print_symbol_info) (&info, abfd);
if (line_numbers)
{
info.relocs = relocs;
info.relcount = relcount;
info.syms = syms;
- bfd_map_over_sections (abfd, get_relocs, (PTR) &info);
+ bfd_map_over_sections (abfd, get_relocs, (void *) &info);
lineno_cache_rel_bfd = abfd;
}
/* Print the name of an object file given on the command line. */
static void
-print_object_filename_bsd (filename)
- char *filename;
+print_object_filename_bsd (char *filename)
{
if (filename_per_file && !filename_per_symbol)
printf ("\n%s:\n", filename);
}
static void
-print_object_filename_sysv (filename)
- char *filename;
+print_object_filename_sysv (char *filename)
{
if (undefined_only)
printf (_("\n\nUndefined symbols from %s:\n\n"), filename);
}
static void
-print_object_filename_posix (filename)
- char *filename;
+print_object_filename_posix (char *filename)
{
if (filename_per_file && !filename_per_symbol)
printf ("%s:\n", filename);
/* Print the name of an archive file given on the command line. */
static void
-print_archive_filename_bsd (filename)
- char *filename;
+print_archive_filename_bsd (char *filename)
{
if (filename_per_file)
printf ("\n%s:\n", filename);
}
static void
-print_archive_filename_sysv (filename)
- char *filename ATTRIBUTE_UNUSED;
+print_archive_filename_sysv (char *filename ATTRIBUTE_UNUSED)
{
}
static void
-print_archive_filename_posix (filename)
- char *filename ATTRIBUTE_UNUSED;
+print_archive_filename_posix (char *filename ATTRIBUTE_UNUSED)
{
}
\f
/* Print the name of an archive member file. */
static void
-print_archive_member_bsd (archive, filename)
- char *archive ATTRIBUTE_UNUSED;
- const char *filename;
+print_archive_member_bsd (char *archive ATTRIBUTE_UNUSED,
+ const char *filename)
{
if (!filename_per_symbol)
printf ("\n%s:\n", filename);
}
static void
-print_archive_member_sysv (archive, filename)
- char *archive;
- const char *filename;
+print_archive_member_sysv (char *archive, const char *filename)
{
if (undefined_only)
printf (_("\n\nUndefined symbols from %s[%s]:\n\n"), archive, filename);
}
static void
-print_archive_member_posix (archive, filename)
- char *archive;
- const char *filename;
+print_archive_member_posix (char *archive, const char *filename)
{
if (!filename_per_symbol)
printf ("%s[%s]:\n", archive, filename);
containing a symbol. */
static void
-print_symbol_filename_bsd (archive_bfd, abfd)
- bfd *archive_bfd, *abfd;
+print_symbol_filename_bsd (bfd *archive_bfd, bfd *abfd)
{
if (filename_per_symbol)
{
}
static void
-print_symbol_filename_sysv (archive_bfd, abfd)
- bfd *archive_bfd, *abfd;
+print_symbol_filename_sysv (bfd *archive_bfd, bfd *abfd)
{
if (filename_per_symbol)
{
}
static void
-print_symbol_filename_posix (archive_bfd, abfd)
- bfd *archive_bfd, *abfd;
+print_symbol_filename_posix (bfd *archive_bfd, bfd *abfd)
{
if (filename_per_symbol)
{
/* Print a symbol value. */
static void
-print_value (abfd, val)
- bfd *abfd ATTRIBUTE_UNUSED;
- bfd_vma val;
+print_value (bfd *abfd ATTRIBUTE_UNUSED, bfd_vma val)
{
#if ! defined (BFD64) || BFD_HOST_64BIT_LONG
printf (value_format, val);
/* Print a line of information about a symbol. */
static void
-print_symbol_info_bsd (info, abfd)
- struct extended_symbol_info *info;
- bfd *abfd;
+print_symbol_info_bsd (struct extended_symbol_info *info, bfd *abfd)
{
if (bfd_is_undefined_symclass (SYM_TYPE (info)))
{
}
else
{
- print_value (abfd, SYM_VALUE (info));
+ /* Normally we print the value of the symbol. If we are printing the
+ size or sorting by size then we print its size, except for the
+ (weird) special case where both flags are defined, in which case we
+ print both values. This conforms to documented behaviour. */
+ 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))
{
- printf(" ");
+ printf (" ");
print_value (abfd, SYM_SIZE (info));
}
}
}
static void
-print_symbol_info_sysv (info, abfd)
- struct extended_symbol_info *info;
- bfd *abfd;
+print_symbol_info_sysv (struct extended_symbol_info *info, bfd *abfd)
{
print_symname ("%-20s|", SYM_NAME (info), abfd);
if (SYM_TYPE (info) == '-')
{
/* A stab. */
- printf ("%18s| ", SYM_STAB_NAME (info)); /* (C) Type */
- printf (desc_format, SYM_STAB_DESC (info)); /* Size */
- printf ("| |"); /* Line, Section */
+ printf ("%18s| ", SYM_STAB_NAME (info)); /* (C) Type. */
+ printf (desc_format, SYM_STAB_DESC (info)); /* Size. */
+ printf ("| |"); /* Line, Section. */
}
else
{
}
static void
-print_symbol_info_posix (info, abfd)
- struct extended_symbol_info *info;
- bfd *abfd;
+print_symbol_info_posix (struct extended_symbol_info *info, bfd *abfd)
{
print_symname ("%s ", SYM_NAME (info), abfd);
printf ("%c ", SYM_TYPE (info));
}
\f
static void
-print_symdef_entry (abfd)
- bfd *abfd;
+print_symdef_entry (bfd *abfd)
{
symindex idx = BFD_NO_MORE_SYMBOLS;
carsym *thesym;
It is called via bfd_map_over_sections. */
static void
-get_relocs (abfd, sec, dataarg)
- bfd *abfd;
- asection *sec;
- PTR dataarg;
+get_relocs (bfd *abfd, asection *sec, void *dataarg)
{
struct get_relocs_info *data = (struct get_relocs_info *) dataarg;