difos/target/linux/realtek/image/rt-loader/linker/linker.ld
Markus Stockhausen ccbff8bbdd realtek: add rt-loader (runtime loader)
The bootloader of many Realtek switches only supports gzipped kernel images.
With limited flash space that might get critical in future versions. For better
compression allow support for compressed images. For this a new loader was
developed. Several ideas have been taken over from the existing lzma loader
but this has been enhanced to make integration simpler. What is new:

- Loader is position independent. No need to define load addresses
- Loader identifies device memory on its own
- Loader uses "official" upstream kernel lzma uncompress
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/decompress_unlzma.c
- Loader uses "official" UNMODIFIED nanoprintg that is used by several
  bare metal projects. https://github.com/charlesnicholson/nanoprintf

Compiled the loader ist just under 12KiB and during boot it will show:

rt-loader
Found RTL8380M (chip id 6275C) with 256MB
Relocate 2924240 bytes from 0x80100000 to 0x8fce0000
Extract kernel with 2900144 bytes from 0x8fce521c to 0x80100000...
Extracted kernel size is 9814907 bytes
Booting kernel from 0x80100000 ...

[    0.000000] Linux version 6.12.33 ...
[    0.000000] RTL838X model is 83806800
...

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/18397
Signed-off-by: Robert Marko <robimarko@gmail.com>
2025-06-28 16:14:55 +02:00

41 lines
919 B
Text

ENTRY(_start)
SECTIONS {
.text : {
*(.text)
}
.data : ALIGN(32) {
*(.sdata*)
*(.data*)
}
/*
* In MIPS position independent code (PIC), the global offset table (GOT) is a data structure
* used to facilitate access to global variables and functions when the code's final memory
* location is not known at compile time. The GOT contains absolute addresses of global symbols,
* but is itself located using a relative reference. This allows the code to be relocated at
* runtime without modification.
*/
.got : ALIGN(32) {
__got_start = .;
*(.got*)
__got_end = .;
}
/*
* Storage for the compressed kernel image that was integrated into the loader during link time.
* No code just binary data.
*/
.kernel : ALIGN(1) {
__kernel_data_start = .;
KEEP(*(.kernel))
__kernel_data_end = .;
}
.bss (NOLOAD) : ALIGN(4) {
__bss_start = .;
*(.bss)
*(.sbss)
*(COMMON)
__bss_end = .;
}
}