From: ian AT cygnus DOT com Subject: Re: ld and microsoft libraries 2 May 1998 06:48:16 -0700 Message-ID: <199805011630.MAA09024.cygnus.gnu-win32@tweedledumb.cygnus.com> References: <199805010046 DOT RAA14849 DOT cygnus DOT gnu-win32 AT pacific DOT pgroup DOT com> To: lfm AT pgroup DOT com Cc: gnu-win32 AT cygnus DOT com In gnu-win32 lfm AT pgroup DOT com (Larry Meadows) writes: >Has anyone worked on gnu ld so that it will handle microsoft libraries. My intention is that the GNU linker will handle Microsoft libraries. However, I don't use any Microsoft libraries, and I don't have any lying around, so I depend upon others to report problems with test cases that I can recreate. >Has anyone worked on implementing the microsoft comdat stuff. In the >microsoft libraries there are object files that contain, e.g., multiple >.text sections. Each of these text sections has a comdat symbol >associated with it. The microsoft linker pulls in a specific text section >only if the comdat symbol is referenced. This is a way to allow multiple >functions in a file, but only the functions that are referenced are >pulled in. I was not aware of that feature of comdat sections. I thought comdat sections mainly worked to eliminate duplicate sections, which the GNU linker does support. Does the MS linker really pull specific sections out of an object file based on symbol references? I don't see any reference to that in the PE documentation, although that doesn't mean it doesn't happen. That would imply that the MS linker can treat an object file like an archive. >Also, the associative comdat is used so that, e.g., a debug$f section >is pulled in only if the associated text section is pulled in. >This seems pretty hard to do in the gnu linker -- in the >section_already_linked function in ldlang.c, it would be necessary to >see if the comdat symbol for a section had been referenced, and I have >no idea how to do this. >One hack is just to link in all the sections, whether they're referenced or >not. But this could result in incompatibility with the microsoft linker. The associative comdat seems fairly straightforward to implement. Make a second pass over the sections immediately after the pass using sec_already_linked, and for each associative section check whether the appropriate other section is being included. I don't see why you have to worry about symbols in this case. Ian - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".