Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ctrsol!lll-winken!pacbell!indetech!lrs From: lrs@indetech.com (Lynn Slater) Newsgroups: gnu.g++ Subject: Re: Please describe how to use g++/gdb with COFF Message-ID: <1989Oct23.154711.20935@indetech.com> Date: 23 Oct 89 15:47:11 GMT References: <8910212151.AA26599@lurch.Stanford.EDU> <20941.625010978@ics.uci.edu> <13058@boulder.Colorado.EDU> Reply-To: lrs@indetech.UUCP (Lynn Slater) Distribution: gnu Organization: Independence Technologies, Inc. Fremont, CA Lines: 187 > btw, collect.c was recently modified - someone is trying to get it work > on the 386i -- if anyone else has gotten this to work, please mail me Here are the patches I use to get collect to run on the sun4/os4. I suspect that they would apply universally. Notes: You must also edit Makefile to make collect and to install it as ?/lib/gcc-collect. You will probably have to edit yoru machines tm.h to define ASM_INT_OP. As a rule of thumb, I would suggest placing it right after the #define of DATA_SECTION_ASM_OP and make it output the same thing as used by ASM_OUTPUT_INT. I.e. If your machine in ASM_OUTPUT_INT uses "\t.word", then #define ASM_INT_OP ".word" I have printf statements in collect.c that should not remain in the ultimate system. However, they are good for peace of mind. These changes seem to work on the sun4 and on the pyramid. Why use this? Only use this if you really want to use the system supplied loader. Reasons: A. gnu ld is not available on your machine B. your machine ld has some quark not exactly matched by gnu ld but significant to the non c++ libraries you load in. C. You fiddle with shared memory in a way gnu ld does not yet handle. diff -c g++-configured ~/dist/g++-1.36.0 diff -c g++-configured/collect.c /home/lrs/dist/g++-1.36.0/collect.c *** g++-configured/collect.c Mon Oct 23 08:35:02 1989 --- /home/lrs/dist/g++-1.36.0/collect.c Thu Oct 12 08:47:23 1989 *************** *** 74,80 **** #ifndef ASM_OUTPUT_LABELREF_AS_INT #define ASM_OUTPUT_LABELREF_AS_INT(FILE,NAME) \ ! (fprintf(FILE,"\t%s ", ASM_INT_OP), \ ASM_OUTPUT_LABELREF(FILE,NAME), \ fprintf(FILE,"\n")) #endif --- 74,80 ---- #ifndef ASM_OUTPUT_LABELREF_AS_INT #define ASM_OUTPUT_LABELREF_AS_INT(FILE,NAME) \ ! (fprintf(FILE,"\t%s", ASM_INT_OP), \ ASM_OUTPUT_LABELREF(FILE,NAME), \ fprintf(FILE,"\n")) #endif *************** *** 280,286 **** exists = 0; while (p) { ! if (strcmp( symbol_name+1, p -> name ) == 0 ) { exists = 1; break; } --- 280,286 ---- exists = 0; while (p) { ! if (strcmp( symbol_name, p -> name ) == 0 ) { exists = 1; break; } *************** *** 298,310 **** if ( is_ctor ) { new -> next = ctor_chain; - printf(" Will call constructor %s\n", symbol_name); ctor_chain = new; ctor_chain_length++; } else { new->next = dtor_chain; - printf(" Will call destructor %s\n", symbol_name); dtor_chain = new; dtor_chain_length++; } --- 298,308 ---- diff -c g++-configured/gcc.c /home/lrs/dist/g++-1.36.0/gcc.c *** g++-configured/gcc.c Mon Oct 23 08:35:00 1989 --- /home/lrs/dist/g++-1.36.0/gcc.c Mon Oct 16 17:56:38 1989 *************** *** 1,13 **** - /* -*- Mode: C; C-Style: C++ -*- - * gcc.c -- distributed copy modified to better use collect - * - * AFSID : $__Header$ - * Created On : Wed Oct 18 16:43:24 1989 - * Last Modified By: Lynn Slater - * Last Modified On: Mon Oct 23 08:35:00 1989 - * Update Count : 5 - */ - /* Compiler driver program that can handle many languages. Copyright (C) 1987,1989 Free Software Foundation, Inc. --- 1,3 ---- *************** *** 308,334 **** }; #ifdef USE_COLLECT ! /* Here is the spec for running the linker, BEFORE doing a collect. ! No entry point is specified and no crt0 file is specified ! */ ! char *link_spec = "%{!c:%{!M*:%{!E:%{!S:ld -r -o %g.R \ ! %{A} %{d} %{e*} %{N} %{n} %{r} %{s} %{S} %{T*} %{t} %{u*} %{X} %{x} %{z}\ ! %{y*} \ ! %{L*} %o %{!nostdlib:-lg++}\n\ ! }}}}"; ! ! /* C++: Here is the spec for "collect"ing global ctor and dtor requirements. ! and then running a master load of everything. ! */ char *collect_spec = "%{!c:%{!M*:%{!E:%{!S:collect -o %g.S %g.R\n\ as %g.S -o %g.O\n\ ! ld %{o*} %l\ ! %{A} %{d} %{e*} %{N} %{n} %{r} %{s} %{S} %{T*} %{t} %{u*} %{X} %{x} %{z}\ ! %{y*} %{!nostdlib:%S} %g.R %g.O\ ! %{L*} %{!nostdlib:-lg++ gnulib%s %{g:-lg} %L}\n\ }}}}"; #else /* Here is the spec for running the linker, after compiling all files. */ char *link_spec = "%{!c:%{!M*:%{!E:%{!S:ld %{o*} %l\ --- 298,316 ---- }; #ifdef USE_COLLECT ! /* C++: Here is the spec for collecting global ctor and dtor ! requirements. */ char *collect_spec = "%{!c:%{!M*:%{!E:%{!S:collect -o %g.S %g.R\n\ as %g.S -o %g.O\n\ ! ld %{o*} %g.R %g.O\n\ }}}}"; + /* Here is the spec for running the linker, after compiling all files. */ + char *link_spec = "%{!c:%{!M*:%{!E:%{!S:ld -r -o %g.R %l\ + %{A} %{d} %{e*} %{N} %{n} %{r} %{s} %{S} %{T*} %{t} %{u*} %{X} %{x} %{z}\ + %{y*} %{!nostdlib:%S} \ + %{L*} %o %{!nostdlib:-lg++ gnulib%s %{g:-lg} %L}\n }}}}"; #else /* Here is the spec for running the linker, after compiling all files. */ char *link_spec = "%{!c:%{!M*:%{!E:%{!S:ld %{o*} %l\ *************** *** 1831,1842 **** { int tmp = execution_count; - value = do_spec (link_spec); - if (value < 0) - error_count = 1; - linker_was_run = (tmp != execution_count); - } - #ifdef USE_COLLECT /* C++: now collect all the requirements for calling global constructors and destructors, --- 1813,1818 ---- *************** *** 1851,1856 **** --- 1827,1838 ---- linker_was_run &= (tmp != execution_count); } #endif + value = do_spec (link_spec); + if (value < 0) + error_count = 1; + linker_was_run = (tmp != execution_count); + } + /* If options said don't run linker, complain about input files to be given to the linker. */ -- Thanks for all the good work, -- Lynn -- =============================================================== Lynn Slater -- lrs@indetech.com or {sun, ames, pacbell}!indetech!lrs 42075 Lawrence Place, Fremont Ca 94538 Office (415) 438-2048; Home (415) 796-4149; Fax (415) 438-2034