obj2asm disassembles object (.obj) files in Intel OMF, Microsoft COFF format, Linux ELF or Mac OS X Mach-O format, and writes out the corresponding assembler source code. (dmc++ generates Intel OMF format object files.)
Both 16 and 32 bit Intel x86 instruction sets are supported.
Looking at the assembly language output of the compiler is highly useful for:
- Understanding how various language constructs are compiled.
- Trying various ways of expressing an algorithm to see which ones produce faster code.
- If a particular function needs to be rewritten in inline assembly and hand optimized for maximum speed, the obj2asm output forms a good starting point.
- Due to the large number of function calling conventions supported, sometimes it is necessary to verify that the correct convention is being used.
- Verifying correct code generation.
- Comparing output with other compilers.
- Learning assembly language.
Compiling the file with the -gl option embeds line number information in the object file, enabling obj2asm to match the source code up with the generated assembler instructions. Compiling the file with the -g option embeds debug records in the object file, which obj2asm will format and output.
obj2asm commands have the following format:
obj2asm [-l -o -x] objectfile[.obj] [sourcefile] [-coutfile[.cod]]
|objectfile||the object file to disassemble. The extension defaults to .obj|
|sourcefile||the file compiled to produce the object file. Use this if the source file name embedded in the object file is missing or incorrect|
|-l||omit code labels in the assembly language file generated. Useful when comparing two object files; helping highlight the differences between them|
|-o||emit object code for each assembly language instruction|
|-x||emit code segment offset for each instruction|
|-coutfile||write output to outfile instead of the standard output. The default extension for outfile is .cod|
To see the code generated by compiling test.cpp, use the following commands:
dmc -c -gl test obj2asm test
Note: Although the output of obj2asm is in masm format, it usually requires a little editting before masm will accept it.
File Formats Supported
- Tool Interface Standards (TIS) Relocatable Object Module Format (OMF) Specification Version 1.1
- Microsoft Codeview 4.0 Symbolic Debug Information Specification
- D programming language extensions to Codeview
- Microsoft COFF
- Tool Interface Standard (TIS) Executable and Linking Format (ELF) Specification Version 1.2
- Mac OS X Mach-O