blob: 4e6c88aa4d87049c9bba77c0379491e2a5ae222f [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
Jisheng Zhang2bf847d2021-11-18 19:26:05 +08007#define RO_EXCEPTION_TABLE_ALIGN 4
Jisheng Zhang6f55ab32021-08-26 22:11:18 +08008
Vitaly Wool44c92252021-04-13 02:35:14 -04009#ifdef CONFIG_XIP_KERNEL
10#include "vmlinux-xip.lds.S"
11#else
12
Alexandre Ghiti2bfc6cd2021-04-11 12:41:44 -040013#include <asm/pgtable.h>
14#define LOAD_OFFSET KERNEL_LINK_ADDR
Vitaly Wool44c92252021-04-13 02:35:14 -040015
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070016#include <asm/vmlinux.lds.h>
17#include <asm/page.h>
18#include <asm/cache.h>
19#include <asm/thread_info.h>
Zong Li00cb41d2020-03-10 00:55:40 +080020#include <asm/set_memory.h>
Atish Patracb7d2dd2020-09-17 15:37:13 -070021#include "image-vars.h"
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070022
Atish Patrae0119952020-03-17 18:11:39 -070023#include <linux/sizes.h>
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070024OUTPUT_ARCH(riscv)
25ENTRY(_start)
26
27jiffies = jiffies_64;
28
Atish Patracb7d2dd2020-09-17 15:37:13 -070029PECOFF_SECTION_ALIGNMENT = 0x1000;
30PECOFF_FILE_ALIGNMENT = 0x200;
31
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070032SECTIONS
33{
34 /* Beginning of code and text segment */
35 . = LOAD_OFFSET;
36 _start = .;
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070037 HEAD_TEXT_SECTION
Atish Patrae0119952020-03-17 18:11:39 -070038 . = ALIGN(PAGE_SIZE);
39
Atish Patra19a00862020-11-04 16:04:38 -080040 .text : {
41 _text = .;
42 _stext = .;
43 TEXT_TEXT
44 SCHED_TEXT
45 CPUIDLE_TEXT
46 LOCK_TEXT
47 KPROBES_TEXT
48 ENTRY_TEXT
49 IRQENTRY_TEXT
50 SOFTIRQENTRY_TEXT
Atish Patra19a00862020-11-04 16:04:38 -080051 _etext = .;
52 }
53
54 . = ALIGN(SECTION_ALIGN);
Atish Patrae0119952020-03-17 18:11:39 -070055 __init_begin = .;
Atish Patrab6566dc2020-11-04 16:04:37 -080056 __init_text_begin = .;
57 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) ALIGN(SECTION_ALIGN) { \
58 _sinittext = .; \
59 INIT_TEXT \
60 _einittext = .; \
61 }
62
Damien Le Moal335b1392020-03-16 09:47:38 +090063 . = ALIGN(8);
64 __soc_early_init_table : {
65 __soc_early_init_table_start = .;
66 KEEP(*(__soc_early_init_table))
67 __soc_early_init_table_end = .;
68 }
Palmer Dabbelt2d268252020-04-14 13:43:24 +090069 __soc_builtin_dtb_table : {
70 __soc_builtin_dtb_table_start = .;
71 KEEP(*(__soc_builtin_dtb_table))
72 __soc_builtin_dtb_table_end = .;
73 }
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070074 /* we have to discard exit text and such at runtime, not link time */
75 .exit.text :
76 {
77 EXIT_TEXT
78 }
Atish Patra19a00862020-11-04 16:04:38 -080079
80 __init_text_end = .;
81 . = ALIGN(SECTION_ALIGN);
82#ifdef CONFIG_EFI
83 . = ALIGN(PECOFF_SECTION_ALIGNMENT);
84 __pecoff_text_end = .;
85#endif
86 /* Start of init data section */
87 __init_data_begin = .;
88 INIT_DATA_SECTION(16)
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070089 .exit.data :
90 {
91 EXIT_DATA
92 }
93 PERCPU_SECTION(L1_CACHE_BYTES)
Atish Patra19a00862020-11-04 16:04:38 -080094
Atish Patrab5b11a82020-11-04 16:04:39 -080095 .rel.dyn : {
96 *(.rel.dyn*)
97 }
98
Atish Patra19a00862020-11-04 16:04:38 -080099 __init_data_end = .;
Vincent Chen6f4eea92021-03-22 22:26:03 +0800100
101 . = ALIGN(8);
102 .alternative : {
103 __alt_start = .;
104 *(.alternative)
105 __alt_end = .;
106 }
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700107 __init_end = .;
108
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700109 /* Start of data section */
110 _sdata = .;
Zong Li00cb41d2020-03-10 00:55:40 +0800111 RO_DATA(SECTION_ALIGN)
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700112 .srodata : {
113 *(.srodata*)
114 }
115
Zong Li00cb41d2020-03-10 00:55:40 +0800116 . = ALIGN(SECTION_ALIGN);
Zong Libd3d9142020-03-10 00:55:39 +0800117 _data = .;
118
Tong Tiangen31da94c2021-06-21 11:28:55 +0800119 RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN)
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700120 .sdata : {
121 __global_pointer$ = . + 0x800;
122 *(.sdata*)
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700123 }
124
Atish Patracb7d2dd2020-09-17 15:37:13 -0700125#ifdef CONFIG_EFI
126 .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
127 __pecoff_data_raw_size = ABSOLUTE(. - __pecoff_text_end);
128#endif
129
130 /* End of data section */
131 _edata = .;
132
Palmer Dabbelt41fb9d52019-02-08 09:11:08 -0800133 BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)
134
Atish Patracb7d2dd2020-09-17 15:37:13 -0700135#ifdef CONFIG_EFI
136 . = ALIGN(PECOFF_SECTION_ALIGNMENT);
137 __pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end);
138#endif
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700139 _end = .;
140
141 STABS_DEBUG
142 DWARF_DEBUG
Kees Cookc604abc2020-08-21 12:42:45 -0700143 ELF_DETAILS
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700144
145 DISCARDS
146}
Vitaly Wool44c92252021-04-13 02:35:14 -0400147#endif /* CONFIG_XIP_KERNEL */