blob: 502d0826ecb14c85ad7c6a4f74a438e37b91a20b [file] [log] [blame]
Thomas Gleixner50acfb22019-05-29 07:18:00 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -07002/*
3 * Copyright (C) 2012 Regents of the University of California
4 * Copyright (C) 2017 SiFive
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -07005 */
6
Vitaly Wool44c92252021-04-13 02:35:14 -04007#ifdef CONFIG_XIP_KERNEL
8#include "vmlinux-xip.lds.S"
9#else
10
Alexandre Ghiti2bfc6cd2021-04-11 12:41:44 -040011#include <asm/pgtable.h>
12#define LOAD_OFFSET KERNEL_LINK_ADDR
Vitaly Wool44c92252021-04-13 02:35:14 -040013
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070014#include <asm/vmlinux.lds.h>
15#include <asm/page.h>
16#include <asm/cache.h>
17#include <asm/thread_info.h>
Zong Li00cb41d2020-03-10 00:55:40 +080018#include <asm/set_memory.h>
Atish Patracb7d2dd2020-09-17 15:37:13 -070019#include "image-vars.h"
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070020
Atish Patrae0119952020-03-17 18:11:39 -070021#include <linux/sizes.h>
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070022OUTPUT_ARCH(riscv)
23ENTRY(_start)
24
25jiffies = jiffies_64;
26
Atish Patracb7d2dd2020-09-17 15:37:13 -070027PECOFF_SECTION_ALIGNMENT = 0x1000;
28PECOFF_FILE_ALIGNMENT = 0x200;
29
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070030SECTIONS
31{
32 /* Beginning of code and text segment */
33 . = LOAD_OFFSET;
34 _start = .;
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070035 HEAD_TEXT_SECTION
Atish Patrae0119952020-03-17 18:11:39 -070036 . = ALIGN(PAGE_SIZE);
37
Atish Patra19a00862020-11-04 16:04:38 -080038 .text : {
39 _text = .;
40 _stext = .;
41 TEXT_TEXT
42 SCHED_TEXT
43 CPUIDLE_TEXT
44 LOCK_TEXT
45 KPROBES_TEXT
46 ENTRY_TEXT
47 IRQENTRY_TEXT
48 SOFTIRQENTRY_TEXT
49 *(.fixup)
50 _etext = .;
51 }
52
53 . = ALIGN(SECTION_ALIGN);
Atish Patrae0119952020-03-17 18:11:39 -070054 __init_begin = .;
Atish Patrab6566dc2020-11-04 16:04:37 -080055 __init_text_begin = .;
56 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) ALIGN(SECTION_ALIGN) { \
57 _sinittext = .; \
58 INIT_TEXT \
59 _einittext = .; \
60 }
61
Damien Le Moal335b1392020-03-16 09:47:38 +090062 . = 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 }
Palmer Dabbelt2d268252020-04-14 13:43:24 +090068 __soc_builtin_dtb_table : {
69 __soc_builtin_dtb_table_start = .;
70 KEEP(*(__soc_builtin_dtb_table))
71 __soc_builtin_dtb_table_end = .;
72 }
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070073 /* we have to discard exit text and such at runtime, not link time */
74 .exit.text :
75 {
76 EXIT_TEXT
77 }
Atish Patra19a00862020-11-04 16:04:38 -080078
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)
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070088 .exit.data :
89 {
90 EXIT_DATA
91 }
92 PERCPU_SECTION(L1_CACHE_BYTES)
Atish Patra19a00862020-11-04 16:04:38 -080093
Atish Patrab5b11a82020-11-04 16:04:39 -080094 .rel.dyn : {
95 *(.rel.dyn*)
96 }
97
Atish Patra19a00862020-11-04 16:04:38 -080098 __init_data_end = .;
Vincent Chen6f4eea92021-03-22 22:26:03 +080099
100 . = ALIGN(8);
101 .alternative : {
102 __alt_start = .;
103 *(.alternative)
104 __alt_end = .;
105 }
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700106 __init_end = .;
107
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700108 /* Start of data section */
109 _sdata = .;
Zong Li00cb41d2020-03-10 00:55:40 +0800110 RO_DATA(SECTION_ALIGN)
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700111 .srodata : {
112 *(.srodata*)
113 }
114
Zong Libd3d9142020-03-10 00:55:39 +0800115 EXCEPTION_TABLE(0x10)
116
Zong Li00cb41d2020-03-10 00:55:40 +0800117 . = ALIGN(SECTION_ALIGN);
Zong Libd3d9142020-03-10 00:55:39 +0800118 _data = .;
119
Tong Tiangen31da94c2021-06-21 11:28:55 +0800120 RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN)
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700121 .sdata : {
122 __global_pointer$ = . + 0x800;
123 *(.sdata*)
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700124 }
125
Atish Patracb7d2dd2020-09-17 15:37:13 -0700126#ifdef CONFIG_EFI
127 .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
128 __pecoff_data_raw_size = ABSOLUTE(. - __pecoff_text_end);
129#endif
130
131 /* End of data section */
132 _edata = .;
133
Palmer Dabbelt41fb9d52019-02-08 09:11:08 -0800134 BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)
135
Atish Patracb7d2dd2020-09-17 15:37:13 -0700136#ifdef CONFIG_EFI
137 . = ALIGN(PECOFF_SECTION_ALIGNMENT);
138 __pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end);
139#endif
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700140 _end = .;
141
142 STABS_DEBUG
143 DWARF_DEBUG
Kees Cookc604abc2020-08-21 12:42:45 -0700144 ELF_DETAILS
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700145
146 DISCARDS
147}
Vitaly Wool44c92252021-04-13 02:35:14 -0400148#endif /* CONFIG_XIP_KERNEL */