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 | |
| 7 | #define LOAD_OFFSET PAGE_OFFSET |
| 8 | #include <asm/vmlinux.lds.h> |
| 9 | #include <asm/page.h> |
| 10 | #include <asm/cache.h> |
| 11 | #include <asm/thread_info.h> |
Zong Li | 00cb41d | 2020-03-10 00:55:40 +0800 | [diff] [blame] | 12 | #include <asm/set_memory.h> |
Atish Patra | cb7d2dd | 2020-09-17 15:37:13 -0700 | [diff] [blame] | 13 | #include "image-vars.h" |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 14 | |
Atish Patra | e011995 | 2020-03-17 18:11:39 -0700 | [diff] [blame] | 15 | #include <linux/sizes.h> |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 16 | OUTPUT_ARCH(riscv) |
| 17 | ENTRY(_start) |
| 18 | |
| 19 | jiffies = jiffies_64; |
| 20 | |
Atish Patra | cb7d2dd | 2020-09-17 15:37:13 -0700 | [diff] [blame] | 21 | PECOFF_SECTION_ALIGNMENT = 0x1000; |
| 22 | PECOFF_FILE_ALIGNMENT = 0x200; |
| 23 | |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 24 | SECTIONS |
| 25 | { |
| 26 | /* Beginning of code and text segment */ |
| 27 | . = LOAD_OFFSET; |
| 28 | _start = .; |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 29 | HEAD_TEXT_SECTION |
Atish Patra | e011995 | 2020-03-17 18:11:39 -0700 | [diff] [blame] | 30 | . = ALIGN(PAGE_SIZE); |
| 31 | |
| 32 | __init_begin = .; |
Atish Patra | b6566dc | 2020-11-04 16:04:37 -0800 | [diff] [blame^] | 33 | __init_text_begin = .; |
| 34 | .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) ALIGN(SECTION_ALIGN) { \ |
| 35 | _sinittext = .; \ |
| 36 | INIT_TEXT \ |
| 37 | _einittext = .; \ |
| 38 | } |
| 39 | |
Damien Le Moal | 335b139 | 2020-03-16 09:47:38 +0900 | [diff] [blame] | 40 | . = ALIGN(8); |
| 41 | __soc_early_init_table : { |
| 42 | __soc_early_init_table_start = .; |
| 43 | KEEP(*(__soc_early_init_table)) |
| 44 | __soc_early_init_table_end = .; |
| 45 | } |
Palmer Dabbelt | 2d26825 | 2020-04-14 13:43:24 +0900 | [diff] [blame] | 46 | __soc_builtin_dtb_table : { |
| 47 | __soc_builtin_dtb_table_start = .; |
| 48 | KEEP(*(__soc_builtin_dtb_table)) |
| 49 | __soc_builtin_dtb_table_end = .; |
| 50 | } |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 51 | /* we have to discard exit text and such at runtime, not link time */ |
| 52 | .exit.text : |
| 53 | { |
| 54 | EXIT_TEXT |
| 55 | } |
| 56 | .exit.data : |
| 57 | { |
| 58 | EXIT_DATA |
| 59 | } |
| 60 | PERCPU_SECTION(L1_CACHE_BYTES) |
| 61 | __init_end = .; |
| 62 | |
Zong Li | 00cb41d | 2020-03-10 00:55:40 +0800 | [diff] [blame] | 63 | . = ALIGN(SECTION_ALIGN); |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 64 | .text : { |
| 65 | _text = .; |
Guo Ren | 8481446 | 2020-10-06 16:49:33 +0000 | [diff] [blame] | 66 | _stext = .; |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 67 | TEXT_TEXT |
| 68 | SCHED_TEXT |
| 69 | CPUIDLE_TEXT |
| 70 | LOCK_TEXT |
| 71 | KPROBES_TEXT |
| 72 | ENTRY_TEXT |
| 73 | IRQENTRY_TEXT |
Nick Hu | 8ad8b72 | 2020-01-06 10:38:32 -0800 | [diff] [blame] | 74 | SOFTIRQENTRY_TEXT |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 75 | *(.fixup) |
| 76 | _etext = .; |
| 77 | } |
| 78 | |
Atish Patra | cb7d2dd | 2020-09-17 15:37:13 -0700 | [diff] [blame] | 79 | #ifdef CONFIG_EFI |
| 80 | . = ALIGN(PECOFF_SECTION_ALIGNMENT); |
| 81 | __pecoff_text_end = .; |
| 82 | #endif |
| 83 | |
Guo Ren | 8481446 | 2020-10-06 16:49:33 +0000 | [diff] [blame] | 84 | INIT_DATA_SECTION(16) |
| 85 | |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 86 | /* Start of data section */ |
| 87 | _sdata = .; |
Zong Li | 00cb41d | 2020-03-10 00:55:40 +0800 | [diff] [blame] | 88 | RO_DATA(SECTION_ALIGN) |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 89 | .srodata : { |
| 90 | *(.srodata*) |
| 91 | } |
| 92 | |
Zong Li | bd3d914 | 2020-03-10 00:55:39 +0800 | [diff] [blame] | 93 | EXCEPTION_TABLE(0x10) |
| 94 | |
Zong Li | 00cb41d | 2020-03-10 00:55:40 +0800 | [diff] [blame] | 95 | . = ALIGN(SECTION_ALIGN); |
Zong Li | bd3d914 | 2020-03-10 00:55:39 +0800 | [diff] [blame] | 96 | _data = .; |
| 97 | |
Kees Cook | c917404 | 2019-10-29 14:13:35 -0700 | [diff] [blame] | 98 | RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 99 | .sdata : { |
| 100 | __global_pointer$ = . + 0x800; |
| 101 | *(.sdata*) |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 102 | } |
| 103 | |
Atish Patra | cb7d2dd | 2020-09-17 15:37:13 -0700 | [diff] [blame] | 104 | #ifdef CONFIG_EFI |
| 105 | .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); } |
| 106 | __pecoff_data_raw_size = ABSOLUTE(. - __pecoff_text_end); |
| 107 | #endif |
| 108 | |
| 109 | /* End of data section */ |
| 110 | _edata = .; |
| 111 | |
Palmer Dabbelt | 41fb9d5 | 2019-02-08 09:11:08 -0800 | [diff] [blame] | 112 | BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0) |
| 113 | |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 114 | .rel.dyn : { |
| 115 | *(.rel.dyn*) |
| 116 | } |
| 117 | |
Atish Patra | cb7d2dd | 2020-09-17 15:37:13 -0700 | [diff] [blame] | 118 | #ifdef CONFIG_EFI |
| 119 | . = ALIGN(PECOFF_SECTION_ALIGNMENT); |
| 120 | __pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end); |
| 121 | #endif |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 122 | _end = .; |
| 123 | |
| 124 | STABS_DEBUG |
| 125 | DWARF_DEBUG |
Kees Cook | c604abc | 2020-08-21 12:42:45 -0700 | [diff] [blame] | 126 | ELF_DETAILS |
Palmer Dabbelt | fbe934d | 2017-07-10 18:08:08 -0700 | [diff] [blame] | 127 | |
| 128 | DISCARDS |
| 129 | } |