diff options
Diffstat (limited to 'gnu/usr.bin/ld/warnings.c')
-rw-r--r-- | gnu/usr.bin/ld/warnings.c | 68 |
1 files changed, 52 insertions, 16 deletions
diff --git a/gnu/usr.bin/ld/warnings.c b/gnu/usr.bin/ld/warnings.c index 0479344..3c65a22 100644 --- a/gnu/usr.bin/ld/warnings.c +++ b/gnu/usr.bin/ld/warnings.c @@ -1,5 +1,5 @@ /* - * $Id: warnings.c,v 1.8 1994/06/15 22:40:00 rich Exp $ + * $Id: warnings.c,v 1.9 1994/12/23 22:30:57 nate Exp $ */ #include <sys/param.h> @@ -25,6 +25,8 @@ #include "ld.h" +static int reported_undefineds; + /* * Print the filename of ENTRY on OUTFILE (a stdio stream), * and then a newline. @@ -101,18 +103,21 @@ print_symbols(outfile) fprintf(outfile, "\nGlobal symbols:\n\n"); FOR_EACH_SYMBOL(i, sp) { - if (sp->defined == (N_UNDF|N_EXT)) - fprintf(outfile, " %s: common, length %#x\n", - sp->name, sp->common_size); + fprintf(outfile, " %s: ", sp->name); if (!(sp->flags & GS_REFERENCED)) - fprintf(outfile, " %s: unreferenced\n", sp->name); + fprintf(outfile, "unreferenced"); else if (sp->so_defined) - fprintf(outfile, " %s: sodefined\n", sp->name); + fprintf(outfile, "sodefined"); else if (!sp->defined) - fprintf(outfile, " %s: undefined\n", sp->name); + fprintf(outfile, "undefined"); + else if (sp->defined == (N_UNDF|N_EXT)) + fprintf(outfile, "common: size %#x", sp->common_size); else - fprintf(outfile, " %s: %#x, size %#x\n", - sp->name, sp->value, sp->size); + fprintf(outfile, "type %d, value %#x, size %#x", + sp->defined, sp->value, sp->size); + if (sp->alias) + fprintf(outfile, ", aliased to %s", sp->alias->name); + fprintf(outfile, "\n"); } END_EACH_SYMBOL; each_file(list_file_locals, (void *)outfile); @@ -463,10 +468,11 @@ do_relocation_warnings(entry, data_segment, outfile, nlist_bitvector) /* Mark as being noted by relocation warning pass. */ SET_BIT(nlist_bitvector, lsp - start_of_syms); + if (g->undef_refs == 0) + reported_undefineds++; if (g->undef_refs >= MAX_UREFS_PRINTED) /* Listed too many */ continue; - /* Undefined symbol which we should mention */ if (++(g->undef_refs) == MAX_UREFS_PRINTED) { @@ -632,10 +638,28 @@ do_file_warnings (entry, outfile) line_number = -1; break; - default: -warnx("Unexpected multiple definitions of symbol `%s', type %#x\n", g->name, np->n_type); + case N_SIZE | N_EXT: + errfmt = + "Size element definition of symbol `%s' (multiply defined)"; + line_number = -1; + break; + + case N_INDR | N_EXT: + errfmt = + "Alias definition of symbol `%s' (multiply defined)"; + line_number = -1; + break; + + case N_UNDF | N_EXT: /* Don't print out multiple defs at references.*/ continue; + + default: + warnx("%s: unexpected multiple definitions " + "of symbol `%s', type %#x", + get_file_name(entry), + g->name, np->n_type); + break; } } else if (BIT_SET_P(nlist_bitvector, i)) { @@ -643,9 +667,10 @@ warnx("Unexpected multiple definitions of symbol `%s', type %#x\n", g->name, np- } else if (list_unresolved_refs && !g->defined && !g->so_defined) { + if (g->undef_refs == 0) + reported_undefineds++; if (g->undef_refs >= MAX_UREFS_PRINTED) continue; - if (++(g->undef_refs) == MAX_UREFS_PRINTED) errfmt = "More undefined `%s' refs follow"; else @@ -656,7 +681,7 @@ warnx("Unexpected multiple definitions of symbol `%s', type %#x\n", g->name, np- g->def_lsp->entry->flags & E_SECONDCLASS) { fprintf(outfile, "%s: Undefined symbol `%s' referenced (use %s ?)\n", - entry->filename, + get_file_name(entry), g->name, g->def_lsp->entry->local_sym_name); continue; @@ -678,7 +703,7 @@ warnx("Unexpected multiple definitions of symbol `%s', type %#x\n", g->name, np- continue; if (line_number == -1) - fprintf(outfile, "%s: ", entry->filename); + fprintf(outfile, "%s: ", get_file_name(entry)); else fprintf(outfile, "%s:%d: ", file_name, line_number); @@ -698,8 +723,11 @@ int do_warnings(outfile) FILE *outfile; { + list_unresolved_refs = !relocatable_output && - (undefined_global_sym_count || undefined_shobj_sym_count); + ( (undefined_global_sym_count - undefined_weak_sym_count) > 0 + || undefined_shobj_sym_count + ); list_multiple_defs = multiple_def_count != 0; if (!(list_unresolved_refs || @@ -714,6 +742,14 @@ do_warnings(outfile) each_file(do_file_warnings, (void *)outfile); + if (list_unresolved_refs && + reported_undefineds != + (undefined_global_sym_count - undefined_weak_sym_count)) + warnx("Spurious undefined symbols: " + "# undefined symbols %d, reported %d", + (undefined_global_sym_count - undefined_weak_sym_count), + reported_undefineds); + if (list_unresolved_refs || list_multiple_defs) return 0; |