How to Convert 64bit COFF to OMF?

3.7k views Asked by At

I need to convert a 64bit .lib file from COFF to OMF. Coff2Omf.exe works fine with 32bit libs but gives...

ERROR: COFF error: FOOx64.lib
(coffread.cpp, 1637) : invalid machine type detected

...on a 64bit lib. Is there an updated tool or similar to use for this?

2

There are 2 answers

2
Sergey Karpukhin On

I wonder if OMF specification have ever existed for 64-bit architecture. By the way, why do you need 64-bit OMF files? 64-bit versions on C++Builder are based on LLVM compiler backend, which produces ELF object files (as far as i know)

I don't know if something like coff2elf is bundled with C++Builder XE7, but, probably you can use opensource tools, like "Object File Converter", look for it here: http://www.agner.org/optimize/#objconv

0
Remy Lebeau On

Per Embarcadero's documentation:

Differences Between Clang-based C++ Compilers and Previous-Generation C++ Compilers

Object and Library File Format

  • BCC32 and its associated tools use OMF in .obj and .lib files.
  • Clang-based C++ compilers use ELF in .o and .a files.

This difference means, for example, that when you migrate a 32-bit Windows applications you must change references to .lib and .obj files to be .a and .o, respectively.

BCC64.EXE, the C++ 64-bit Windows Compiler

Compiled object file
ELF64 format

#pragma link

Do not specify the file extension (.ext) of modulename, as long as you are using default file types. The linkers assume the following default values for the file extension (.ext) of modulename:

  • .obj extension for BCC32
  • .o extension for:
    Clang-based C++ compilers
    BCCOSX

So if you omit the .ext, then the correct extension is automatically used according to your current target platform.

OMF is only used by the 32bit compiler/linker. The 64bit compiler/linker uses ELF64 instead.