From 3db9fd9b8f8cd023423c0d58eecaca5987817184 Mon Sep 17 00:00:00 2001 From: omicron Date: Thu, 3 Apr 2025 00:49:31 +0200 Subject: [PATCH] Added object file format spec This is a WIP. --- doc/object_format.md | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 doc/object_format.md diff --git a/doc/object_format.md b/doc/object_format.md new file mode 100644 index 0000000..3b67110 --- /dev/null +++ b/doc/object_format.md @@ -0,0 +1,55 @@ +# Linker file format + +```C + +struct object_file { + uint64_t magic; // ".oo-bin" + uint64_t version; // 1 + uint64_t architecture; // AMD64(0) + uint64_t offsets_offset; + + struct offsets { + uint64_t strings; + uint64_t sections; + uint64_t symbols; + uint64_t relocations; + } offsets; + + struct string_table { + uint64_t size; + uint8_t data[static size]; + } strings; + + struct section_table { + uint32_t count; + struct section_entry { + uint32_t name; + uint64_t offset; + uint64_t size_on_disk; + uint64_t size_in_memory; + uint64_t flags; + } sections[static count]; + } sections; + + struct symbol_table { + uint32_t count; + struct symbol_entry { + uint32_t name; + uint8_t kind; // IMPORT(0) | EXPORT(1) | LOCAL(2) + uint32_t section; + uint64_t offset; + } symbols[static count]; + } symbols; + + struct relocation_table { + uint32_t count; + struct relocation_entry { + uint32_t section; + uint64_t offset; + uint8_t size; + uint32_t symbol; + uint8_t kind; // ABSOLUTE(0) | RELATIVE(1) + } relocations[static count]; + } relocations; +}; +```