blob: f4ce98c82c8df14f57c0cd56f8a39acfbcb2de37 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
David Feng85fd5f12013-12-14 11:47:35 +08002/*
3 * (C) Copyright 2013
4 * David Feng <fenghua@phytium.com.cn>
5 *
6 * (C) Copyright 2002
7 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
David Feng85fd5f12013-12-14 11:47:35 +08008 */
9
macro.wave.z@gmail.com01bd3342016-12-08 11:58:22 +080010#include <config.h>
11#include <asm/psci.h>
12
David Feng85fd5f12013-12-14 11:47:35 +080013OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
14OUTPUT_ARCH(aarch64)
15ENTRY(_start)
16SECTIONS
17{
macro.wave.z@gmail.com01bd3342016-12-08 11:58:22 +080018#ifdef CONFIG_ARMV8_SECURE_BASE
19 /DISCARD/ : { *(.rela._secure*) }
20#endif
David Feng85fd5f12013-12-14 11:47:35 +080021 . = 0x00000000;
22
23 . = ALIGN(8);
Ilias Apalodimascdb58392024-03-15 08:43:50 +020024 __image_copy_start = ADDR(.text);
David Feng85fd5f12013-12-14 11:47:35 +080025 .text :
26 {
David Feng85fd5f12013-12-14 11:47:35 +080027 CPUDIR/start.o (.text*)
Alexander Graf94a10f22018-06-12 07:48:37 +020028 }
29
30 /* This needs to come before *(.text*) */
31 .efi_runtime : {
32 __efi_runtime_start = .;
33 *(.text.efi_runtime*)
34 *(.rodata.efi_runtime*)
35 *(.data.efi_runtime*)
36 __efi_runtime_stop = .;
37 }
38
Ilias Apalodimas3f9a3112025-02-20 15:54:40 +020039#ifdef CONFIG_MMU_PGPROT
40 .text_rest ALIGN(CONSTANT(COMMONPAGESIZE)) :
41#else
Alexander Graf94a10f22018-06-12 07:48:37 +020042 .text_rest :
Ilias Apalodimas3f9a3112025-02-20 15:54:40 +020043#endif
Alexander Graf94a10f22018-06-12 07:48:37 +020044 {
Ilias Apalodimas3f9a3112025-02-20 15:54:40 +020045 __text_start = .;
David Feng85fd5f12013-12-14 11:47:35 +080046 *(.text*)
Ilias Apalodimas3f9a3112025-02-20 15:54:40 +020047#ifdef CONFIG_MMU_PGPROT
48 . = ALIGN(CONSTANT(COMMONPAGESIZE));
49#endif
50 __text_end = .;
David Feng85fd5f12013-12-14 11:47:35 +080051 }
macro.wave.z@gmail.com01bd3342016-12-08 11:58:22 +080052
53#ifdef CONFIG_ARMV8_PSCI
54 .__secure_start :
55#ifndef CONFIG_ARMV8_SECURE_BASE
56 ALIGN(CONSTANT(COMMONPAGESIZE))
57#endif
58 {
59 KEEP(*(.__secure_start))
60 }
61
62#ifndef CONFIG_ARMV8_SECURE_BASE
Tom Rinia17db832023-01-10 11:19:31 -050063#define __ARMV8_SECURE_BASE
macro.wave.z@gmail.com01bd3342016-12-08 11:58:22 +080064#define __ARMV8_PSCI_STACK_IN_RAM
Tom Rinia17db832023-01-10 11:19:31 -050065#else
66#define __ARMV8_SECURE_BASE CONFIG_ARMV8_SECURE_BASE
macro.wave.z@gmail.com01bd3342016-12-08 11:58:22 +080067#endif
Tom Rinia17db832023-01-10 11:19:31 -050068 .secure_text __ARMV8_SECURE_BASE :
macro.wave.z@gmail.com01bd3342016-12-08 11:58:22 +080069 AT(ADDR(.__secure_start) + SIZEOF(.__secure_start))
70 {
71 *(._secure.text)
Chee Hong Angfb140832019-02-12 00:27:02 -080072 . = ALIGN(8);
73 __secure_svc_tbl_start = .;
74 KEEP(*(._secure_svc_tbl_entries))
75 __secure_svc_tbl_end = .;
macro.wave.z@gmail.com01bd3342016-12-08 11:58:22 +080076 }
77
78 .secure_data : AT(LOADADDR(.secure_text) + SIZEOF(.secure_text))
79 {
80 *(._secure.data)
81 }
82
83 .secure_stack ALIGN(ADDR(.secure_data) + SIZEOF(.secure_data),
84 CONSTANT(COMMONPAGESIZE)) (NOLOAD) :
85#ifdef __ARMV8_PSCI_STACK_IN_RAM
86 AT(ADDR(.secure_stack))
87#else
88 AT(LOADADDR(.secure_data) + SIZEOF(.secure_data))
89#endif
90 {
91 KEEP(*(.__secure_stack_start))
92
93 . = . + CONFIG_ARMV8_PSCI_NR_CPUS * ARM_PSCI_STACK_SIZE;
94
95 . = ALIGN(CONSTANT(COMMONPAGESIZE));
96
97 KEEP(*(.__secure_stack_end))
98 }
99
100#ifndef __ARMV8_PSCI_STACK_IN_RAM
101 . = LOADADDR(.secure_stack);
102#endif
103
104 .__secure_end : AT(ADDR(.__secure_end)) {
105 KEEP(*(.__secure_end))
106 LONG(0x1d1071c); /* Must output something to reset LMA */
107 }
108#endif
Ilias Apalodimas3f9a3112025-02-20 15:54:40 +0200109 .efi_runtime_rel : {
110 __efi_runtime_rel_start = .;
111 *(.rel*.efi_runtime)
112 *(.rel*.efi_runtime.*)
113 __efi_runtime_rel_stop = .;
David Feng85fd5f12013-12-14 11:47:35 +0800114 }
115
Ilias Apalodimas3f9a3112025-02-20 15:54:40 +0200116#ifdef CONFIG_MMU_PGPROT
117 .rodata ALIGN(CONSTANT(COMMONPAGESIZE)): {
118#else
119 .rodata ALIGN(8) : {
120#endif
121 __start_rodata = .;
122 *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
123 }
David Feng85fd5f12013-12-14 11:47:35 +0800124
Ilias Apalodimas3f9a3112025-02-20 15:54:40 +0200125 __u_boot_list ALIGN(8) : {
Andrew Scull5a9095c2022-05-30 10:00:04 +0000126 KEEP(*(SORT(__u_boot_list*)));
Ilias Apalodimas3f9a3112025-02-20 15:54:40 +0200127#ifdef CONFIG_MMU_PGPROT
128 . = ALIGN(CONSTANT(COMMONPAGESIZE));
129#endif
130 __end_rodata = .;
David Feng85fd5f12013-12-14 11:47:35 +0800131 }
132
Ilias Apalodimas3f9a3112025-02-20 15:54:40 +0200133#ifdef CONFIG_MMU_PGPROT
134 .data ALIGN(CONSTANT(COMMONPAGESIZE)) : {
135#else
136 .data ALIGN(8) : {
137#endif
138 __start_data = .;
139 *(.data*)
Alexander Graf0bd425a2016-03-04 01:10:01 +0100140 }
141
142 . = ALIGN(8);
Ilias Apalodimascdb58392024-03-15 08:43:50 +0200143 __image_copy_end = .;
David Feng85fd5f12013-12-14 11:47:35 +0800144
Ilias Apalodimas3f9a3112025-02-20 15:54:40 +0200145 .rela.dyn ALIGN(8) : {
Ilias Apalodimas45b1bd92024-03-15 08:43:48 +0200146 __rel_dyn_start = .;
David Feng85fd5f12013-12-14 11:47:35 +0800147 *(.rela*)
Ilias Apalodimas45b1bd92024-03-15 08:43:48 +0200148 __rel_dyn_end = .;
David Feng85fd5f12013-12-14 11:47:35 +0800149 }
150
151 _end = .;
152
Ilias Apalodimas772acf82024-03-15 08:43:51 +0200153 /*
154 * arch/arm/lib/crt0_64.S assumes __bss_start - __bss_end % 8 == 0
155 */
Ilias Apalodimas3f9a3112025-02-20 15:54:40 +0200156 .bss ADDR(.rela.dyn) (OVERLAY) : {
Ilias Apalodimas6d1e1b82024-03-15 08:43:46 +0200157 __bss_start = .;
David Feng85fd5f12013-12-14 11:47:35 +0800158 *(.bss*)
Ilias Apalodimas6d1e1b82024-03-15 08:43:46 +0200159 . = ALIGN(8);
160 __bss_end = .;
Ilias Apalodimas3f9a3112025-02-20 15:54:40 +0200161#ifdef CONFIG_MMU_PGPROT
162 . = ALIGN(CONSTANT(COMMONPAGESIZE));
163#endif
164 __end_data = .;
David Feng85fd5f12013-12-14 11:47:35 +0800165 }
166
167 /DISCARD/ : { *(.dynsym) }
168 /DISCARD/ : { *(.dynstr*) }
169 /DISCARD/ : { *(.dynamic*) }
170 /DISCARD/ : { *(.plt*) }
171 /DISCARD/ : { *(.interp*) }
172 /DISCARD/ : { *(.gnu*) }
Stephen Warren80a93652018-01-03 14:31:51 -0700173
174#ifdef CONFIG_LINUX_KERNEL_IMAGE_HEADER
175#include "linux-kernel-image-header-vars.h"
176#endif
David Feng85fd5f12013-12-14 11:47:35 +0800177}