abrossard@watcgl.waterloo.edu (Alain Brossard) (10/18/88)
Gcc when given the -gg flag inserts an incomplete definition into the symbol table when an external variable is declared but not used as in the file second.c. Gld then finds an undefined external but fails to print the name of the symbol or even to say that it found an undefined external before exiting without generating the .out file. Gcc is compiled to generate code for the 68000, but executes on a vax. This should have no effect on the problem at hand. Script started on Mon Oct 17 17:19:30 1988 cgl$ more main.c void main() { sub(); } cgl$ more second.c void sub() { extern char *_Gen_host_init; } cgl$ alias gcc68 gcc68 -c -v -gg cgl$ gcc68 main.c gcc version 1.29 /usr/watcgl/lib/m68k_gnu/gcpp -v -undef -D__GNU__ -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__HAVE_68881__ -Dmc68020 main.c /tmp/cc000888.cpp GNU CPP version 1.29 /usr/watcgl/lib/m68k_gnu/gcc168 /tmp/cc000888.cpp -quiet -dumpbase main.c -version -symout /tmp/cc000888.sym -o /tmp/cc000888.s GNU C version 1.29 (68k, MIT syntax) compiled by CC. /usr/watcgl/bin/m68k_gnu/gas68 -mc68020 -G /tmp/cc000888.sym /tmp/cc000888.s -o main.b cgl$ gcc68 second.c gcc version 1.29 /usr/watcgl/lib/m68k_gnu/gcpp -v -undef -D__GNU__ -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__HAVE_68881__ -Dmc68020 second.c /tmp/cc000892.cpp GNU CPP version 1.29 /usr/watcgl/lib/m68k_gnu/gcc168 /tmp/cc000892.cpp -quiet -dumpbase second.c -version -symout /tmp/cc000892.sym -o /tmp/cc000892.s GNU C version 1.29 (68k, MIT syntax) compiled by CC. /usr/watcgl/bin/m68k_gnu/gas68 -mc68020 -G /tmp/cc000892.sym /tmp/cc000892.s -o second.b cgl$ gld68 main.b second.b List of undefined was incomplete, complete list: __Gen_host_init: undefined cgl$ script done on Mon Oct 17 17:21:55 1988 The error message from gld68 was gotten by modifying it in the following way: In function list_undefined_symbols(), after the calls to list_unresolved_references(), I check to make sure they all have been printed: === if( undefined_global_sym_count ) { /* not all undefined listed */ fprintf( outfile, "List of undefined was incomplete, complete list:\n"); for (i = 0; i < TABSIZE; i++) { register symbol *sp; for (sp = symtab[i]; sp; sp = sp->link) { if (!sp->defined && sp->referenced) fprintf (outfile, " %s: undefined\n", sp->name); } } } === This little piece of code does print all the undefined symbols. In list_unresolved_references(), I added the following 2 lines: === address_to_line (txt_reloc->r_address + entry->text_start_address, state_pointer); + if( g->undef_refs == 0 ) undefined_global_sym_count--; g->undef_refs++; === ... === address_to_line (data_reloc->r_address + entry->data_start_address, state_pointer); + if( g->undef_refs == 0 ) undefined_global_sym_count--; if (current->line >= 0) === The line numbers have been removed since they wouldn't correspond to the released version (we are cross-compiling on a vax for a 68020). I couldn't find a version for gld, but it is a fairly recent version with a copyright of 1988. The older version (1.21.0) that we used until recently, used the above mentioned for loop to print the list of undefined symbols and as such wasn't a problem, it is only the new one using the routine list_unresolved_references() which is failing. Alain Brossard vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv Alain Brossard, CS Dept., U. Waterloo, Waterloo, Ontario, Canada N2L 3G1 INTERNET:abrossard@watcgl.uwaterloo.ca INTERNET:abrossard@watcgl.waterloo.edu UUCP :uunet!watmath!watcgl!abrossard EAN :abrossard@cgl.waterloo.cdn