Porting EPOS

EPOS is designed to be highly portable (at least if compared with ordinary OS). All architectural dependencies are well encapsulated inside hardware mediators that must be written for every new architecture or hardware platform (called machine in EPOS). This however does not mean that porting EPOS is close to be a zero-effort activity. The purpose of this guide is to help you to focus on what really matters from the OS perspective.

GCC Considerations

EPOS can mostly go with standard GCC distributions, but the way different versions of GCC generate code and handle ELF objects can be a good source of headache. In general, this are the things that "always change" from GCC version to version:

  • Machines that require a BOOT strap (such as PC) will have to track the ELF file geometry generated by GCC's default liker scripts, since implementing ELF support here is usually not possible (512 bytes for the PC). To determine the offset of SETUP's entry point (GCC defaults to "_start") used by BOOT, simply run make on EPOS root directory and then:

objdump -p src/setup/pc_setup | sed -n -e 's/^ *LOAD off *\(0x.*\) vaddr.*$/\1/ p' | head -1

The result can be patched into the BOOT strap ("ELF_HDR_SIZE" constant for PC).

  • GLD messes up the meaning of -Ttext and -Tdata command line options, causing a rupture between ELF segments and contained sections. Mark Mitchell explained this on a post to binutils list:

For a long time, -Ttext, -Tdata, and -Tbss have been useless (or
broken, depending on how you look at it) on ELF systems.  Rather than
setting the segment base address, these options set the address of a
particular section.  That tended to result in the linker putting that
section outside the relevant segment, without moving the rest of the
contents of the segment, and then issuing none-too-helpful errors

  Not enough room for program headers (allocated 3, need 4)

In order to specify the address of a segment, we have to identify the first contained section to latter use --section-start "section" arguments. Unfortunately, this has been varying considerably from version to version and also between omagic and nmagic link editions. Once identified, these section names can be entered into makedefs.

Architecture-specific Considerations

Intel x86

Machine-specific Considerations