# Program loading (ivss) **Program loading** transfers linked section bytes into simulated memory and applies relocations before execution. ivss's loader copies each eligible section according to its header: ```c if (addr == 0) { Mem_WriteRawBytes(data, offset, size); offset += size; } else { Mem_WriteRawBytes(data, addr, size); } ``` Here `addr` and `size` come from the current section header. A nonzero address places the bytes directly; zero-address sections use the loader's running offset. Symbol-table and relocation sections are skipped as ordinary program contents. The loader then consults matching relocation records and writes resolved values into memory. The serialized file can therefore retain zero placeholders that become meaningful addresses only in the loaded image. Loading does not choose a new entry point from the ELF header: `Emu_RunElf()` initializes the program counter to `0x40000000`. The code section must be placed accordingly. The emulator's own memory-map callback is installed after this initial loading, so raw section copies do not trigger terminal output or other mapped-device actions. Source: [emulator.c](https://github.com/yanevskiv/ivss/blob/main/src/emulator.c).