Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting COFF lib file to OMF format

Is there any way to convert COFF library (lib file) to OMF library for using with C++Builder6 ? This coff is not just import library, it conatians some code. When I try to convert it using borland's coff2omf.exe, I get 1KB file from 15KB file.

like image 896
CITBL Avatar asked Jun 24 '10 22:06

CITBL


4 Answers

Instead of DigitalMars converter, you may use the Object file converter available at http://agner.org/optimize

This utility can be used for converting object files between COFF/PE, OMF, ELF and Mach-O formats for all 32-bit and 64-bit x86 platforms. Can modify symbol names in object files. Can build, modify and convert function libraries across platforms. Can dump object files and executable files. Also includes a very good disassembler supporting the SSE4, AVX, AVX2, FMA and XOP instruction sets. Source code included (GPL).

This is a great site for low-level optimization, and there are a lot of useful information in the associated manual pdf file, about the library formats across several platforms.

like image 61
Arnaud Bouchez Avatar answered Sep 26 '22 02:09

Arnaud Bouchez


It's fairly typical for an OMF object file to be a lot smaller than an equivalent COFF object, so what you're getting may well be valid.

If you find that it's really not, you can probably break the lib file into individual object files, disassemble the object files, re-assemble them to OMF object files, and put those together into an OMF lib file.

like image 29
Jerry Coffin Avatar answered Sep 25 '22 02:09

Jerry Coffin


This is rather late, but if anyone is looking for an answer, you can checkout COFFIMPLIB from DigitalMars. COFF2OMF is available at the same site, but it looks like that's older.

like image 37
0x1mason Avatar answered Sep 26 '22 02:09

0x1mason


Integrating Delphi (omf) and Ada (gcc, coff) required lots of effort until I've given up doing it in a single exe.

I honestly tried to disintegrate gcc rtl and ada rtl .a (coff libraries) into lots of .o (objects), convert them via coff2omf (there were DMD coff2omf and iirc another convobj or so). Some of the coff .o failed to be converted to .obj so I can't say if it was a reliable way at all.

Assembler level conversion is not so simple when it takes to exceptions and other deep details.

It's a pity I haven't tried a tool named ftp://ftp.styx.cabel.net/pub/UniLink/

It's not obvious, but UniLink can probably be used to achieve the goal. One of its targets is C++ Builder package (both dynamic and static). unilink -Tpp -GI should do the trick

like image 23
OCTAGRAM Avatar answered Sep 25 '22 02:09

OCTAGRAM