Y From:	CRDGW2::CRDGW2::MRGATE::"SMTP::PREP.AI.MIT.EDU::INFO-G++-REQUEST" 13-SEP-1989 01:05  To:	MRGATE::"ARISIA::EVERHART"5 Subj:	what and where are the COFF patches for GNU C++   R Received: by life.ai.mit.edu (4.1/AI-4.10) id AA09982; Tue, 12 Sep 89 17:06:42 EDT- Return-Path: <csusac!cvms!ronald@ucdavis.edu> k Received: from ucdavis.ucdavis.edu by life.ai.mit.edu (4.1/AI-4.10) id AA09845; Tue, 12 Sep 89 16:56:58 EDT / Received: by ucdavis.ucdavis.edu (5.51/UCD1.41) ( 	id AA00937; Tue, 12 Sep 89 13:52:04 PDT( Received: by csusac.csus.edu (4.12/5.17)( 	id AA16299; Tue, 12 Sep 89 15:40:39 edt! Date: Tue, 12 Sep 89 15:40:39 edt $ From: csusac!cvms!ronald@ucdavis.edu0 Message-Id: <8909121940.AA16299@csusac.csus.edu>7 To: csusac!ucdavis!prep.ai.mit.edu!info-g++@ucdavis.edu 8 Subject: what and where are the COFF patches for GNU C++  R In article <2559@ccncsu.ColoState.EDU> thorson@typhoon.atmos.colostate.edu writes:R >In article <299900002@uicsgva.csg.uiuc.edu> niermann@uicsgva.csg.uiuc.edu writes:B >>  I am trying to build g++-1.35.0 for an encore multimax ns3200.C >>While compiling newld.c I get a very large number of errors. The   >>first few are: >>  1 >>newld.c:613: field `header' has incomplete type  >>newld.c: In function main: >....Errors aplenty... >>Tom  >>niermann@bach.csg.uiuc.edu > & >I have the same problem on a Sun386i. > : >Even the errors are exactly the same as Tom listed in his	 >message.  > 0 >I've been trying to get this going all weekend. >  >WE NEED HELP!  F For this last year, I have been providing a set of patches for GNU C++I to better integrate with COFF tools.  Apparently, these patches are still G little known about.  Perhaps Michael Tiemann will see fit to mention in ? his next release that these are available from me and that I am  independently supporting them.  @ Patches starting from release 1.32.0 are available via anonymousA ftp from cindy.csuchico.edu [132.241.0.35].  In the pub directory ? find the "g++-coff" and "libg++-sysv" directories.  Under those 9 are the appropriate patches for the appropriate releases.   E Here is the latest README.COFF from the patches so you can decide for & yourself if these patches are for you.  F ---------------------------- cut here --------------------------------K This is the file README.COFF.  It contains notes on bringing up the GNU C++ M compiler (g++) to generate COFF format executables for UNIX System V and it's  COFFing cousins.  P The tricky part about getting GNU C++ running under System V is the need to haveN some agent which causes the initialization and finalization (i.e. constructionF and destruction) of all global static (i.e. file-level) class objects.  L The current implementation of g++ creates one routine per source/object fileL which will execute all of the constructors for all of the initialized globalK static class objects (if any such constructors are needed).  These per-file * super-constructors always have names like:   	_GLOBAL.I.sourcefilename_cc  J Likewise (if needed) G++ also creates one super-destructor per file with a
 name like:   	_GLOBAL.D.sourcefilename_cc  M At run-time, the crt1+.o routine must call each of the super-constructors for J each of the objects files of the whole program in turn.  It then must callL main().  Finally, it must call each of the super-destructors in turn.  (NoteI that the exit() library routine should also be setup to invoke all of the  super-destructors.)   K In order to do its job, crt1+.o must have two contiguous lists of addresses L which it can traverse.  One list is a list of addresses of all of the super-O constructors, the other is a list of addresses of all of the super-destructors.   O On BSD UNIX systems, these two lists (called __CTOR_LIST__ & __DTOR_LIST__) are M created by a modified form of the GNU linker called ld++.  Since ld++ assumes N that input files are in "a.out" object format and not in System V COFF format,1 this approach just doesn't port well to System V.   J Fortunately, as of System V Release 2 (and possibly even before), standardJ COFF linkers, accept so called "user-defined" sections, and they even haveJ a special language for directing "ld" as to what to do with such sections.  J Just like the familiar ".text", ".data", and ".bss" sections, these "user-I defined" sections allow one to cause otherwise unrelated chunks of object J "stuff" to be collected into one contiguous region of a process's run-time address space.  L Thus, on my system, I modified g++ to output ".section" assembler directivesL for two "user-defined" sections.  One called ".ctors" and another one calledL ".dtors".  For each source/object file, I also arranged for g++ to place oneK 32-bit address word into the ".ctors" section and another into the ".dtors" 1 section.  (Each of these is only done if needed).   K In each case, the single address placed in these sections is the address of I the super-constructor (or super-destructor) for the current source/object  file.   J At link time, my COFF linker places all of the ".ctors" address words intoN consecutive words in the output file.  Likewise, it places all of the ".dtors"M address words into a separate set of consecutive words.  Thus the two "super" + address lists are constructed at link-time.   J Note that for optimal results you should use a linker directives file that; contains something which looks somewhat like the following:   	 	SECTIONS  	{ 		.text <sizeof_headers>: 5 			{ *(.init) *(.text) *(.ctors) *(.dtors) *(.fini) } @ 		GROUP BIND(ADDR(.text) + SIZEOF(.text) + NEXT(<align_value>)): 			{ .data : { } .bss : { } }  	}  N This will force the .ctors and .dtors sections to be joined to the tail end ofK the .text section and placed in read-only memory in the linked output file. M (You probably don't even need the specifications of "*(.init)" and "*(.fini)" < in there, but if you are mixing languages, you may need it.)  M See your system's ld(1) man page and the linker section in the "Support Tools < Guide" for more information about "linker directives" files.  P In order to allow crt1+.o to find the beginnings of each of the two super lists,M two symbols are defined as residing at the beginning of the .ctors and .dtors O sections (respectively) in the crt1+.o file.  These symbols are "__CTOR_LIST__" M and "__DTOR_LIST__" respectively.  These are the same labels used to mark the % list heads in the BSD version of g++.   J To find the ends of the lists, the "g++" driver program (System V version)I passes the normal list of arguments to the system (COFF) linker, followed H by the name of a special file called crtn+.o.  This file defines the twoK symbols "__CTORS_END__" and "__DTORS_END__" as residing at the ends of each H of the two super lists in the .ctors and .dtors sections (respectively).  I It is particularly important to be able to find the end of the DTORS list N because the language rules call for this list to be traversed IN REVERSE ORDERM relative to the order in which the CTORS list was traversed.  Thus, traversal F must start from the END of the DTORS list and work backwards up to the/ beginning.  The crt1+.o code does exactly that. F ---------------------------- cut here --------------------------------   --N Ronald Cole               | uucp:     cvms!ronald       voice: +1 916 895 8321D Senior Software Engineer  | internet: csusac!cvms!ronald@ucdavis.eduO CVM Systems               +---------------------------------------------------- O "SCCS, the source motel! Programs check in and never check out!" - Ken Thompson   