1b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */ 21da177e4SLinus Torvalds/* ld script to make s390 Linux kernel 31da177e4SLinus Torvalds * Written by Martin Schwidefsky (schwidefsky@de.ibm.com) 41da177e4SLinus Torvalds */ 51da177e4SLinus Torvalds 60778dc3aSHeiko Carstens#include <asm/thread_info.h> 752480ee5SSam Ravnborg#include <asm/page.h> 8de5012b4SIlya Leoshkevich#include <asm/ftrace.lds.h> 90ccb32c9SHeiko Carstens 100ccb32c9SHeiko Carstens/* 110ccb32c9SHeiko Carstens * Put .bss..swapper_pg_dir as the first thing in .bss. This will 120ccb32c9SHeiko Carstens * make sure it has 16k alignment. 130ccb32c9SHeiko Carstens */ 140290c9e3SHeiko Carstens#define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir) \ 150290c9e3SHeiko Carstens *(.bss..invalid_pg_dir) 160ccb32c9SHeiko Carstens 17b46650d5SVasily Gorbik#define RO_EXCEPTION_TABLE_ALIGN 16 18b46650d5SVasily Gorbik 19d07a980cSHeiko Carstens/* Handle ro_after_init data on our own. */ 20d07a980cSHeiko Carstens#define RO_AFTER_INIT_DATA 21d07a980cSHeiko Carstens 22a494398bSMasahiro Yamada#define RUNTIME_DISCARD_EXIT 23a494398bSMasahiro Yamada 24441110a5SKees Cook#define EMITS_PT_NOTE 25441110a5SKees Cook 261da177e4SLinus Torvalds#include <asm-generic/vmlinux.lds.h> 27d1b52a43SVasily Gorbik#include <asm/vmlinux.lds.h> 281da177e4SLinus Torvalds 291da177e4SLinus TorvaldsOUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390") 301da177e4SLinus TorvaldsOUTPUT_ARCH(s390:64-bit) 318282cd64SVasily GorbikENTRY(startup_continue) 321da177e4SLinus Torvaldsjiffies = jiffies_64; 331da177e4SLinus Torvalds 34ea29ee16SMartin SchwidefskyPHDRS { 35ea29ee16SMartin Schwidefsky text PT_LOAD FLAGS(5); /* R_E */ 36ea29ee16SMartin Schwidefsky data PT_LOAD FLAGS(7); /* RWE */ 37ea29ee16SMartin Schwidefsky note PT_NOTE FLAGS(0); /* ___ */ 38ea29ee16SMartin Schwidefsky} 39ea29ee16SMartin Schwidefsky 401da177e4SLinus TorvaldsSECTIONS 411da177e4SLinus Torvalds{ 42183ab05fSVasily Gorbik . = 0x100000; 431da177e4SLinus Torvalds .text : { 4424350fdaSVasily Gorbik _stext = .; /* Start of text section */ 4524350fdaSVasily Gorbik _text = .; /* Text and read-only data */ 462133bb8dSTim Abbott HEAD_TEXT 477664709bSSam Ravnborg TEXT_TEXT 481da177e4SLinus Torvalds SCHED_TEXT 491da177e4SLinus Torvalds LOCK_TEXT 504ba069b8SMichael Grundy KPROBES_TEXT 5188dbd203SHeiko Carstens IRQENTRY_TEXT 52be7635e7SAlexander Potapenko SOFTIRQENTRY_TEXT 53de5012b4SIlya Leoshkevich FTRACE_HOTPATCH_TRAMPOLINES_TEXT 5494cbc0eaSVasily Gorbik *(.text.*_indirect_*) 551da177e4SLinus Torvalds *(.gnu.warning) 5657d7f939SMartin Schwidefsky . = ALIGN(PAGE_SIZE); 571da177e4SLinus Torvalds _etext = .; /* End of text section */ 5824350fdaSVasily Gorbik } :text = 0x0700 591da177e4SLinus Torvalds 6093240b32SKees Cook RO_DATA(PAGE_SIZE) 611da177e4SLinus Torvalds 6252480ee5SSam Ravnborg . = ALIGN(PAGE_SIZE); 63dfcc3e6aSHeiko Carstens _sdata = .; /* Start of data section */ 64162e006eSHeiko Carstens 65d07a980cSHeiko Carstens . = ALIGN(PAGE_SIZE); 66d07a980cSHeiko Carstens __start_ro_after_init = .; 67d07a980cSHeiko Carstens .data..ro_after_init : { 68d07a980cSHeiko Carstens *(.data..ro_after_init) 6957d15877SArd Biesheuvel JUMP_TABLE_DATA 706434efbdSKees Cook } :data 71d07a980cSHeiko Carstens . = ALIGN(PAGE_SIZE); 72d07a980cSHeiko Carstens __end_ro_after_init = .; 73fe355b7fSHongjie Yang 74*fc9fabeeSHeiko Carstens .data.rel.ro : { 75*fc9fabeeSHeiko Carstens *(.data.rel.ro .data.rel.ro.*) 76*fc9fabeeSHeiko Carstens } 77*fc9fabeeSHeiko Carstens .got : { 78*fc9fabeeSHeiko Carstens __got_start = .; 79*fc9fabeeSHeiko Carstens *(.got) 80*fc9fabeeSHeiko Carstens __got_end = .; 81*fc9fabeeSHeiko Carstens } 82*fc9fabeeSHeiko Carstens 83c9174047SKees Cook RW_DATA(0x100, PAGE_SIZE, THREAD_SIZE) 84bf9921a9SGerald Schaefer BOOT_DATA_PRESERVED 851da177e4SLinus Torvalds 866bda6670SAlexander Egorenkov . = ALIGN(8); 878b5f08b4SHeiko Carstens .amode31.refs : { 88c78d0c74SHeiko Carstens _start_amode31_refs = .; 89c78d0c74SHeiko Carstens *(.amode31.refs) 90c78d0c74SHeiko Carstens _end_amode31_refs = .; 916bda6670SAlexander Egorenkov } 926bda6670SAlexander Egorenkov 9345d619bdSAlexander Gordeev . = ALIGN(PAGE_SIZE); 941da177e4SLinus Torvalds _edata = .; /* End of data section */ 951da177e4SLinus Torvalds 961da177e4SLinus Torvalds /* will be freed after init */ 9752480ee5SSam Ravnborg . = ALIGN(PAGE_SIZE); /* Init code and data */ 981da177e4SLinus Torvalds __init_begin = .; 9904a95f6dSNelson Elhage 10057d7f939SMartin Schwidefsky . = ALIGN(PAGE_SIZE); 10157d7f939SMartin Schwidefsky .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { 1021c21765cSMasahiro Yamada _sinittext = .; 10357d7f939SMartin Schwidefsky INIT_TEXT 10457d7f939SMartin Schwidefsky . = ALIGN(PAGE_SIZE); 1051c21765cSMasahiro Yamada _einittext = .; 10657d7f939SMartin Schwidefsky } 10704a95f6dSNelson Elhage 108c0007f1aSHeiko Carstens /* 109c0007f1aSHeiko Carstens * .exit.text is discarded at runtime, not link time, 110c0007f1aSHeiko Carstens * to deal with references from __bug_table 111c0007f1aSHeiko Carstens */ 112e16af09dSSam Ravnborg .exit.text : { 11301ba2bdcSSam Ravnborg EXIT_TEXT 1141da177e4SLinus Torvalds } 115e16af09dSSam Ravnborg 116a4e69245SHeiko Carstens .exit.data : { 117a4e69245SHeiko Carstens EXIT_DATA 118a4e69245SHeiko Carstens } 119a4e69245SHeiko Carstens 120686140a1SVasily Gorbik /* 121686140a1SVasily Gorbik * struct alt_inst entries. From the header (alternative.h): 122686140a1SVasily Gorbik * "Alternative instructions for different CPU types or capabilities" 123686140a1SVasily Gorbik * Think locking instructions on spinlocks. 124686140a1SVasily Gorbik * Note, that it is a part of __init region. 125686140a1SVasily Gorbik */ 126686140a1SVasily Gorbik . = ALIGN(8); 127686140a1SVasily Gorbik .altinstructions : { 128686140a1SVasily Gorbik __alt_instructions = .; 129686140a1SVasily Gorbik *(.altinstructions) 130686140a1SVasily Gorbik __alt_instructions_end = .; 131686140a1SVasily Gorbik } 132686140a1SVasily Gorbik 133686140a1SVasily Gorbik /* 134686140a1SVasily Gorbik * And here are the replacement instructions. The linker sticks 135686140a1SVasily Gorbik * them as binary blobs. The .altinstructions has enough data to 136686140a1SVasily Gorbik * get the address and the length of them to patch the kernel safely. 137686140a1SVasily Gorbik * Note, that it is a part of __init region. 138686140a1SVasily Gorbik */ 139686140a1SVasily Gorbik .altinstr_replacement : { 140686140a1SVasily Gorbik *(.altinstr_replacement) 141686140a1SVasily Gorbik } 142686140a1SVasily Gorbik 143f19fbd5eSMartin Schwidefsky /* 144f19fbd5eSMartin Schwidefsky * Table with the patch locations to undo expolines 145f19fbd5eSMartin Schwidefsky */ 146c9305b6cSJosh Poimboeuf . = ALIGN(4); 147f19fbd5eSMartin Schwidefsky .nospec_call_table : { 148f19fbd5eSMartin Schwidefsky __nospec_call_start = . ; 149f19fbd5eSMartin Schwidefsky *(.s390_indirect*) 150f19fbd5eSMartin Schwidefsky __nospec_call_end = . ; 151f19fbd5eSMartin Schwidefsky } 152f19fbd5eSMartin Schwidefsky .nospec_return_table : { 153f19fbd5eSMartin Schwidefsky __nospec_return_start = . ; 154f19fbd5eSMartin Schwidefsky *(.s390_return*) 155f19fbd5eSMartin Schwidefsky __nospec_return_end = . ; 156f19fbd5eSMartin Schwidefsky } 157f19fbd5eSMartin Schwidefsky 158d1b52a43SVasily Gorbik BOOT_DATA 159d1b52a43SVasily Gorbik 1606bda6670SAlexander Egorenkov /* 161c78d0c74SHeiko Carstens * .amode31 section for code, data, ex_table that need to stay 162c78d0c74SHeiko Carstens * below 2 GB, even when the kernel is relocated above 2 GB. 1636bda6670SAlexander Egorenkov */ 1646bda6670SAlexander Egorenkov . = ALIGN(PAGE_SIZE); 165c78d0c74SHeiko Carstens _samode31 = .; 166c78d0c74SHeiko Carstens .amode31.text : { 167c78d0c74SHeiko Carstens _stext_amode31 = .; 168c78d0c74SHeiko Carstens *(.amode31.text) 169c78d0c74SHeiko Carstens *(.amode31.text.*_indirect_*) 1706bda6670SAlexander Egorenkov . = ALIGN(PAGE_SIZE); 171c78d0c74SHeiko Carstens _etext_amode31 = .; 1726bda6670SAlexander Egorenkov } 1736bda6670SAlexander Egorenkov . = ALIGN(16); 174c78d0c74SHeiko Carstens .amode31.ex_table : { 175c78d0c74SHeiko Carstens _start_amode31_ex_table = .; 176c78d0c74SHeiko Carstens KEEP(*(.amode31.ex_table)) 177c78d0c74SHeiko Carstens _stop_amode31_ex_table = .; 1786bda6670SAlexander Egorenkov } 1796bda6670SAlexander Egorenkov . = ALIGN(PAGE_SIZE); 180c78d0c74SHeiko Carstens .amode31.data : { 181c78d0c74SHeiko Carstens *(.amode31.data) 1826bda6670SAlexander Egorenkov } 1836bda6670SAlexander Egorenkov . = ALIGN(PAGE_SIZE); 184c78d0c74SHeiko Carstens _eamode31 = .; 1856bda6670SAlexander Egorenkov 18692e6ecf3SChristian Borntraeger /* early.c uses stsi, which requires page aligned data. */ 18792e6ecf3SChristian Borntraeger . = ALIGN(PAGE_SIZE); 18804a95f6dSNelson Elhage INIT_DATA_SECTION(0x100) 189e16af09dSSam Ravnborg 1900415b00dSTejun Heo PERCPU_SECTION(0x100) 191805bc0bcSGerald Schaefer 192805bc0bcSGerald Schaefer .dynsym ALIGN(8) : { 193805bc0bcSGerald Schaefer __dynsym_start = .; 194805bc0bcSGerald Schaefer *(.dynsym) 195805bc0bcSGerald Schaefer __dynsym_end = .; 196805bc0bcSGerald Schaefer } 197805bc0bcSGerald Schaefer .rela.dyn ALIGN(8) : { 198805bc0bcSGerald Schaefer __rela_dyn_start = .; 199805bc0bcSGerald Schaefer *(.rela*) 200805bc0bcSGerald Schaefer __rela_dyn_end = .; 201805bc0bcSGerald Schaefer } 202805bc0bcSGerald Schaefer 20352480ee5SSam Ravnborg . = ALIGN(PAGE_SIZE); 204e16af09dSSam Ravnborg __init_end = .; /* freed after init ends here */ 2051da177e4SLinus Torvalds 2060ccb32c9SHeiko Carstens BSS_SECTION(PAGE_SIZE, 4 * PAGE_SIZE, PAGE_SIZE) 2071da177e4SLinus Torvalds 20845d619bdSAlexander Gordeev . = ALIGN(PAGE_SIZE); 2091da177e4SLinus Torvalds _end = . ; 2101da177e4SLinus Torvalds 211369f91c3SVasily Gorbik /* 212369f91c3SVasily Gorbik * uncompressed image info used by the decompressor 213369f91c3SVasily Gorbik * it should match struct vmlinux_info 214369f91c3SVasily Gorbik */ 2155a2e1853SVasily Gorbik .vmlinux.info 0 (INFO) : { 216369f91c3SVasily Gorbik QUAD(_stext) /* default_lma */ 217369f91c3SVasily Gorbik QUAD(startup_continue) /* entry */ 218369f91c3SVasily Gorbik QUAD(__bss_start - _stext) /* image_size */ 21915426ca4SVasily Gorbik QUAD(__bss_stop - __bss_start) /* bss_size */ 220d1b52a43SVasily Gorbik QUAD(__boot_data_start) /* bootdata_off */ 221d1b52a43SVasily Gorbik QUAD(__boot_data_end - __boot_data_start) /* bootdata_size */ 222bf9921a9SGerald Schaefer QUAD(__boot_data_preserved_start) /* bootdata_preserved_off */ 223bf9921a9SGerald Schaefer QUAD(__boot_data_preserved_end - 224bf9921a9SGerald Schaefer __boot_data_preserved_start) /* bootdata_preserved_size */ 225805bc0bcSGerald Schaefer QUAD(__dynsym_start) /* dynsym_start */ 226805bc0bcSGerald Schaefer QUAD(__rela_dyn_start) /* rela_dyn_start */ 227805bc0bcSGerald Schaefer QUAD(__rela_dyn_end) /* rela_dyn_end */ 228e3ec8e0fSAlexander Gordeev QUAD(_eamode31 - _samode31) /* amode31_size */ 229bb1520d5SAlexander Gordeev QUAD(init_mm) 230bb1520d5SAlexander Gordeev QUAD(swapper_pg_dir) 231bb1520d5SAlexander Gordeev QUAD(invalid_pg_dir) 232557b1970SVasily Gorbik#ifdef CONFIG_KASAN 233557b1970SVasily Gorbik QUAD(kasan_early_shadow_page) 234557b1970SVasily Gorbik QUAD(kasan_early_shadow_pte) 235557b1970SVasily Gorbik QUAD(kasan_early_shadow_pmd) 236557b1970SVasily Gorbik QUAD(kasan_early_shadow_pud) 237557b1970SVasily Gorbik QUAD(kasan_early_shadow_p4d) 238557b1970SVasily Gorbik#endif 2395a2e1853SVasily Gorbik } :NONE 240369f91c3SVasily Gorbik 241e16af09dSSam Ravnborg /* Debugging sections. */ 242e16af09dSSam Ravnborg STABS_DEBUG 243e16af09dSSam Ravnborg DWARF_DEBUG 244c604abc3SKees Cook ELF_DETAILS 245023bf6f1STejun Heo 246023bf6f1STejun Heo /* Sections to be discarded */ 247023bf6f1STejun Heo DISCARDS 248bc3703f2SHendrik Brueckner /DISCARD/ : { 249bc3703f2SHendrik Brueckner *(.eh_frame) 250e9c9cb90SIlya Leoshkevich *(.interp) 251bc3703f2SHendrik Brueckner } 2521da177e4SLinus Torvalds} 253