mirror of
https://github.com/ivoszbg/uniLoader.git
synced 2026-08-15 05:18:32 +00:00
The current header implementation is incomplete: the text_offset and image_size slots are overlaid with internal relocation metadata (_rel_stack_base / _rel_stack_size), and the flags field is zero, which makes some bootloaders unhappy. Fill up the the missing props and while at it, stub out the image header into a header file to avoid duplicating. image_size is computed in the linker script as _stack_end - _start so the early stack page is included in the runtime memory footprint advertised to the previous-stage bootloader. Patch inspired by work from @Trijal08 and cleaned up to not account for ELF PiE.
46 lines
1.2 KiB
C
46 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Derived info from arch/arm64/kernel/head.S in the Linux kernel.
|
|
*/
|
|
#ifndef _AARCH64_LINUX_KERNEL_IMAGE_HEADER_H
|
|
#define _AARCH64_LINUX_KERNEL_IMAGE_HEADER_H
|
|
|
|
/*
|
|
* Image header flags (Documentation/arm64/booting.rst):
|
|
* Bit 0 Kernel endianness.
|
|
1 if BE, 0 if LE.
|
|
* Bit 1-2 Kernel Page size.
|
|
0 - Unspecified.
|
|
1 - 4K
|
|
2 - 16K
|
|
3 - 64K
|
|
* Bit 3 Kernel physical placement
|
|
0
|
|
2MB aligned base should be as close as possible
|
|
to the base of DRAM, since memory below it is not
|
|
accessible via the linear mapping
|
|
1
|
|
2MB aligned base such that all image_size bytes
|
|
counted from the start of the image are within
|
|
the 48-bit addressable range of physical memory
|
|
*/
|
|
#define LINUX_IMAGE_FLAGS ((1 << 1) | (1 << 3))
|
|
|
|
.macro linux_image_header entry
|
|
/*
|
|
* DO NOT MODIFY. Image header expected by Linux boot-loaders.
|
|
*/
|
|
b \entry
|
|
.long 0 /* reserved */
|
|
.quad 0 /* text_offset */
|
|
.quad _kernel_size /* image_size, see linker script */
|
|
.quad LINUX_IMAGE_FLAGS /* flags */
|
|
.quad 0 /* reserved */
|
|
.quad 0 /* reserved */
|
|
.quad 0 /* reserved */
|
|
.ascii "ARM\x64" /* magic number */
|
|
.long 0 /* reserved */
|
|
.endm
|
|
|
|
#endif /* _AARCH64_LINUX_KERNEL_IMAGE_HEADER_H */
|