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 * Copyright (C) 2020 Vitaly Wool, Konsulko AB 6 */ 7 8#include <asm/pgtable.h> 9#define LOAD_OFFSET KERNEL_LINK_ADDR 10/* No __ro_after_init data in the .rodata section - which will always be ro */ 11#define RO_AFTER_INIT_DATA 12 13#include <asm/vmlinux.lds.h> 14#include <asm/page.h> 15#include <asm/cache.h> 16#include <asm/thread_info.h> 17 18OUTPUT_ARCH(riscv) 19ENTRY(_start) 20 21jiffies = jiffies_64; 22 23SECTIONS 24{ 25 /* Beginning of code and text segment */ 26 . = LOAD_OFFSET; 27 _xiprom = .; 28 _start = .; 29 HEAD_TEXT_SECTION 30 INIT_TEXT_SECTION(PAGE_SIZE) 31 /* we have to discard exit text and such at runtime, not link time */ 32 .exit.text : 33 { 34 EXIT_TEXT 35 } 36 37 .text : { 38 _text = .; 39 _stext = .; 40 TEXT_TEXT 41 SCHED_TEXT 42 CPUIDLE_TEXT 43 LOCK_TEXT 44 KPROBES_TEXT 45 ENTRY_TEXT 46 IRQENTRY_TEXT 47 SOFTIRQENTRY_TEXT 48 *(.fixup) 49 _etext = .; 50 } 51 RO_DATA(L1_CACHE_BYTES) 52 .srodata : { 53 *(.srodata*) 54 } 55 .init.rodata : { 56 INIT_SETUP(16) 57 INIT_CALLS 58 CON_INITCALL 59 INIT_RAM_FS 60 } 61 _exiprom = .; /* End of XIP ROM area */ 62 63 64/* 65 * From this point, stuff is considered writable and will be copied to RAM 66 */ 67 __data_loc = ALIGN(16); /* location in file */ 68 . = LOAD_OFFSET + XIP_OFFSET; /* location in memory */ 69 70 _sdata = .; /* Start of data section */ 71 _data = .; 72 RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) 73 _edata = .; 74 __start_ro_after_init = .; 75 .data.ro_after_init : AT(ADDR(.data.ro_after_init) - LOAD_OFFSET) { 76 *(.data..ro_after_init) 77 } 78 __end_ro_after_init = .; 79 80 . = ALIGN(PAGE_SIZE); 81 __init_begin = .; 82 .init.data : { 83 INIT_DATA 84 } 85 .exit.data : { 86 EXIT_DATA 87 } 88 . = ALIGN(8); 89 __soc_early_init_table : { 90 __soc_early_init_table_start = .; 91 KEEP(*(__soc_early_init_table)) 92 __soc_early_init_table_end = .; 93 } 94 __soc_builtin_dtb_table : { 95 __soc_builtin_dtb_table_start = .; 96 KEEP(*(__soc_builtin_dtb_table)) 97 __soc_builtin_dtb_table_end = .; 98 } 99 PERCPU_SECTION(L1_CACHE_BYTES) 100 101 . = ALIGN(8); 102 .alternative : { 103 __alt_start = .; 104 *(.alternative) 105 __alt_end = .; 106 } 107 __init_end = .; 108 109 . = ALIGN(16); 110 .xip.traps : { 111 __xip_traps_start = .; 112 *(.xip.traps) 113 __xip_traps_end = .; 114 } 115 116 . = ALIGN(PAGE_SIZE); 117 .sdata : { 118 __global_pointer$ = . + 0x800; 119 *(.sdata*) 120 *(.sbss*) 121 } 122 123 BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0) 124 125 .rel.dyn : AT(ADDR(.rel.dyn) - LOAD_OFFSET) { 126 *(.rel.dyn*) 127 } 128 129 /* 130 * End of copied data. We need a dummy section to get its LMA. 131 * Also located before final ALIGN() as trailing padding is not stored 132 * in the resulting binary file and useless to copy. 133 */ 134 .data.endmark : AT(ADDR(.data.endmark) - LOAD_OFFSET) { } 135 _edata_loc = LOADADDR(.data.endmark); 136 137 . = ALIGN(PAGE_SIZE); 138 _end = .; 139 140 STABS_DEBUG 141 DWARF_DEBUG 142 143 DISCARDS 144} 145