summaryrefslogtreecommitdiffstats
path: root/arch/arm/lib/pbl.lds.S
blob: ec7296f0fb34fef5a71a0326b580f519966103b2 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* SPDX-License-Identifier: GPL-2.0-or-later */
/* SPDX-FileCopyrightText: 2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix */

#include <linux/sizes.h>
#include <asm/barebox.lds.h>
#include <asm/memory.h>
#include <asm-generic/memory_layout.h>
#include <asm-generic/pointer.h>
#include <asm/memory.h>

/*
 * The size of the PE/COFF section that covers the barebox image, which
 * runs from _stext to _edata, must be a round multiple of the PE/COFF
 * FileAlignment, which we set to its minimum value of 0x200. '_stext'
 * itself must be 4 KB aligned, because that's what the adrp instructions
 * expects, so padding out _edata to a 0x200 aligned boundary should be
 * sufficient.
 */
PECOFF_FILE_ALIGNMENT = 0x200;

#ifdef CONFIG_EFI_STUB
#define PECOFF_EDATA_PADDING   \
       .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
#else
#define PECOFF_EDATA_PADDING
#endif

#ifdef CONFIG_PBL_RELOCATABLE
#define BASE	0x0
#else
#define BASE	(TEXT_BASE - SZ_2M)
#endif

#ifdef CONFIG_HABV4_QSPI
#define HAB_CSF_LEN	0x4000
#else
#define HAB_CSF_LEN	0x2000
#endif

OUTPUT_FORMAT(BAREBOX_OUTPUT_FORMAT)
OUTPUT_ARCH(BAREBOX_OUTPUT_ARCH)

SECTIONS
{
	. = BASE;

	.image_start : { *(.__image_start) }

	PRE_IMAGE

	. = ALIGN(4);
	._text : { *(._text) }
	.text      :
	{
		_stext = .;
		*(.text_head_prologue*)
		*(.text_head_entry*)
		__bare_init_start = .;
		*(.text_bare_init*)
		__bare_init_end = .;
		*(.text*)
	}

	/* Discard unwind if enable in barebox */
	/DISCARD/ : { *(.ARM.ex*) }

	BAREBOX_BARE_INIT_SIZE
	BAREBOX_PBL_SIZE

	. = ALIGN(4);
	.rodata : { *(.rodata*) }

	. = ALIGN(ASM_SZPTR);
	__pbl_board_stack_top = .;
	.rodata.pbl_board_stack_top : {
		*(.pbl_board_stack_top_*)
		/* Dummy for when BootROM sets up usable stack */
		ASM_LD_PTR(0x00000000)
	}
	ASSERT(. - __pbl_board_stack_top <= 2 * ASM_SZPTR, "Only One PBL per Image allowed")

	.barebox_imd : { BAREBOX_IMD }

	. = ALIGN(PBL_SEGMENT_ALIGN);
	_etext = .;			/* End of text and rodata section */
	_sdata = .;

	. = ALIGN(4);
	.data : { *(.data*) }

	. = ALIGN(4);
	__shasum_start = .;
	.shasum : {
		KEEP(*(.shasum))
	}
	__shasum_end = .;

	BAREBOX_RELOCATION_TABLE

	pbl_code_size =  . - BASE;

	. = ALIGN(4);
	.__bss_start :  { *(.__bss_start) }
	.bss : { *(.bss*) }
	.__bss_stop :  { *(.__bss_stop) }
	_end = .;

	pbl_memory_size =  . - BASE;

#if defined(CONFIG_CPU_64) && defined(CONFIG_HABV4)
	. = ALIGN(0x1000);
	__csf_start = .;
	.hab_csf : {
		BYTE(0x5a);
		. += + HAB_CSF_LEN - 1;
	} = 0x5a
	__csf_end = .;
#endif /* CONFIG_CPU_64 && CONFIG_HABV4 */

	. = ALIGN(4);
	__piggydata_start = .;
	.piggydata : {
		*(.piggydata)
	}

	. = ALIGN(4);
	__pblext_start = .;
	.pblext : {
		*(.pblext.*)
	}
	__pblext_end = .;

	PECOFF_EDATA_PADDING

	__pecoff_data_rawsize = ABSOLUTE(. - _etext);

	/* .bss is dwarfed by piggydata size, so we just handle .bss
	 * as normal PE data
	 */

	__pecoff_data_size = ABSOLUTE(. - _etext);

	.image_end : { KEEP(*(.__image_end)) }

	pbl_image_size =  . - BASE;

	_barebox_image_size = __image_end - BASE;
	_barebox_pbl_size = __bss_start - BASE;
}