From: "Lawrence Rust" Newsgroups: comp.os.msdos.djgpp References: Subject: Re: Using MASM generated COFF files with GPP (solution) Lines: 52 Organization: Software Systems X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Message-ID: Date: Tue, 17 Apr 2001 13:05:56 +0100 NNTP-Posting-Host: 62.253.145.91 X-Complaints-To: abuse AT ntlworld DOT com X-Trace: news6-win.server.ntlworld.com 987509203 62.253.145.91 (Tue, 17 Apr 2001 13:06:43 BST) NNTP-Posting-Date: Tue, 17 Apr 2001 13:06:43 BST To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Eli Zaretskii" wrote in message news:Pine DOT SUN DOT 3 DOT 91 DOT 1010417142859 DOT 12338A-100000 AT is... > Then how come Tom's program worked? I haven't seen the actual program that Tom used but I presume that the code made no use of local static data or external subroutine calls. > I'm hearing these two different types of reports for quite some time > now. Some people tell that they can link MASM-produced COFF object files > with no problems, others tell that the relocations are wrong and must be > patched manually. It almost sounds as if there are two different > versions of MASM out there. > > Perhaps someone could set the record straight once and for all. > > TIA I've tried various versions of ml.exe and found that all of them generate relocations incompatible with ld. I've tested versions 6.11d (from the Win98 & NT4 DDK), 6.13.8204 (from the Win2k DDK) and 6.14.8444 (from the WinMe DDK). I've found the best to be version 6.14.8444 which comes with the Windows ME extensions for the Windows 2000 DDK, found in \DDKWIN2K\BIN\WIN_ME\BIN\ML.EXE. I've found that: 1. A call to an external subroutine is assembled as an 0E8h opcode followed by a relative offset (initially 0). A REL32 relocation record is created pointing to the offset. 'ld' incorrectly calculates the displacement to the target because it ignores the offset of the fixup within the section. 2. References to local static data are assembled with a section relative address and a DIR32 relocation record. 'ld' incorrectly calculates the virtual address because it subtracts the relative section offset from it. > > I wrote a simple utility to do this which can be downloaded > > (with C source) from www.softsystem.co.uk/masm2djg.zip > > Please consider uploading it to DJ Delorie's server (see section 22.8 of > the DJGPP FAQ for the details), so that your utility could be put on > SimTel.NET mirrors, where all DJGPP users could easily get it, even if > your home page somehow becomes invalid. Thanks. Done. -- Lawrence Rust Software Systems www.softsystem.co.uk