Mail Archives: djgpp/1997/10/20/10:03:36
From: | Evin C Robertson <ecr+@andrew.cmu.edu>
|
Newsgroups: | comp.os.msdos.djgpp,comp.os.msdos.programmer
|
Subject: | Re: Q: Linking gcc object files w/ Borland library
|
Date: | Fri, 17 Oct 1997 12:33:38 -0400
|
Organization: | Freshman, CIT Undeclared, Carnegie Mellon, Pittsburgh, PA
|
Lines: | 52
|
Distribution: | world
|
Message-ID: | <soFtBWm00iWp06BrA0@andrew.cmu.edu>
|
References: | <MIHASAN DOT 97Oct16105356 AT odin DOT fli DOT sh DOT bosch DOT de>
|
NNTP-Posting-Host: | po9.andrew.cmu.edu
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Excerpts from netnews.comp.os.msdos.programmer: 16-Oct-97 Q: Linking gcc
object files.. by mihasan AT odin DOT fli DOT sh DOT bosc
> we have a large project on DOS entirely written in C with the
> GNU C Compiler. But we now find that we can't link
> the gcc object files with a library written in Borland C.
> Unfortunately we don't have the sources for that specific
> library.
>
> The library has the extension .obj, while the GNU object files
> have the extension .o. Even if we rename the Borland library from
> .obj to .o, we get the link message "File not recognized: File
> format not recognized".
>
> What object file format is used on DOS, what is the
> name of the object file format that gcc creates, and
> how can the two be linked?
Well, the COFF format for GNU C is different than the OBJ format for
Borland. There is a possibility you can get the two to link, though it
will take some (considerable) work. If it's an i/o library, you might
as well give up.
1. Use OBJ2ASM (avalailable freely on the net) to decompile the OBJ file
to assembly.
2. Massage OBJ2ASM's output so that it will compile correctly using your
choice of assembler which supports COFF object files. The GASM which
comes with GNU C supports these, but it uses ATT assembly, which is
ugly. So I recommend using NASM. Mostly you'll need to wipe out
directives and make sure everything makes NASM happy.
2.5. If the code was 32 bit, you're probably done. Otherwise, continue.
3. Now you have to deal with the differences between 16 bit and 32 bit
code and compiler differences. Then you'll need to make sure the
calling convention matches up well. You'll want to change the
push-pop's to 32-bit instructions instead of 16 bit instructions.
You'll want to make the return value 32 bits instead of 16 bits. You
can have GCC output assembly so you can see what this is supposed to
look like. Once this is working, you'll need to go through the file and
find all the places where something is done differently in 16 bits than
it is done in 32 bits and change it.
4. Make sure it runs properly. If it doesn't, repeat step 3.
If you have any questions (or would like to hire me to do this), drop me
a note.
- Raw text -