Plan 9 and Inferno at the Google Summer of Code

Plan9 kernel image format

Today I decided to leave plan9 ELF booting effort. Plan9 linker’s ELF output is not correct. This is creating lot of problems.

So now I am going to write custom boot loader for plan9’s kernel.

First thing i need to do is to understand plan9 kernel’s format.

Here is the information that i got from a.out.h:

   struct  Exec
          long    magic;          /* magic number */
          long    text;           /* size of text segment */
          long    data;           /* size of initialized data */
          long    bss;            /* size of uninitialized data */
          long    syms;           /* size of symbol table */
          long    entry;          /* entry point */
          long    spsz;           /* size of pc/sp offset table */
          long    pcsz;           /* size of pc/line number table */

I wrote a simple C program to read plan9 kernel image and print above information from it.

Kernel file image size = text + data + syms + spsz + pcsz

Also another important thing that I found out is that, this header is in big endian format, so on x86 architecture we need to swap data to read it correctly.