summaryrefslogtreecommitdiff
path: root/arch/arm64/kernel/tashaboot.lds
blob: e2b79545faecf2951c81beb2296ff71093efefbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * tashaboot arm64 memory layout. one segment, loaded at the bottom of
 * RAM, right where qemu -kernel drops a raw image on virt.
 *
 * Copyright (C) 2026 Bradley Morgan <brads@mainlining.org>
 */

OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
OUTPUT_ARCH(aarch64)
ENTRY(_start)

SECTIONS
{
	/*
	 * the first 64 bytes are the arm64 Image header: code0 'b' over
	 * it, magic ARM\x64, text_offset 0. qemu -kernel parses the
	 * header, loads the file at 0x40000000 and enters at
	 * 0x40000000, where the branch lands on reset at 0x40000040.
	 * without the header qemu guesses text_offset 0x80000 and runs
	 * the whole loader from the wrong address.
	 */
	. = 0x40000000;

	__image_copy_start = .;
	_text_start = .;

	.text :
	{
		arch/arm64/kernel/start.o (.text.boot)
		*(.text.boot)

		/* the Image header, code0 branches over it */
		. = ALIGN(64);
		*(.text.imgheader)
		. = ALIGN(64);

		*(.text*)
	}

	. = ALIGN(8);
	__text_end = .;

	.rodata :
	{
		*(SORT_BY_ALIGNMENT(.rodata*))
	}

	. = ALIGN(8);
	__rodata_end = .;

	.data :
	{
		*(.data*)
	}

	. = ALIGN(8);
	__image_end = .;

	__bss_start = .;
	.bss :
	{
		*(.bss*)
		*(COMMON)
	}
	. = ALIGN(8);
	__bss_end = .;

	/*
	 * the stack lives in its own region, clear of bss. page tables
	 * and buffers are bss objects, a stack sharing their address
	 * space grows down into them and the first deep call crushes
	 * whatever it meets.
	 */
	. = ALIGN(4096);
	__stack_bottom = .;
	. += 0x4000;
	__stack_top = .;
	__image_copy_end = .;

	/DISCARD/ : { *(.dynsym) }
	/DISCARD/ : { *(.dynstr*) }
	/DISCARD/ : { *(.dynamic*) }
	/DISCARD/ : { *(.plt*) }
	/DISCARD/ : { *(.interp*) }
	/DISCARD/ : { *(.gnu*) }
	/DISCARD/ : { *(.ARM.attributes) }
	/DISCARD/ : { *(.comment) }
	/DISCARD/ : { *(.note*) }
	/DISCARD/ : { *(.eh_frame*) }
}