From: locke AT mcs DOT net (Peter Johnson) Newsgroups: comp.os.msdos.djgpp Subject: Re: GDB to debug Masm/Nasn output? Date: Sat, 20 Feb 1999 23:36:42 GMT Organization: BiLogic Productions Lines: 75 Message-ID: <36cf4632.80880437@news.cso.uiuc.edu> References: NNTP-Posting-Host: isr3193.urh.uiuc.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Newsreader: Forte Agent 1.5/32.452 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com The problem is that specifying the /CO option to MASM does produce COFF object files, but they don't contain sections named ".text", ".data", etc. Also, you won't be able to debug programs unless they were linked with ld (the DJGPP/GNU linker). I have been able to get MASM-assembled code to link successfully with ld by hexediting the section names in the object file. However, in general, I think you'll have more success with NASM, as long as you link with ld! Good luck! Peter Johnson locke AT mcs DOT net On Sat, 20 Feb 1999 19:52:46 +0000, Dave Bird wrote: > > Dear People, > > I have a large Intel-style assembler program shared with other users, > who are very unlikely to mess with different assemblers than MASM > (or I could get them NASM) or with high level. This is a given. > It needs to start using protected mode or "unreal mode" for very big > data structures. > > Can I debug MASM (or NASM) output with GDB or similar? I can't use > CodeView because it will reset large segment limits back to 64K or > TubboDebug because it won't let me allocate loads of memory; > apparently if I use masm's LINK /CO then I am producing COFF output. > I have the latest DJGPP2.2 package from DJ's website. > > However, GDB says "wrong file format" -- even though according to > the FAQ it should run EXE as well as COFF -- and exe2coff equally > says that the file hasn't got a COFF section. Help! This may be > a MASM problem as much as anything; maybe I need a different > Intel-style assembler which will produce output GDB can eat? > > Regards, > > DAVE. > > >BEGIN FAQ QUOTE=======================================================[ > >12.4 GDB would not debug unless it sees COFF output > >Q: I try invoking GDB on my program, but it says: "not in executable >format: File format not recognized." Huh? >+ >+---------------------------------------------------------------------+ >A: Most probably, you've invoked GDB from DJGPP v2.0 on a .exe program. >That version of GDB needs to be called with the name of un-stubbed COFF >executable as its argument. To get both a .exe and a COFF file, you >should make your link command line look this way: > > gcc -o foo foo.o > >instead of > > gcc -o foo.exe foo.o > >(the latter will only produce foo.exe, while the former produces both >foo, the COFF executable which gdb needs, and foo.exe). > >To produce a COFF file from a .exe program, use the EXE2COFF program >which comes with DJGPP, like this: > > exe2coff foo.exe > >Debuggers which come with DJGPP v2.01 can debug COFF and .exe programs >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >alike, so upgrading to v2.01 should solve this problem. > >========================================================]END FAQ QUOTE.