1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Copyright (C) 2012 Regents of the University of California 4 * Copyright (C) 2017 SiFive 5 */ 6 7#define RO_EXCEPTION_TABLE_ALIGN 4 8#define RUNTIME_DISCARD_EXIT 9 10#ifdef CONFIG_XIP_KERNEL 11#include "vmlinux-xip.lds.S" 12#else 13 14#include <asm/pgtable.h> 15#define LOAD_OFFSET KERNEL_LINK_ADDR 16 17#include <asm/vmlinux.lds.h> 18#include <asm/page.h> 19#include <asm/cache.h> 20#include <asm/thread_info.h> 21#include <asm/set_memory.h> 22#include "image-vars.h" 23 24#include <linux/sizes.h> 25OUTPUT_ARCH(riscv) 26ENTRY(_start) 27 28jiffies = jiffies_64; 29 30SECTIONS 31{ 32 /* Beginning of code and text segment */ 33 . = LOAD_OFFSET; 34 _start = .; 35 HEAD_TEXT_SECTION 36 . = ALIGN(PAGE_SIZE); 37 38 .text : { 39 _text = .; 40 _stext = .; 41 TEXT_TEXT 42 SCHED_TEXT 43 LOCK_TEXT 44 KPROBES_TEXT 45 ENTRY_TEXT 46 IRQENTRY_TEXT 47 SOFTIRQENTRY_TEXT 48 _etext = .; 49 } 50 51 . = ALIGN(SECTION_ALIGN); 52 __init_begin = .; 53 __init_text_begin = .; 54 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) ALIGN(SECTION_ALIGN) { \ 55 _sinittext = .; \ 56 INIT_TEXT \ 57 _einittext = .; \ 58 } 59 60 . = ALIGN(8); 61 __soc_early_init_table : { 62 __soc_early_init_table_start = .; 63 KEEP(*(__soc_early_init_table)) 64 __soc_early_init_table_end = .; 65 } 66 __soc_builtin_dtb_table : { 67 __soc_builtin_dtb_table_start = .; 68 KEEP(*(__soc_builtin_dtb_table)) 69 __soc_builtin_dtb_table_end = .; 70 } 71 /* we have to discard exit text and such at runtime, not link time */ 72 __exittext_begin = .; 73 .exit.text : 74 { 75 EXIT_TEXT 76 } 77 __exittext_end = .; 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) 88 89 .init.pi : { 90 KEEP(*(.init.pi*)) 91 } 92 93 .init.bss : { 94 KEEP(*(.init.bss*)) /* from the EFI stub */ 95 } 96 .exit.data : 97 { 98 EXIT_DATA 99 } 100 101 RUNTIME_CONST_VARIABLES 102 103 PERCPU_SECTION(L1_CACHE_BYTES) 104 105 .rel.dyn : { 106 *(.rel.dyn*) 107 } 108 109 .rela.dyn : ALIGN(8) { 110 __rela_dyn_start = .; 111 *(.rela .rela*) 112 __rela_dyn_end = .; 113 } 114 115 __init_data_end = .; 116 117 . = ALIGN(8); 118 .alternative : { 119 __alt_start = .; 120 KEEP(*(.alternative)) 121 __alt_end = .; 122 } 123 __init_end = .; 124 125 /* Start of data section */ 126 _sdata = .; 127 RO_DATA(SECTION_ALIGN) 128 .srodata : { 129 *(.srodata*) 130 } 131 132 . = ALIGN(SECTION_ALIGN); 133 _data = .; 134 135 RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN) 136 .sdata : { 137 __global_pointer$ = . + 0x800; 138 *(.sdata*) 139 } 140 141 .got : { *(.got*) } 142 143#ifdef CONFIG_RELOCATABLE 144 .data.rel : { *(.data.rel*) } 145 .plt : { *(.plt) } 146 .dynamic : { *(.dynamic) } 147 .dynsym : { *(.dynsym) } 148 .dynstr : { *(.dynstr) } 149 .hash : { *(.hash) } 150 .gnu.hash : { *(.gnu.hash) } 151#endif 152 153#ifdef CONFIG_EFI 154 .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); } 155 __pecoff_data_raw_size = ABSOLUTE(. - __pecoff_text_end); 156 __pecoff_data_raw_end = ABSOLUTE(.); 157#endif 158 159 /* End of data section */ 160 _edata = .; 161 162 BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0) 163 164#ifdef CONFIG_EFI 165 . = ALIGN(PECOFF_SECTION_ALIGNMENT); 166 __pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end); 167 __pecoff_data_virt_end = ABSOLUTE(.); 168#endif 169 _end = .; 170 171 STABS_DEBUG 172 DWARF_DEBUG 173 ELF_DETAILS 174 .riscv.attributes 0 : { *(.riscv.attributes) } 175 176 DISCARDS 177} 178#endif /* CONFIG_XIP_KERNEL */ 179