diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-05-11 22:55:31 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-05-11 22:55:31 +0300 |
| commit | 27ffa747f36aee9c1d5bbc61395a078238366070 (patch) | |
| tree | f37c544aaca6bebd1cc146d1eb002483c7cfd474 /arch/riscv64/conf/init-link.S | |
| parent | 3109effe7297232e17c1792e63c3a9c7d129a4eb (diff) | |
| download | kmi-27ffa747f36aee9c1d5bbc61395a078238366070.tar.gz kmi-27ffa747f36aee9c1d5bbc61395a078238366070.zip | |
arbitrary load address and RAM base detection
+ Both kind of go hand in hand, made sense to do both at the same time.
Some parts feel slightly hacky, the loader works by placing everything
on the stack and avoiding global values. Still, seems to work?
Diffstat (limited to 'arch/riscv64/conf/init-link.S')
| -rw-r--r-- | arch/riscv64/conf/init-link.S | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/arch/riscv64/conf/init-link.S b/arch/riscv64/conf/init-link.S index 600304f..0933fbb 100644 --- a/arch/riscv64/conf/init-link.S +++ b/arch/riscv64/conf/init-link.S @@ -5,11 +5,13 @@ OUTPUT_ARCH(riscv) ENTRY(_start) SECTIONS { - . = ABSOLUTE(PM_KERN_BASE); - __init_start = .; + /* slight hack, the binary is position independent code but technically + not a PIE, so avoid globals and just add the load address to external + addresses. */ + __init_start = 0; /* objcopy only copies these three sections (as far as I'm aware) into the - produces binary, so __init_end should point to the correct location in the + produced binary, so __init_end should point to the correct location in the final binary */ .text ALIGN(4K) : AT(0) { @@ -29,7 +31,10 @@ SECTIONS { *(.sbss*) *(.bss*) *(COMMON) } - __init_end = . ; + .top : { + *(.top*) + } + __kernel_size = <KERNEL_SIZE>; .garbage : { |
