xref: /openbmc/linux/arch/riscv/kernel/vmlinux.lds.S (revision 249592bf)
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2012 Regents of the University of California
4 * Copyright (C) 2017 SiFive
5 */
6
7#ifdef CONFIG_XIP_KERNEL
8#include "vmlinux-xip.lds.S"
9#else
10
11#include <asm/pgtable.h>
12#define LOAD_OFFSET KERNEL_LINK_ADDR
13
14#include <asm/vmlinux.lds.h>
15#include <asm/page.h>
16#include <asm/cache.h>
17#include <asm/thread_info.h>
18#include <asm/set_memory.h>
19#include "image-vars.h"
20
21#include <linux/sizes.h>
22OUTPUT_ARCH(riscv)
23ENTRY(_start)
24
25jiffies = jiffies_64;
26
27PECOFF_SECTION_ALIGNMENT = 0x1000;
28PECOFF_FILE_ALIGNMENT = 0x200;
29
30SECTIONS
31{
32	/* Beginning of code and text segment */
33	. = LOAD_OFFSET;
34	_start = .;
35	HEAD_TEXT_SECTION
36	. = ALIGN(PAGE_SIZE);
37
38	.text : {
39		_text = .;
40		_stext = .;
41		TEXT_TEXT
42		SCHED_TEXT
43		CPUIDLE_TEXT
44		LOCK_TEXT
45		KPROBES_TEXT
46		ENTRY_TEXT
47		IRQENTRY_TEXT
48		SOFTIRQENTRY_TEXT
49		*(.fixup)
50		_etext = .;
51	}
52
53	. = ALIGN(SECTION_ALIGN);
54	__init_begin = .;
55	__init_text_begin = .;
56	.init.text : AT(ADDR(.init.text) - LOAD_OFFSET) ALIGN(SECTION_ALIGN) { \
57		_sinittext = .;						\
58		INIT_TEXT						\
59		_einittext = .;						\
60	}
61
62	. = ALIGN(8);
63	__soc_early_init_table : {
64		__soc_early_init_table_start = .;
65		KEEP(*(__soc_early_init_table))
66		__soc_early_init_table_end = .;
67	}
68	__soc_builtin_dtb_table : {
69		__soc_builtin_dtb_table_start = .;
70		KEEP(*(__soc_builtin_dtb_table))
71		__soc_builtin_dtb_table_end = .;
72	}
73	/* we have to discard exit text and such at runtime, not link time */
74	.exit.text :
75	{
76		EXIT_TEXT
77	}
78
79	__init_text_end = .;
80	. = ALIGN(SECTION_ALIGN);
81#ifdef CONFIG_EFI
82	. = ALIGN(PECOFF_SECTION_ALIGNMENT);
83	__pecoff_text_end = .;
84#endif
85	/* Start of init data section */
86	__init_data_begin = .;
87	INIT_DATA_SECTION(16)
88	.exit.data :
89	{
90		EXIT_DATA
91	}
92	PERCPU_SECTION(L1_CACHE_BYTES)
93
94	.rel.dyn : {
95		*(.rel.dyn*)
96	}
97
98	__init_data_end = .;
99
100	. = ALIGN(8);
101	.alternative : {
102		__alt_start = .;
103		*(.alternative)
104		__alt_end = .;
105	}
106	__init_end = .;
107
108	/* Start of data section */
109	_sdata = .;
110	RO_DATA(SECTION_ALIGN)
111	.srodata : {
112		*(.srodata*)
113	}
114
115	EXCEPTION_TABLE(0x10)
116
117	. = ALIGN(SECTION_ALIGN);
118	_data = .;
119
120	RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
121	.sdata : {
122		__global_pointer$ = . + 0x800;
123		*(.sdata*)
124	}
125
126#ifdef CONFIG_EFI
127	.pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
128	__pecoff_data_raw_size = ABSOLUTE(. - __pecoff_text_end);
129#endif
130
131	/* End of data section */
132	_edata = .;
133
134	BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)
135
136#ifdef CONFIG_EFI
137	. = ALIGN(PECOFF_SECTION_ALIGNMENT);
138	__pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end);
139#endif
140	_end = .;
141
142	STABS_DEBUG
143	DWARF_DEBUG
144	ELF_DETAILS
145
146	DISCARDS
147}
148#endif /* CONFIG_XIP_KERNEL */
149