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