Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!princeton!phoenix!jtliu From: jtliu@phoenix.UUCP Newsgroups: comp.sys.ibm.pc Subject: Re: Borland / Turbo C Message-ID: <723@phoenix.PRINCETON.EDU> Date: Thu, 17-Sep-87 01:05:00 EDT Article-I.D.: phoenix.723 Posted: Thu Sep 17 01:05:00 1987 Date-Received: Sat, 19-Sep-87 07:49:32 EDT References: <7871.1684.forumexp@mts.rpi.edu> Reply-To: jtliu@phoenix.UUCP (James T. Liu) Organization: Princeton Univ. Computing and Information Technology Lines: 42 Summary: Large memory model link problems In article <7871.1684.forumexp@mts.rpi.edu> Howard Kapustein writes: > > According to BYTE magazine, Turbo C has a problem linking > large memory models. I think the problem was they didn't > compile right. How can I tell if my copy is bad (I purchased > it late-July.) I have not used large models yet, so I don't > know if I'm affected. I don't have the infamous inverted division error > ( 4/2 = .5). >... I don't know if this link problem has been brought up before, but I ran into this when compiling a large program. Apparantly, the problem occurs when linking (compiling is not a problem) large memory model programs using the emulator library (emu.lib). This is what I have been able to figure out: Routine fpexcep in the emulator library calls _exit (which is defined in the main library, cl.lib) with a near call. This means fpexcep and _exit has to be loaded within 64K of each other. The problem occurs because fpexcep resides in segment _TEXT which is defined in c0l.obj and thus occurs at the beginning of the executable. However, _exit is defined in EXIT_TEXT in library cl.lib, and this does not get loaded until externals are resolved by the linker. This means, _exit gets loaded after all of your program modules. Thus, if your program code is longer than 64K, you'll run into this bug. I believe the linker reports 'fixup offset exceeds field width in module fpexcep', or something like that. I've found a simple way to fix this. All you have to do is to assemble the following file: exit_text segment para public 'code' exit_text ends end and include this right after c0l (which should be the first file linked). What this does is to force segment EXIT_TEXT to be loaded right after segment _TEXT, thus forcing fpexcep and _exit to be within 64K of each other. I believe this works, but I really haven't tested it that extensively. - Jim Liu (DEI)