Merge tag 'loongarch-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai...
[linux-block.git] / arch / loongarch / kernel / vmlinux.lds.S
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/sizes.h>
3 #include <asm/asm-offsets.h>
4 #include <asm/thread_info.h>
5
6 #define PAGE_SIZE _PAGE_SIZE
7 #define RO_EXCEPTION_TABLE_ALIGN        4
8
9 /*
10  * Put .bss..swapper_pg_dir as the first thing in .bss. This will
11  * ensure that it has .bss alignment (64K).
12  */
13 #define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir)
14
15 #include <asm-generic/vmlinux.lds.h>
16 #include "image-vars.h"
17
18 /*
19  * Max avaliable Page Size is 64K, so we set SectionAlignment
20  * field of EFI application to 64K.
21  */
22 PECOFF_FILE_ALIGN = 0x200;
23 PECOFF_SEGMENT_ALIGN = 0x10000;
24
25 OUTPUT_ARCH(loongarch)
26 ENTRY(kernel_entry)
27 PHDRS {
28         text PT_LOAD FLAGS(7);  /* RWX */
29         note PT_NOTE FLAGS(4);  /* R__ */
30 }
31
32 jiffies  = jiffies_64;
33
34 SECTIONS
35 {
36         . = VMLINUX_LOAD_ADDRESS;
37
38         _text = .;
39         HEAD_TEXT_SECTION
40
41         . = ALIGN(PECOFF_SEGMENT_ALIGN);
42         _stext = .;
43         .text : {
44                 TEXT_TEXT
45                 SCHED_TEXT
46                 LOCK_TEXT
47                 KPROBES_TEXT
48                 IRQENTRY_TEXT
49                 SOFTIRQENTRY_TEXT
50                 *(.fixup)
51                 *(.gnu.warning)
52         } :text = 0
53         . = ALIGN(PECOFF_SEGMENT_ALIGN);
54         _etext = .;
55
56         /*
57          * struct alt_inst entries. From the header (alternative.h):
58          * "Alternative instructions for different CPU types or capabilities"
59          * Think locking instructions on spinlocks.
60          */
61         . = ALIGN(4);
62         .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
63                 __alt_instructions = .;
64                 *(.altinstructions)
65                 __alt_instructions_end = .;
66         }
67
68 #ifdef CONFIG_RELOCATABLE
69         . = ALIGN(8);
70         .la_abs : AT(ADDR(.la_abs) - LOAD_OFFSET) {
71                 __la_abs_begin = .;
72                 *(.la_abs)
73                 __la_abs_end = .;
74         }
75 #endif
76
77         .got : ALIGN(16) { *(.got) }
78         .plt : ALIGN(16) { *(.plt) }
79         .got.plt : ALIGN(16) { *(.got.plt) }
80
81         .data.rel : { *(.data.rel*) }
82
83         . = ALIGN(PECOFF_SEGMENT_ALIGN);
84         __init_begin = .;
85         __inittext_begin = .;
86
87         INIT_TEXT_SECTION(PAGE_SIZE)
88         .exit.text : {
89                 EXIT_TEXT
90         }
91
92         . = ALIGN(PECOFF_SEGMENT_ALIGN);
93         __inittext_end = .;
94
95         __initdata_begin = .;
96
97         INIT_DATA_SECTION(16)
98         .exit.data : {
99                 EXIT_DATA
100         }
101
102 #ifdef CONFIG_SMP
103         PERCPU_SECTION(1 << CONFIG_L1_CACHE_SHIFT)
104 #endif
105
106         .init.bss : {
107                 *(.init.bss)
108         }
109         . = ALIGN(PECOFF_SEGMENT_ALIGN);
110         __initdata_end = .;
111
112         __init_end = .;
113
114         _sdata = .;
115         RO_DATA(4096)
116         RW_DATA(1 << CONFIG_L1_CACHE_SHIFT, PAGE_SIZE, THREAD_SIZE)
117
118         .rela.dyn : ALIGN(8) {
119                 __rela_dyn_begin = .;
120                  *(.rela.dyn) *(.rela*)
121                 __rela_dyn_end = .;
122         }
123
124         .sdata : {
125                 *(.sdata)
126         }
127         .edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGN); }
128         _edata =  .;
129
130         BSS_SECTION(0, SZ_64K, 8)
131         . = ALIGN(PECOFF_SEGMENT_ALIGN);
132
133         _end = .;
134
135         STABS_DEBUG
136         DWARF_DEBUG
137         ELF_DETAILS
138
139         .gptab.sdata : {
140                 *(.gptab.data)
141                 *(.gptab.sdata)
142         }
143         .gptab.sbss : {
144                 *(.gptab.bss)
145                 *(.gptab.sbss)
146         }
147
148         DISCARDS
149         /DISCARD/ : {
150                 *(.dynamic .dynsym .dynstr .hash .gnu.hash)
151                 *(.gnu.attributes)
152                 *(.options)
153                 *(.eh_frame)
154         }
155 }