150acfb2bSThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-only */ 2fbe934d6SPalmer Dabbelt/* 3fbe934d6SPalmer Dabbelt * Copyright (C) 2012 Regents of the University of California 4fbe934d6SPalmer Dabbelt * Copyright (C) 2017 SiFive 5fbe934d6SPalmer Dabbelt */ 6fbe934d6SPalmer Dabbelt 72bf847dbSJisheng Zhang#define RO_EXCEPTION_TABLE_ALIGN 4 87e92586cSJisheng Zhang#define RUNTIME_DISCARD_EXIT 96f55ab36SJisheng Zhang 1044c92257SVitaly Wool#ifdef CONFIG_XIP_KERNEL 1144c92257SVitaly Wool#include "vmlinux-xip.lds.S" 1244c92257SVitaly Wool#else 1344c92257SVitaly Wool 142bfc6cd8SAlexandre Ghiti#include <asm/pgtable.h> 152bfc6cd8SAlexandre Ghiti#define LOAD_OFFSET KERNEL_LINK_ADDR 1644c92257SVitaly Wool 17fbe934d6SPalmer Dabbelt#include <asm/vmlinux.lds.h> 18fbe934d6SPalmer Dabbelt#include <asm/page.h> 19fbe934d6SPalmer Dabbelt#include <asm/cache.h> 20fbe934d6SPalmer Dabbelt#include <asm/thread_info.h> 2100cb41d5SZong Li#include <asm/set_memory.h> 22cb7d2dd5SAtish Patra#include "image-vars.h" 23fbe934d6SPalmer Dabbelt 24e011995eSAtish Patra#include <linux/sizes.h> 25fbe934d6SPalmer DabbeltOUTPUT_ARCH(riscv) 26fbe934d6SPalmer DabbeltENTRY(_start) 27fbe934d6SPalmer Dabbelt 28fbe934d6SPalmer Dabbeltjiffies = jiffies_64; 29fbe934d6SPalmer Dabbelt 30fbe934d6SPalmer DabbeltSECTIONS 31fbe934d6SPalmer Dabbelt{ 32fbe934d6SPalmer Dabbelt /* Beginning of code and text segment */ 33fbe934d6SPalmer Dabbelt . = LOAD_OFFSET; 34fbe934d6SPalmer Dabbelt _start = .; 35fbe934d6SPalmer Dabbelt HEAD_TEXT_SECTION 36e011995eSAtish Patra . = ALIGN(PAGE_SIZE); 37e011995eSAtish Patra 3819a00869SAtish Patra .text : { 3919a00869SAtish Patra _text = .; 4019a00869SAtish Patra _stext = .; 4119a00869SAtish Patra TEXT_TEXT 4219a00869SAtish Patra SCHED_TEXT 4319a00869SAtish Patra LOCK_TEXT 4419a00869SAtish Patra KPROBES_TEXT 4519a00869SAtish Patra ENTRY_TEXT 4619a00869SAtish Patra IRQENTRY_TEXT 4719a00869SAtish Patra SOFTIRQENTRY_TEXT 4819a00869SAtish Patra _etext = .; 4919a00869SAtish Patra } 5019a00869SAtish Patra 5119a00869SAtish Patra . = ALIGN(SECTION_ALIGN); 52e011995eSAtish Patra __init_begin = .; 53b6566dc1SAtish Patra __init_text_begin = .; 54b6566dc1SAtish Patra .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) ALIGN(SECTION_ALIGN) { \ 55b6566dc1SAtish Patra _sinittext = .; \ 56b6566dc1SAtish Patra INIT_TEXT \ 57b6566dc1SAtish Patra _einittext = .; \ 58b6566dc1SAtish Patra } 59b6566dc1SAtish Patra 60335b1390SDamien Le Moal . = ALIGN(8); 61335b1390SDamien Le Moal __soc_early_init_table : { 62335b1390SDamien Le Moal __soc_early_init_table_start = .; 63335b1390SDamien Le Moal KEEP(*(__soc_early_init_table)) 64335b1390SDamien Le Moal __soc_early_init_table_end = .; 65335b1390SDamien Le Moal } 662d268251SPalmer Dabbelt __soc_builtin_dtb_table : { 672d268251SPalmer Dabbelt __soc_builtin_dtb_table_start = .; 682d268251SPalmer Dabbelt KEEP(*(__soc_builtin_dtb_table)) 692d268251SPalmer Dabbelt __soc_builtin_dtb_table_end = .; 702d268251SPalmer Dabbelt } 71fbe934d6SPalmer Dabbelt /* we have to discard exit text and such at runtime, not link time */ 72*8db56df4SAlexandre Ghiti __exittext_begin = .; 73fbe934d6SPalmer Dabbelt .exit.text : 74fbe934d6SPalmer Dabbelt { 75fbe934d6SPalmer Dabbelt EXIT_TEXT 76fbe934d6SPalmer Dabbelt } 77*8db56df4SAlexandre Ghiti __exittext_end = .; 7819a00869SAtish Patra 7919a00869SAtish Patra __init_text_end = .; 8019a00869SAtish Patra . = ALIGN(SECTION_ALIGN); 8119a00869SAtish Patra#ifdef CONFIG_EFI 8219a00869SAtish Patra . = ALIGN(PECOFF_SECTION_ALIGNMENT); 8319a00869SAtish Patra __pecoff_text_end = .; 8419a00869SAtish Patra#endif 8519a00869SAtish Patra /* Start of init data section */ 8619a00869SAtish Patra __init_data_begin = .; 8719a00869SAtish Patra INIT_DATA_SECTION(16) 8826e7aacbSAlexandre Ghiti 893b90b09aSAlexandre Ghiti .init.pi : { 90c828856bSZhangjin Wu KEEP(*(.init.pi*)) 9126e7aacbSAlexandre Ghiti } 9226e7aacbSAlexandre Ghiti 930ed0031bSJisheng Zhang .init.bss : { 94c828856bSZhangjin Wu KEEP(*(.init.bss*)) /* from the EFI stub */ 950ed0031bSJisheng Zhang } 96fbe934d6SPalmer Dabbelt .exit.data : 97fbe934d6SPalmer Dabbelt { 98fbe934d6SPalmer Dabbelt EXIT_DATA 99fbe934d6SPalmer Dabbelt } 100fbe934d6SPalmer Dabbelt PERCPU_SECTION(L1_CACHE_BYTES) 10119a00869SAtish Patra 102b5b11a8aSAtish Patra .rel.dyn : { 103b5b11a8aSAtish Patra *(.rel.dyn*) 104b5b11a8aSAtish Patra } 105b5b11a8aSAtish Patra 1064db9e253SAlexandre Ghiti .rela.dyn : ALIGN(8) { 1074db9e253SAlexandre Ghiti __rela_dyn_start = .; 1084db9e253SAlexandre Ghiti *(.rela .rela*) 1094db9e253SAlexandre Ghiti __rela_dyn_end = .; 1104db9e253SAlexandre Ghiti } 1114db9e253SAlexandre Ghiti 11219a00869SAtish Patra __init_data_end = .; 1136f4eea90SVincent Chen 1146f4eea90SVincent Chen . = ALIGN(8); 1156f4eea90SVincent Chen .alternative : { 1166f4eea90SVincent Chen __alt_start = .; 117c828856bSZhangjin Wu KEEP(*(.alternative)) 1186f4eea90SVincent Chen __alt_end = .; 1196f4eea90SVincent Chen } 120fbe934d6SPalmer Dabbelt __init_end = .; 121fbe934d6SPalmer Dabbelt 122fbe934d6SPalmer Dabbelt /* Start of data section */ 123fbe934d6SPalmer Dabbelt _sdata = .; 12400cb41d5SZong Li RO_DATA(SECTION_ALIGN) 125fbe934d6SPalmer Dabbelt .srodata : { 126fbe934d6SPalmer Dabbelt *(.srodata*) 127fbe934d6SPalmer Dabbelt } 128fbe934d6SPalmer Dabbelt 12900cb41d5SZong Li . = ALIGN(SECTION_ALIGN); 130bd3d914dSZong Li _data = .; 131bd3d914dSZong Li 13231da94c2STong Tiangen RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN) 133fbe934d6SPalmer Dabbelt .sdata : { 134fbe934d6SPalmer Dabbelt __global_pointer$ = . + 0x800; 135fbe934d6SPalmer Dabbelt *(.sdata*) 136cb7d2dd5SAtish Patra } 137cb7d2dd5SAtish Patra 13826e7aacbSAlexandre Ghiti .got : { *(.got*) } 13926e7aacbSAlexandre Ghiti 14039b33072SAlexandre Ghiti#ifdef CONFIG_RELOCATABLE 14139b33072SAlexandre Ghiti .data.rel : { *(.data.rel*) } 14239b33072SAlexandre Ghiti .plt : { *(.plt) } 14339b33072SAlexandre Ghiti .dynamic : { *(.dynamic) } 14439b33072SAlexandre Ghiti .dynsym : { *(.dynsym) } 14539b33072SAlexandre Ghiti .dynstr : { *(.dynstr) } 14639b33072SAlexandre Ghiti .hash : { *(.hash) } 14739b33072SAlexandre Ghiti .gnu.hash : { *(.gnu.hash) } 14839b33072SAlexandre Ghiti#endif 14939b33072SAlexandre Ghiti 150cb7d2dd5SAtish Patra#ifdef CONFIG_EFI 151cb7d2dd5SAtish Patra .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); } 152cb7d2dd5SAtish Patra __pecoff_data_raw_size = ABSOLUTE(. - __pecoff_text_end); 15355de1e4aSAlexandre Ghiti __pecoff_data_raw_end = ABSOLUTE(.); 154cb7d2dd5SAtish Patra#endif 155cb7d2dd5SAtish Patra 156fbe934d6SPalmer Dabbelt /* End of data section */ 157fbe934d6SPalmer Dabbelt _edata = .; 158fbe934d6SPalmer Dabbelt 15941fb9d54SPalmer Dabbelt BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0) 16041fb9d54SPalmer Dabbelt 161cb7d2dd5SAtish Patra#ifdef CONFIG_EFI 162cb7d2dd5SAtish Patra . = ALIGN(PECOFF_SECTION_ALIGNMENT); 163cb7d2dd5SAtish Patra __pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end); 16455de1e4aSAlexandre Ghiti __pecoff_data_virt_end = ABSOLUTE(.); 165cb7d2dd5SAtish Patra#endif 166fbe934d6SPalmer Dabbelt _end = .; 167fbe934d6SPalmer Dabbelt 168fbe934d6SPalmer Dabbelt STABS_DEBUG 169fbe934d6SPalmer Dabbelt DWARF_DEBUG 170c604abc3SKees Cook ELF_DETAILS 171b13e64d9SJisheng Zhang .riscv.attributes 0 : { *(.riscv.attributes) } 172fbe934d6SPalmer Dabbelt 173fbe934d6SPalmer Dabbelt DISCARDS 174fbe934d6SPalmer Dabbelt} 17544c92257SVitaly Wool#endif /* CONFIG_XIP_KERNEL */ 176