projects/linux·blob master · refs

174 lines · 3.1 KiB

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