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 9#ifdef CONFIG_XIP_KERNEL 10#include "vmlinux-xip.lds.S" 11#else 12 13#include <asm/pgtable.h> 14#define LOAD_OFFSET KERNEL_LINK_ADDR 15 16#include <asm/vmlinux.lds.h> 17#include <asm/page.h> 18#include <asm/cache.h> 19#include <asm/thread_info.h> 20#include <asm/set_memory.h> 21#include "image-vars.h" 22 23#include <linux/sizes.h> 24OUTPUT_ARCH(riscv) 25ENTRY(_start) 26 27jiffies = jiffies_64; 28 29PECOFF_SECTION_ALIGNMENT = 0x1000; 30PECOFF_FILE_ALIGNMENT = 0x200; 31 32SECTIONS 33{ 34 /* Beginning of code and text segment */ 35 . = LOAD_OFFSET; 36 _start = .; 37 HEAD_TEXT_SECTION 38 . = ALIGN(PAGE_SIZE); 39 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 51 _etext = .; 52 } 53 54 . = ALIGN(SECTION_ALIGN); 55 __init_begin = .; 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 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 } 69 __soc_builtin_dtb_table : { 70 __soc_builtin_dtb_table_start = .; 71 KEEP(*(__soc_builtin_dtb_table)) 72 __soc_builtin_dtb_table_end = .; 73 } 74 /* we have to discard exit text and such at runtime, not link time */ 75 .exit.text : 76 { 77 EXIT_TEXT 78 } 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) 89 .exit.data : 90 { 91 EXIT_DATA 92 } 93 PERCPU_SECTION(L1_CACHE_BYTES) 94 95 .rel.dyn : { 96 *(.rel.dyn*) 97 } 98 99 __init_data_end = .; 100 101 . = ALIGN(8); 102 .alternative : { 103 __alt_start = .; 104 *(.alternative) 105 __alt_end = .; 106 } 107 __init_end = .; 108 109 /* Start of data section */ 110 _sdata = .; 111 RO_DATA(SECTION_ALIGN) 112 .srodata : { 113 *(.srodata*) 114 } 115 116 . = ALIGN(SECTION_ALIGN); 117 _data = .; 118 119 RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN) 120 .sdata : { 121 __global_pointer$ = . + 0x800; 122 *(.sdata*) 123 } 124 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 133 BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0) 134 135#ifdef CONFIG_EFI 136 . = ALIGN(PECOFF_SECTION_ALIGNMENT); 137 __pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end); 138#endif 139 _end = .; 140 141 STABS_DEBUG 142 DWARF_DEBUG 143 ELF_DETAILS 144 145 DISCARDS 146} 147#endif /* CONFIG_XIP_KERNEL */ 148