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 __exittext_begin = .; 33 .exit.text : 34 { 35 EXIT_TEXT 36 } 37 __exittext_end = .; 38 39 .text : { 40 _text = .; 41 _stext = .; 42 TEXT_TEXT 43 SCHED_TEXT 44 LOCK_TEXT 45 KPROBES_TEXT 46 ENTRY_TEXT 47 IRQENTRY_TEXT 48 SOFTIRQENTRY_TEXT 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(PAGE_SIZE); /* location in file */ 68 . = KERNEL_LINK_ADDR + XIP_OFFSET; /* location in memory */ 69 70#undef LOAD_OFFSET 71#define LOAD_OFFSET (KERNEL_LINK_ADDR + XIP_OFFSET - (__data_loc & XIP_OFFSET_MASK)) 72 73 _sdata = .; /* Start of data section */ 74 _data = .; 75 RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) 76 _edata = .; 77 __start_ro_after_init = .; 78 .data.ro_after_init : AT(ADDR(.data.ro_after_init) - LOAD_OFFSET) { 79 *(.data..ro_after_init) 80 } 81 __end_ro_after_init = .; 82 83 . = ALIGN(PAGE_SIZE); 84 __init_begin = .; 85 .init.data : { 86 INIT_DATA 87 } 88 .exit.data : { 89 EXIT_DATA 90 } 91 . = ALIGN(8); 92 __soc_early_init_table : { 93 __soc_early_init_table_start = .; 94 KEEP(*(__soc_early_init_table)) 95 __soc_early_init_table_end = .; 96 } 97 __soc_builtin_dtb_table : { 98 __soc_builtin_dtb_table_start = .; 99 KEEP(*(__soc_builtin_dtb_table)) 100 __soc_builtin_dtb_table_end = .; 101 } 102 103 __init_end = .; 104 105 . = ALIGN(16); 106 .xip.traps : { 107 __xip_traps_start = .; 108 *(.xip.traps) 109 __xip_traps_end = .; 110 } 111 112 . = ALIGN(PAGE_SIZE); 113 .sdata : { 114 __global_pointer$ = . + 0x800; 115 *(.sdata*) 116 *(.sbss*) 117 } 118 119 BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0) 120 121 PERCPU_SECTION(L1_CACHE_BYTES) 122 123 .rel.dyn : AT(ADDR(.rel.dyn) - LOAD_OFFSET) { 124 *(.rel.dyn*) 125 } 126 127 /* 128 * End of copied data. We need a dummy section to get its LMA. 129 * Also located before final ALIGN() as trailing padding is not stored 130 * in the resulting binary file and useless to copy. 131 */ 132 .data.endmark : AT(ADDR(.data.endmark) - LOAD_OFFSET) { } 133 _edata_loc = LOADADDR(.data.endmark); 134 135 . = ALIGN(PAGE_SIZE); 136 _end = .; 137 138 STABS_DEBUG 139 DWARF_DEBUG 140 141 DISCARDS 142} 143