305877d85e96bb3eb2aa24caf6b0d6f23333a2c0
[platform/kernel/linux-rpi.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 #define RO_EXCEPTION_TABLE_ALIGN        4
8 #define RUNTIME_DISCARD_EXIT
9
10 #ifdef CONFIG_XIP_KERNEL
11 #include "vmlinux-xip.lds.S"
12 #else
13
14 #include <asm/pgtable.h>
15 #define LOAD_OFFSET KERNEL_LINK_ADDR
16
17 #include <asm/vmlinux.lds.h>
18 #include <asm/page.h>
19 #include <asm/cache.h>
20 #include <asm/thread_info.h>
21 #include <asm/set_memory.h>
22 #include "image-vars.h"
23
24 #include <linux/sizes.h>
25 OUTPUT_ARCH(riscv)
26 ENTRY(_start)
27
28 jiffies = jiffies_64;
29
30 SECTIONS
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                 LOCK_TEXT
44                 KPROBES_TEXT
45                 ENTRY_TEXT
46                 IRQENTRY_TEXT
47                 SOFTIRQENTRY_TEXT
48                 _etext = .;
49         }
50
51         . = ALIGN(SECTION_ALIGN);
52         __init_begin = .;
53         __init_text_begin = .;
54         .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) ALIGN(SECTION_ALIGN) { \
55                 _sinittext = .;                                         \
56                 INIT_TEXT                                               \
57                 _einittext = .;                                         \
58         }
59
60         . = ALIGN(8);
61         __soc_early_init_table : {
62                 __soc_early_init_table_start = .;
63                 KEEP(*(__soc_early_init_table))
64                 __soc_early_init_table_end = .;
65         }
66         __soc_builtin_dtb_table : {
67                 __soc_builtin_dtb_table_start = .;
68                 KEEP(*(__soc_builtin_dtb_table))
69                 __soc_builtin_dtb_table_end = .;
70         }
71         /* we have to discard exit text and such at runtime, not link time */
72         .exit.text :
73         {
74                 EXIT_TEXT
75         }
76
77         __init_text_end = .;
78         . = ALIGN(SECTION_ALIGN);
79 #ifdef CONFIG_EFI
80         . = ALIGN(PECOFF_SECTION_ALIGNMENT);
81         __pecoff_text_end = .;
82 #endif
83         /* Start of init data section */
84         __init_data_begin = .;
85         INIT_DATA_SECTION(16)
86
87         /* Those sections result from the compilation of kernel/pi/string.c */
88         .init.pidata : {
89                 *(.init.srodata.cst8*)
90                 *(.init__bug_table*)
91                 *(.init.sdata*)
92         }
93
94         .init.bss : {
95                 *(.init.bss)    /* from the EFI stub */
96         }
97         .exit.data :
98         {
99                 EXIT_DATA
100         }
101         PERCPU_SECTION(L1_CACHE_BYTES)
102
103         .rel.dyn : {
104                 *(.rel.dyn*)
105         }
106
107         __init_data_end = .;
108
109         . = ALIGN(8);
110         .alternative : {
111                 __alt_start = .;
112                 *(.alternative)
113                 __alt_end = .;
114         }
115         __init_end = .;
116
117         /* Start of data section */
118         _sdata = .;
119         RO_DATA(SECTION_ALIGN)
120         .srodata : {
121                 *(.srodata*)
122         }
123
124         . = ALIGN(SECTION_ALIGN);
125         _data = .;
126
127         RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN)
128         .sdata : {
129                 __global_pointer$ = . + 0x800;
130                 *(.sdata*)
131         }
132
133         .rela.dyn : ALIGN(8) {
134                 __rela_dyn_start = .;
135                 *(.rela .rela*)
136                 __rela_dyn_end = .;
137         }
138
139         .got : { *(.got*) }
140
141 #ifdef CONFIG_RELOCATABLE
142         .data.rel : { *(.data.rel*) }
143         .plt : { *(.plt) }
144         .dynamic : { *(.dynamic) }
145         .dynsym : { *(.dynsym) }
146         .dynstr : { *(.dynstr) }
147         .hash : { *(.hash) }
148         .gnu.hash : { *(.gnu.hash) }
149 #endif
150
151 #ifdef CONFIG_EFI
152         .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
153         __pecoff_data_raw_size = ABSOLUTE(. - __pecoff_text_end);
154         __pecoff_data_raw_end = ABSOLUTE(.);
155 #endif
156
157         /* End of data section */
158         _edata = .;
159
160         BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)
161
162 #ifdef CONFIG_EFI
163         . = ALIGN(PECOFF_SECTION_ALIGNMENT);
164         __pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end);
165         __pecoff_data_virt_end = ABSOLUTE(.);
166 #endif
167         _end = .;
168
169         STABS_DEBUG
170         DWARF_DEBUG
171         ELF_DETAILS
172         .riscv.attributes 0 : { *(.riscv.attributes) }
173
174         DISCARDS
175 }
176 #endif /* CONFIG_XIP_KERNEL */