1b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */ 21da177e4SLinus Torvalds/* ld script to make ARM Linux kernel 31da177e4SLinus Torvalds * taken from the i386 version by Russell King 41da177e4SLinus Torvalds * Written by Martin Mares <[email protected]> 51da177e4SLinus Torvalds */ 61da177e4SLinus Torvalds 7538bf469SChris Brandt#ifdef CONFIG_XIP_KERNEL 8538bf469SChris Brandt#include "vmlinux-xip.lds.S" 9538bf469SChris Brandt#else 10538bf469SChris Brandt 1165fddcfcSMike Rapoport#include <linux/pgtable.h> 12d7e3b065SKees Cook#include <asm/vmlinux.lds.h> 13f0d5375eSWill Deacon#include <asm/cache.h> 144f7a1812SRussell King#include <asm/thread_info.h> 15f6430a93SLinus Walleij#include <asm/page.h> 16a9ff6961SLinus Walleij#include <asm/mpu.h> 171da177e4SLinus Torvalds 181da177e4SLinus TorvaldsOUTPUT_ARCH(arm) 191da177e4SLinus TorvaldsENTRY(stext) 2037d07b72SNicolas Pitre 211da177e4SLinus Torvalds#ifndef __ARMEB__ 221da177e4SLinus Torvaldsjiffies = jiffies_64; 231da177e4SLinus Torvalds#else 241da177e4SLinus Torvaldsjiffies = jiffies_64 + 4; 251da177e4SLinus Torvalds#endif 2637d07b72SNicolas Pitre 271da177e4SLinus TorvaldsSECTIONS 281da177e4SLinus Torvalds{ 2939df8887SRussell King /* 306760b109SRussell King * XXX: The linker does not define how output sections are 316760b109SRussell King * assigned to input sections when there are multiple statements 326760b109SRussell King * matching the same input section name. There is no documented 336760b109SRussell King * order of matching. 346760b109SRussell King * 3539df8887SRussell King * unwind exit sections must be discarded before the rest of the 3639df8887SRussell King * unwind sections get included. 3739df8887SRussell King */ 3839df8887SRussell King /DISCARD/ : { 39ab42fad0SNicolas Pitre ARM_DISCARD 4039df8887SRussell King#ifndef CONFIG_SMP_ON_UP 4139df8887SRussell King *(.alt.smp.init) 4239df8887SRussell King#endif 43c39866f2SNathan Chancellor#ifndef CONFIG_ARM_UNWIND 44c39866f2SNathan Chancellor *(.ARM.exidx) *(.ARM.exidx.*) 45c39866f2SNathan Chancellor *(.ARM.extab) *(.ARM.extab.*) 46c39866f2SNathan Chancellor#endif 4739df8887SRussell King } 4839df8887SRussell King 49b78f63f4SLinus Walleij . = KERNEL_OFFSET + TEXT_OFFSET; 501604d79dSRussell King .head.text : { 51e2f81844SRussell King _text = .; 522abc1c50STim Abbott HEAD_TEXT 531604d79dSRussell King } 541e6b4811SKees Cook 550f5bf6d0SLaura Abbott#ifdef CONFIG_STRICT_KERNEL_RWX 561e6b4811SKees Cook . = ALIGN(1<<SECTION_SHIFT); 571e6b4811SKees Cook#endif 581e6b4811SKees Cook 59046835b4SVladimir Murzin#ifdef CONFIG_ARM_MPU 60046835b4SVladimir Murzin . = ALIGN(PMSAv8_MINALIGN); 61046835b4SVladimir Murzin#endif 623835d69aSRussell King .text : { /* Real text segment */ 63e2f81844SRussell King _stext = .; /* Text and read-only data */ 6447b4c77dSNicolas Pitre ARM_TEXT 653835d69aSRussell King } 663835d69aSRussell King 6725362dc4SKees Cook#ifdef CONFIG_DEBUG_ALIGN_RODATA 6880d6b0c2SKees Cook . = ALIGN(1<<SECTION_SHIFT); 6980d6b0c2SKees Cook#endif 7014c4a533SKees Cook _etext = .; /* End of text section */ 7114c4a533SKees Cook 723835d69aSRussell King RO_DATA(PAGE_SIZE) 733835d69aSRussell King 74ee951c63SStephen Boyd . = ALIGN(4); 75ee951c63SStephen Boyd __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { 76ee951c63SStephen Boyd __start___ex_table = .; 77*f9733aa9SRolf Eike Beer ARM_MMU_KEEP(*(__ex_table)) 78ee951c63SStephen Boyd __stop___ex_table = .; 79ee951c63SStephen Boyd } 80ee951c63SStephen Boyd 813835d69aSRussell King#ifdef CONFIG_ARM_UNWIND 82d9a46e6eSNicolas Pitre ARM_UNWIND_SECTIONS 833835d69aSRussell King#endif 843835d69aSRussell King 850f5bf6d0SLaura Abbott#ifdef CONFIG_STRICT_KERNEL_RWX 861e6b4811SKees Cook . = ALIGN(1<<SECTION_SHIFT); 871e6b4811SKees Cook#else 883835d69aSRussell King . = ALIGN(PAGE_SIZE); 891e6b4811SKees Cook#endif 903835d69aSRussell King __init_begin = .; 91538bf469SChris Brandt 9291470958SNicolas Pitre ARM_VECTORS 931604d79dSRussell King INIT_TEXT_SECTION(8) 941604d79dSRussell King .exit.text : { 95a9ad21feSRussell King ARM_EXIT_KEEP(EXIT_TEXT) 961604d79dSRussell King } 971604d79dSRussell King .init.proc.info : { 985085f3ffSRussell King ARM_CPU_DISCARD(PROC_INFO) 991604d79dSRussell King } 1001604d79dSRussell King .init.arch.info : { 1011da177e4SLinus Torvalds __arch_info_begin = .; 102ed0f9410SYuntao Liu KEEP(*(.arch.info.init)) 1031da177e4SLinus Torvalds __arch_info_end = .; 1041604d79dSRussell King } 1051604d79dSRussell King .init.tagtable : { 1061da177e4SLinus Torvalds __tagtable_begin = .; 1079506057fSBen Dooks *(.taglist.init) 1081da177e4SLinus Torvalds __tagtable_end = .; 1091604d79dSRussell King } 110f00ec48fSRussell King#ifdef CONFIG_SMP_ON_UP 1111604d79dSRussell King .init.smpalt : { 112f00ec48fSRussell King __smpalt_begin = .; 113f00ec48fSRussell King *(.alt.smp.init) 114f00ec48fSRussell King __smpalt_end = .; 1151604d79dSRussell King } 116f00ec48fSRussell King#endif 1171604d79dSRussell King .init.pv_table : { 118dc21af99SRussell King __pv_table_begin = .; 119ed0f9410SYuntao Liu KEEP(*(.pv_table)) 120dc21af99SRussell King __pv_table_end = .; 1211604d79dSRussell King } 122861e37daSNicolas Pitre 123861e37daSNicolas Pitre INIT_DATA_SECTION(16) 124861e37daSNicolas Pitre 1251604d79dSRussell King .exit.data : { 1261604d79dSRussell King ARM_EXIT_KEEP(EXIT_DATA) 1271604d79dSRussell King } 12878d7530aSNelson Elhage 1299973290cSDavid Brown#ifdef CONFIG_SMP 130f0d5375eSWill Deacon PERCPU_SECTION(L1_CACHE_BYTES) 1319973290cSDavid Brown#endif 13278d7530aSNelson Elhage 133b54290e5SNicolas Pitre#ifdef CONFIG_HAVE_TCM 134b54290e5SNicolas Pitre ARM_TCM 135b54290e5SNicolas Pitre#endif 136b54290e5SNicolas Pitre 1370f5bf6d0SLaura Abbott#ifdef CONFIG_STRICT_KERNEL_RWX 1381e6b4811SKees Cook . = ALIGN(1<<SECTION_SHIFT); 1391e6b4811SKees Cook#else 140a1c510d0SArd Biesheuvel . = ALIGN(THREAD_ALIGN); 1411e6b4811SKees Cook#endif 142562c85caSYalin Wang __init_end = .; 1431da177e4SLinus Torvalds 1448c7e6574SCatalin Marinas _sdata = .; 145a1c510d0SArd Biesheuvel RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN) 1461da177e4SLinus Torvalds _edata = .; 147b5effd38SPeter Zijlstra 14878d7530aSNelson Elhage BSS_SECTION(0, 0, 0) 149046835b4SVladimir Murzin#ifdef CONFIG_ARM_MPU 150046835b4SVladimir Murzin . = ALIGN(PMSAv8_MINALIGN); 151046835b4SVladimir Murzin#endif 1521da177e4SLinus Torvalds _end = .; 15378d7530aSNelson Elhage 15478d7530aSNelson Elhage STABS_DEBUG 155512dd2eeSKees Cook DWARF_DEBUG 1563b14aefbSKees Cook ARM_DETAILS 1570c918e75SKees Cook 1580c918e75SKees Cook ARM_ASSERTS 1591da177e4SLinus Torvalds} 1601da177e4SLinus Torvalds 1610f5bf6d0SLaura Abbott#ifdef CONFIG_STRICT_KERNEL_RWX 162728f5c07SRussell King/* 16364ac2e74SKees Cook * Without CONFIG_DEBUG_ALIGN_RODATA, __start_rodata_section_aligned will 16464ac2e74SKees Cook * be the first section-aligned location after __start_rodata. Otherwise, 16564ac2e74SKees Cook * it will be equal to __start_rodata. 16664ac2e74SKees Cook */ 16764ac2e74SKees Cook__start_rodata_section_aligned = ALIGN(__start_rodata, 1 << SECTION_SHIFT); 16891c617d7SArnd Bergmann#endif 16964ac2e74SKees Cook 170728f5c07SRussell King/* 171728f5c07SRussell King * These must never be empty 172728f5c07SRussell King * If you have to comment these two assert statements out, your 173728f5c07SRussell King * binutils is too old (for other reasons as well) 174728f5c07SRussell King */ 1751da177e4SLinus TorvaldsASSERT((__proc_info_end - __proc_info_begin), "missing CPU support") 176336fe1d6SArnd Bergmann#ifndef CONFIG_COMPILE_TEST 1771da177e4SLinus TorvaldsASSERT((__arch_info_end - __arch_info_begin), "no machine record defined") 178336fe1d6SArnd Bergmann#endif 17906f75a1fSArd Biesheuvel 180538bf469SChris Brandt#endif /* CONFIG_XIP_KERNEL */ 181