/* * Universalisos Linker Script * PikeOS 5.0 Feature Parity - Memory Layout Definition * * Defines memory regions for ARM and RISC-V architectures * with proper alignment and section placement for safety-critical systems. */ /* * Entry point */ ENTRY(kernel_main) /* * Memory regions for QEMU virt machine */ MEMORY { /* QEMU virt machine memory layout */ RAM (rwxai) : ORIGIN = 0x40000000, LENGTH = 128M FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64M } /* * Stack sizes */ __stack_size = 0x4000; /* 16KB stack */ __irq_stack_size = 0x1000; /* 4KB IRQ stack */ __fiq_stack_size = 0x1000; /* 4KB FIQ stack */ __system_stack_size = 0x2000; /* 8KB system stack */ /* * Heap configuration */ __heap_start = 0x60000000; __heap_end = 0x60800000; /* 8MB heap */ __heap_size = __heap_end - __heap_start; /* * Section definitions */ SECTIONS { /* * Exception vector table (must be at offset 0x00000000) */ .vectors : { . = ALIGN(4); KEEP(*(.text.vectors)) . = ALIGN(4); } > FLASH /* * Code and read-only data */ .text : { . = ALIGN(4); *(.text) *(.text*) *(.rodata) *(.rodata*) . = ALIGN(4); } > RAM AT> FLASH /* * Constructor and destructor tables */ .ctors : { . = ALIGN(4); __ctor_start = .; KEEP(*(.ctors)) KEEP(*(SORT(.ctors.*))) __ctor_end = .; . = ALIGN(4); } > RAM .dtors : { . = ALIGN(4); __dtor_start = .; KEEP(*(.dtors)) KEEP(*(SORT(.dtors.*))) __dtor_end = .; . = ALIGN(4); } > RAM /* * Exception vectors (data section) */ .data : { . = ALIGN(4); *(.data) *(.data*) . = ALIGN(4); } > RAM /* * KDEV driver descriptors (self-registered via UOS_DRV_REGISTER) */ .uos_drv : { __uos_drv_start = .; KEEP(*(.uos_drv)) __uos_drv_end = .; } > RAM /* * Embedded configuration manifest (config/cfg_blob.S .incbin) */ .uoscfg : { . = ALIGN(4); _uos_cfg_start = .; KEEP(*(.uoscfg)) . = ALIGN(4); _uos_cfg_end = .; } > RAM /* * BSS section (zero-initialized data) */ .bss : { . = ALIGN(4); __bss_start = .; *(.bss) *(.bss*) *(COMMON) . = ALIGN(4); __bss_end = .; } > RAM /* * Stack definitions */ .stack : { . = ALIGN(16); . = . + __stack_size; __stack_top = .; } > RAM .irq_stack : { . = ALIGN(16); . = . + __irq_stack_size; __irq_stack_top = .; } > RAM .fiq_stack : { . = ALIGN(16); . = . + __fiq_stack_size; __fiq_stack_top = .; } > RAM .system_stack : { . = ALIGN(16); . = . + __system_stack_size; __system_stack_top = .; } > RAM /* * Heap definition */ .heap : { . = ALIGN(8); __heap_start = .; . = . + __heap_size; __heap_end = .; . = ALIGN(8); } > RAM /* * Debug sections */ /DISCARD/ : { *(.comment) *(.ARM.attributes) *(.note.*) } /* * Stack protection (optional for safety) */ .stack_protector : { . = ALIGN(8); __stack_chk_guard = .; . = . + 8; } > RAM }