Y From:	CRDGW2::CRDGW2::MRGATE::"SMTP::PREP.AI.MIT.EDU::INFO-G++-REQUEST" 21-OCT-1989 19:51  To:	MRGATE::"ARISIA::EVERHART"6 Subj:	Re: Please describe how to use g++/gdb with COFF  R Received: by life.ai.mit.edu (4.0/AI-4.10) id AA07106; Sat, 21 Oct 89 17:21:41 EDT Return-Path: <rfg@ics.uci.edu>c Received: from ICS.UCI.EDU by life.ai.mit.edu (4.0/AI-4.10) id AA07093; Sat, 21 Oct 89 17:20:48 EDT % Date:     Sat, 21 Oct 89 14:15:01 PDT  From: rfg@ics.uci.edu : Subject:  Re: Please describe how to use g++/gdb with COFF To: info-g++@prep.ai.mit.edu- Message-Id:  <8910211415.aa19148@ICS.UCI.EDU>   = In a recent posting, rjk@sequent.UUCP (Robert Kelley) writes:   J >I know that there are several approaches for using g++ and gdb with COFF.J >One could modify g++ to generate assembler directives suitable for a COFFI >assembler.  One could translate assembler directives from a.out style to I >COFF style.  One could translate object files from a.out to COFF.  There K >are probably many other approaches.  The ones that I would consider viable 9 >would retain the ability to debug g++ programs with gdb.  > N >I would like to hear about any work in this area.  Discussion of the relativeM >advantages and disadvantages of each approach would be particularly welcome.   L Actually, there appear to be two primary means of targeting the G++ compilerE to a COFF based system, and zero (implemented) ways of getting gdb to P fully understand the resulting executable files (but I may be wrong about this).   The "AT&T linker" Approach --------------------------K As far a G++ targeting for COFF, I implemented one (simple?) method about a I year ago.  When I was working on the problem, I was targeting for NS32xxx F processor.  At that time, there was no implementation of either GAS orE GNU ld available for the NS32xxx processors.  Thus, in order to avoid J having to port these tools myself, I decided to use the "native" assemblerL and linker (if possible).  This is exactly the way most ports of GCC startedD life, i.e. most GCC ports started out assuming the use of a "native" assembler and linker.   K Because there was already a set of GCC configurations files for the NS32xxx H processors (developed by Michael Tiemann, with minor patches specific toF NSC's Genix OS added by me) the first cut of the G++ port was easy and> (mostly) worked well.  There was one important gotcha however.  I The "gotcha" was that my global objects were not being constructed before G "main()" was called.  Likewise, these objects were not being destructed  upon program exit.  D I managed to figure out exactly why this problem occured, and I alsoD managed to trick my (standard AT&T style) COFF linker into doing theC tricky things that needed to be done to get the global constructors D and destructor to execute.  I (and others) have since managed to useA the exact same techniques to get other standard AT&T COFF linkers C (on several other machines and architectures) to do the same magic.   H Ron Cole (cvms!ronald@ucdavis.edu) has been distributing and maintainingB my patches (for the "AT&T linker" approach) for some time now.  HeD currently has complete patch kits for several recent versions of G++E (up to 1.35.1).  I am now trying to bring up G++ 1.36.0- on the iPSC2 C (aka Intel HyperCube) using this "AT&T linker" approach, and I will E gladly make the revised patch set available as soon as they appear to  be working.   H For more technical details regarding this approach, get the patches fromF Ron Cole (or via ananymous FTP from cindy.csuchico.edu in the ~ftp/pubF directory) and read the file README.COFF (contained in the patch kit).   The "GNU Linker" Approach  ------------------------- M A very different means of getting g++ up on COFF systems has been implemented M primarily by Dirk Grunwald (grunwald@cs.colorado.edu).  I appologize if there I were other people (in particular, MDT) who also worked on this, and who I D have failed to give proper credit to.  In any case, the "GNU Linker"F approach is prefered by Michael Tiemann and by the FSF because it usesH fewer non-free software tools.  This approach relies on a program calledE "collect" which does some of the magic which the standard linker does L in the "AT&T Linker" approach.  It also requires the GNU assembler (aka GAS)K which creates only a.out style object files.  Finally, this approach relies M on another program called "robotussin" (aka COFF medicine) which does a thing I called COFF ENCAPSULATION.  This turns a.out style object files into COFF N object files.  I cannot comment in too much detail on this approach because...G well... I have never really used it.  Perhaps Dirk will give us a short  overview here.    
 Pro's & Con's 
 ------------- D Fow awhile there, Dirk, and Ron Cole, and I and (to a lesser extent)E Michael Tiemann were arguing back and forth in these newsgroups about B which method is better.  I believe that this discussion ultimatelyE disintegrated into a "tastes great... less filling... tastes great... F less filling...." type of argument.  Nobody was being convinced of theD validity of anybody else's point of view, so I (for one) decided not to bother anymore.  K Now, I would like to just make the point that (believe it or not) different F people have different needs.  Some people want a total GNU environmentG and they are willing to do all the porting work necessary to get there. I Other people just want to bring up g++ (on their COFF based systems) with C a minimum of muss and fuss.  Both sets of needs are valid and, IMHO ) both sets of needs should be accomodated.   K As far as pros and cons of each approach, well, I feel that the AT&T Linker E approach can be ported more easily (actually quite trivially) to most M standard COFF based systems (there are one or two exceptions where individual I manufacturers have strayed from the path of the one true COFF).  I'm sure I that Dirk will disagree with my statement, and claim that collect is more I portable.  If you have time, I suggest that you try both (and report your  results here of course).  K Regarding support, Dirk G., Michael Tiemann, and the FSF are supporting the E GNU linker approach.  Ron Cole is trying his best to make the patches C for the AT&T linker approach available to all who want them.  Since E Michael Tiemann has technical reservations about this approach, he is D naturally unwilling to fully embrace the patches which implement it.  F Since it seems unlikely that MDT will incorporate these patches (ever)H Ron Cole may get tired of hasseling with them at some point in time, andH may decide to kiss it off.  Thus, if you are worried about the very long5 haul, I suggest that you use the GNU linker approach.   I If, on the other hand, you want a quick (and not so dirty) implementation M of G++ on your (standard) COFF system, I suggest that you try the AT&T Linker  route.  A One final point.  The last time I heard, the GNU linker could not G yet deal with COFF shared libraries.  If you need to use such libraries @ in your G++ programs, perhaps you had better use an AT&T linker.  
 GDB Debugging 
 ------------- H Regarding the use of GDB on a COFF system for symbolically debugging G++H programs, if you can find anybody who has implemented this, I would veryG much like to hear about it!!!!  As far as I know, this has simply never  been implemented yet.    // rfg