From 96cc09a0c4dce4f5221efe9052b4553a4c8a6bc6 Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Wed, 24 Jun 1992 20:58:17 +0000 Subject: [PATCH] * nm.c (valueof macro): Add missing parentheses. (Their lack screwed up numeric_forward().) --- binutils/ChangeLog | 5 +++++ binutils/nm.c | 46 ++++++++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 1002bd06818..06e21240db6 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +Wed Jun 24 13:48:07 1992 Per Bothner (bothner@cygnus.com) + + * nm.c (valueof macro): Add missing parentheses. + (Their lack screwed up numeric_forward().) + Sun Jun 14 10:33:27 1992 John Gilmore (gnu at cygnus.com) * objdump.c (dump_elf_stabs): Also dump .stab.index and diff --git a/binutils/nm.c b/binutils/nm.c index e6ab17f66e9..7a7dea9daf6 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -55,16 +55,16 @@ extern char *program_version; extern char *target; struct option long_options[] = { - {"debug-syms", 0, &print_debug_syms, 1}, - {"extern-only", 0, &external_only, 1}, - {"no-sort", 0, &no_sort, 1}, - {"numeric-sort", 0, &sort_numerically, 1}, - {"print-armap", 0, &print_armap, 1}, - {"print-file-name", 0, &file_on_each_line, 1}, - {"reverse-sort", 0, &reverse_sort, 1}, - {"target", 2, (int *)NULL, 0}, - {"undefined-only", 0, &undefined_only, 1}, - {0, 0, 0, 0} + {"debug-syms", no_argument, &print_debug_syms, 1}, + {"extern-only", no_argument, &external_only, 1}, + {"no-sort", no_argument, &no_sort, 1}, + {"numeric-sort", no_argument, &sort_numerically, 1}, + {"print-armap", no_argument, &print_armap, 1}, + {"print-file-name", no_argument, &file_on_each_line, 1}, + {"reverse-sort", no_argument, &reverse_sort, 1}, + {"target", optional_argument, (int *)NULL, 0}, + {"undefined-only", no_argument, &undefined_only, 1}, + {0, no_argument, 0, 0} }; int show_names = 0; @@ -85,14 +85,13 @@ main (argc, argv) char **argv; { int c; /* sez which option char */ - int ind = 0; /* used by getopt and ignored by us */ - extern int optind; /* steps thru options */ + int option_index = 0; /* used by getopt and ignored by us */ int retval; program_name = *argv; bfd_init(); - while ((c = getopt_long(argc, argv, "agnoprsu", long_options, &ind)) != EOF) { + while ((c = getopt_long(argc, argv, "agnoprsu", long_options, &option_index)) != EOF) { switch (c) { case 'a': print_debug_syms = 1; break; case 'g': external_only = 1; break; @@ -119,7 +118,7 @@ main (argc, argv) on sucess -- the inverse of the C sense. */ /* OK, all options now parsed. If no filename specified, do a.out. */ - if (optind == argc) return !display_file ("a.out"); + if (option_index == argc) return !display_file ("a.out"); retval = 0; show_names = (argc -optind)>1; @@ -248,7 +247,7 @@ do_one_rel_file (abfd) } /* Symbol-sorting predicates */ -#define valueof(x) (x)->section->vma + (x)->value +#define valueof(x) ((x)->section->vma + (x)->value) int numeric_forward (x, y) char *x; @@ -304,16 +303,23 @@ filter_symbols (abfd, syms, symcount) { asymbol **from, **to; unsigned int dst_count = 0; + asymbol *sym; + unsigned int src_count; for (from = to = syms, src_count = 0; src_count flags; + + + flagword flags = (from[src_count])->flags; + sym = from[src_count]; if (undefined_only) { - keep = (flags & BSF_UNDEFINED); + keep = sym->section == &bfd_und_section; } else if (external_only) { - keep = ((flags & BSF_GLOBAL) || (flags & BSF_UNDEFINED) || - (flags & BSF_FORT_COMM)); + keep = ((flags & BSF_GLOBAL) + || (sym->section == &bfd_und_section) + || (sym->section == &bfd_com_section)); + } else { keep = 1; } @@ -342,7 +348,7 @@ print_symbols (abfd, syms, symcount) if (file_on_each_line) printf("%s:", bfd_get_filename(abfd)); if (undefined_only) { - if ((*sym)->flags & BSF_UNDEFINED) + if ((*sym)->section == &bfd_und_section) puts ((*sym)->name); } else { -- 2.30.2