[Main]
Title=__ld_insert_kernel_rom_calls
See Also=insert_mlink_rom_calls: __ld_insert_mlink_rom_calls, insert_compressed_rom_calls: __ld_insert_compressed_rom_calls
[Top]
__ld_insert_kernel_rom_calls can be used to handle
ROM calls. It inserts references to
ROM calls in the format used by kernels:
- If the program uses at least one ROM call...
- 2 bytes: the number of different ROM calls minus 1
- For each ROM call...
- 2 bytes: index of the ROM call
- Relocation table for this ROM call:
- For each reference...
- 2 bytes: location (may not be 0)
- 2 bytes: 0
If a program uses this insertion, it must process it as follows:
- For each ROM call...
- For each relocation entry...
- Get the starting address of the program (via
__ld_entry_point);
- Add the location value;
- Modify the 4-byte value (offset) at the resulting address:
- Get the address of the ROM function/variable indexed by
index;
- Add the value of offset;
- Write the resulting address to the 4-byte space covered by
offset.
Before program termination, this process has to be reverted, so that it can
be repeated the next time the program starts. Simply deactivating the
relocation code would prevent programs from being transferred between
devices.