Thomas Gleixner | 50acfb2 | 2019-05-29 07:18:00 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2012 Regents of the University of California |
| 4 | * Copyright (C) 2017 SiFive |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
Vitaly Wool | 44c9225 | 2021-04-13 02:35:14 -0400 | [diff] [blame] | 7 | #ifdef CONFIG_XIP_KERNEL |
| 8 | #include "vmlinux-xip.lds.S" |
| 9 | #else |
| 10 | |
Alexandre Ghiti | 2bfc6cd | 2021-04-11 12:41:44 -0400 | [diff] [blame] | 11 | #include <asm/pgtable.h> |
| 12 | #define LOAD_OFFSET KERNEL_LINK_ADDR |
Vitaly Wool | 44c9225 | 2021-04-13 02:35:14 -0400 | [diff] [blame] | 13 | |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 14 | #include <asm/vmlinux.lds.h> |
| 15 | #include <asm/page.h> |
| 16 | #include <asm/cache.h> |
| 17 | #include <asm/thread_info.h> |
Zong Li | 00cb41d | 2020-03-10 00:55:40 +0800 | [diff] [blame] | 18 | #include <asm/set_memory.h> |
Atish Patra | cb7d2dd | 2020-09-17 15:37:13 -0700 | [diff] [blame] | 19 | #include "image-vars.h" |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 20 | |
Atish Patra | e011995 | 2020-03-17 18:11:39 -0700 | [diff] [blame] | 21 | #include <linux/sizes.h> |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 22 | OUTPUT_ARCH(riscv) |
| 23 | ENTRY(_start) |
| 24 | |
| 25 | jiffies = jiffies_64; |
| 26 | |
Atish Patra | cb7d2dd | 2020-09-17 15:37:13 -0700 | [diff] [blame] | 27 | PECOFF_SECTION_ALIGNMENT = 0x1000; |
| 28 | PECOFF_FILE_ALIGNMENT = 0x200; |
| 29 | |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 30 | SECTIONS |
| 31 | { |
| 32 | /* Beginning of code and text segment */ |
| 33 | . = LOAD_OFFSET; |
| 34 | _start = .; |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 35 | HEAD_TEXT_SECTION |
Atish Patra | e011995 | 2020-03-17 18:11:39 -0700 | [diff] [blame] | 36 | . = ALIGN(PAGE_SIZE); |
| 37 | |
Atish Patra | 19a0086 | 2020-11-04 16:04:38 -0800 | [diff] [blame] | 38 | .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 Patra | e011995 | 2020-03-17 18:11:39 -0700 | [diff] [blame] | 54 | __init_begin = .; |
Atish Patra | b6566dc | 2020-11-04 16:04:37 -0800 | [diff] [blame] | 55 | __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 Moal | 335b139 | 2020-03-16 09:47:38 +0900 | [diff] [blame] | 62 | . = 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 Dabbelt | 2d26825 | 2020-04-14 13:43:24 +0900 | [diff] [blame] | 68 | __soc_builtin_dtb_table : { |
| 69 | __soc_builtin_dtb_table_start = .; |
| 70 | KEEP(*(__soc_builtin_dtb_table)) |
| 71 | __soc_builtin_dtb_table_end = .; |
| 72 | } |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 73 | /* we have to discard exit text and such at runtime, not link time */ |
| 74 | .exit.text : |
| 75 | { |
| 76 | EXIT_TEXT |
| 77 | } |
Atish Patra | 19a0086 | 2020-11-04 16:04:38 -0800 | [diff] [blame] | 78 | |
| 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 Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 88 | .exit.data : |
| 89 | { |
| 90 | EXIT_DATA |
| 91 | } |
| 92 | PERCPU_SECTION(L1_CACHE_BYTES) |
Atish Patra | 19a0086 | 2020-11-04 16:04:38 -0800 | [diff] [blame] | 93 | |
Atish Patra | b5b11a8 | 2020-11-04 16:04:39 -0800 | [diff] [blame] | 94 | .rel.dyn : { |
| 95 | *(.rel.dyn*) |
| 96 | } |
| 97 | |
Atish Patra | 19a0086 | 2020-11-04 16:04:38 -0800 | [diff] [blame] | 98 | __init_data_end = .; |
Vincent Chen | 6f4eea9 | 2021-03-22 22:26:03 +0800 | [diff] [blame] | 99 | |
| 100 | . = ALIGN(8); |
| 101 | .alternative : { |
| 102 | __alt_start = .; |
| 103 | *(.alternative) |
| 104 | __alt_end = .; |
| 105 | } |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 106 | __init_end = .; |
| 107 | |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 108 | /* Start of data section */ |
| 109 | _sdata = .; |
Zong Li | 00cb41d | 2020-03-10 00:55:40 +0800 | [diff] [blame] | 110 | RO_DATA(SECTION_ALIGN) |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 111 | .srodata : { |
| 112 | *(.srodata*) |
| 113 | } |
| 114 | |
Zong Li | bd3d914 | 2020-03-10 00:55:39 +0800 | [diff] [blame] | 115 | EXCEPTION_TABLE(0x10) |
| 116 | |
Zong Li | 00cb41d | 2020-03-10 00:55:40 +0800 | [diff] [blame] | 117 | . = ALIGN(SECTION_ALIGN); |
Zong Li | bd3d914 | 2020-03-10 00:55:39 +0800 | [diff] [blame] | 118 | _data = .; |
| 119 | |
Tong Tiangen | 31da94c | 2021-06-21 11:28:55 +0800 | [diff] [blame^] | 120 | RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN) |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 121 | .sdata : { |
| 122 | __global_pointer$ = . + 0x800; |
| 123 | *(.sdata*) |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 124 | } |
| 125 | |
Atish Patra | cb7d2dd | 2020-09-17 15:37:13 -0700 | [diff] [blame] | 126 | #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 Dabbelt | 41fb9d5 | 2019-02-08 09:11:08 -0800 | [diff] [blame] | 134 | BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0) |
| 135 | |
Atish Patra | cb7d2dd | 2020-09-17 15:37:13 -0700 | [diff] [blame] | 136 | #ifdef CONFIG_EFI |
| 137 | . = ALIGN(PECOFF_SECTION_ALIGNMENT); |
| 138 | __pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end); |
| 139 | #endif |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 140 | _end = .; |
| 141 | |
| 142 | STABS_DEBUG |
| 143 | DWARF_DEBUG |
Kees Cook | c604abc | 2020-08-21 12:42:45 -0700 | [diff] [blame] | 144 | ELF_DETAILS |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 145 | |
| 146 | DISCARDS |
| 147 | } |
Vitaly Wool | 44c9225 | 2021-04-13 02:35:14 -0400 | [diff] [blame] | 148 | #endif /* CONFIG_XIP_KERNEL */ |