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