xref: /linux/arch/riscv/kernel/vmlinux.lds.S (revision dd093fb0)
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#define RO_EXCEPTION_TABLE_ALIGN	4
8
9#ifdef CONFIG_XIP_KERNEL
10#include "vmlinux-xip.lds.S"
11#else
12
13#include <asm/pgtable.h>
14#define LOAD_OFFSET KERNEL_LINK_ADDR
15
16#include <asm/vmlinux.lds.h>
17#include <asm/page.h>
18#include <asm/cache.h>
19#include <asm/thread_info.h>
20#include <asm/set_memory.h>
21#include "image-vars.h"
22
23#include <linux/sizes.h>
24OUTPUT_ARCH(riscv)
25ENTRY(_start)
26
27jiffies = jiffies_64;
28
29PECOFF_SECTION_ALIGNMENT = 0x1000;
30PECOFF_FILE_ALIGNMENT = 0x200;
31
32SECTIONS
33{
34	/* Beginning of code and text segment */
35	. = LOAD_OFFSET;
36	_start = .;
37	HEAD_TEXT_SECTION
38	. = ALIGN(PAGE_SIZE);
39
40	.text : {
41		_text = .;
42		_stext = .;
43		TEXT_TEXT
44		SCHED_TEXT
45		LOCK_TEXT
46		KPROBES_TEXT
47		ENTRY_TEXT
48		IRQENTRY_TEXT
49		SOFTIRQENTRY_TEXT
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	. = ALIGN(SECTION_ALIGN);
116	_data = .;
117
118	RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN)
119	.sdata : {
120		__global_pointer$ = . + 0x800;
121		*(.sdata*)
122	}
123
124#ifdef CONFIG_EFI
125	.pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
126	__pecoff_data_raw_size = ABSOLUTE(. - __pecoff_text_end);
127#endif
128
129	/* End of data section */
130	_edata = .;
131
132	BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)
133
134#ifdef CONFIG_EFI
135	. = ALIGN(PECOFF_SECTION_ALIGNMENT);
136	__pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end);
137#endif
138	_end = .;
139
140	STABS_DEBUG
141	DWARF_DEBUG
142	ELF_DETAILS
143
144	DISCARDS
145}
146#endif /* CONFIG_XIP_KERNEL */
147