1

I've been learning low-level stuff for a while now and I'm quite familiar with PE files and how they work. But I've been unable to find any documentation of their precursor .o files. I'm looking for a deep-dive on the actual byte-by-byte structure of them.

What does the format of .o files depend on? Is it even platform specific at all? Perhaps compiler-specific? Where can I find documentation on the file format of .o files? Mostly interested in Windows.

Abraham
  • 93
  • 5
  • 4
    https://wiki.osdev.org/COFF https://learn.microsoft.com/en-us/windows/win32/debug/pe-format – Alan Birtles Jun 04 '22 at 20:06
  • Read Levine's book *Linkers and loaders* – Basile Starynkevitch Jun 04 '22 at 20:21
  • To my knowledge, the object file are not platform-specific, but not all compilers use the same formats. MSVC uses a different format than GCC/Clang on Windows. – prapin Jun 04 '22 at 22:59
  • 1
    This could answer your question: [clarification-on-binary-file-pe-coff-elf-formats-terminology](https://stackoverflow.com/questions/2170818/clarification-on-binary-file-pe-coff-elf-formats-terminology) ; `.o` aka `object` aka `relocatable` files are platform specific (ie executable file format). you will find some infos here [Comparison_of_executable_file_formats](https://en.wikipedia.org/wiki/Comparison_of_executable_file_formats) – Valery S. Jun 05 '22 at 06:44

1 Answers1

2

.o files as produced by GCC and LLVM when using Windows (MinGW) are COFF files (see https://wiki.osdev.org/COFF). On certain other platforms the ELF format is used.

The Windows PE format (used for .dll and .exe files) is actualy a subset of the COFF format.

Brecht Sanders
  • 6,215
  • 1
  • 16
  • 40