blob: 7f24bc08403e162b2243609d0b7fdd87b418a5fe [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/* ld script to make ARM Linux kernel
3 * taken from the i386 version by Russell King
4 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
5 */
6
Chris Brandt538bf462016-02-03 15:58:10 +01007#ifdef CONFIG_XIP_KERNEL
8#include "vmlinux-xip.lds.S"
9#else
10
Mike Rapoport65fddcf2020-06-08 21:32:42 -070011#include <linux/pgtable.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <asm-generic/vmlinux.lds.h>
Will Deaconf0d53752012-01-20 11:55:54 +010013#include <asm/cache.h>
Russell King4f7a1812005-05-05 13:11:00 +010014#include <asm/thread_info.h>
Nicolas Pitre37d07b72005-10-29 21:44:56 +010015#include <asm/memory.h>
Vladimir Murzin046835b2018-04-03 10:39:23 +010016#include <asm/mpu.h>
Linus Walleijf6430a92009-06-24 23:38:56 +010017#include <asm/page.h>
Ard Biesheuvele60a1fe2015-03-23 10:52:57 +000018
Nicolas Pitre2f181e02018-02-27 22:39:27 -050019#include "vmlinux.lds.h"
Russell Kinga9ad21f2011-02-21 10:13:36 +000020
Linus Torvalds1da177e2005-04-16 15:20:36 -070021OUTPUT_ARCH(arm)
22ENTRY(stext)
Nicolas Pitre37d07b72005-10-29 21:44:56 +010023
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#ifndef __ARMEB__
25jiffies = jiffies_64;
26#else
27jiffies = jiffies_64 + 4;
28#endif
Nicolas Pitre37d07b72005-10-29 21:44:56 +010029
Linus Torvalds1da177e2005-04-16 15:20:36 -070030SECTIONS
31{
Russell King39df8882011-05-26 11:25:33 +010032 /*
Russell King6760b102011-09-20 23:35:15 +010033 * XXX: The linker does not define how output sections are
34 * assigned to input sections when there are multiple statements
35 * matching the same input section name. There is no documented
36 * order of matching.
37 *
Russell King39df8882011-05-26 11:25:33 +010038 * unwind exit sections must be discarded before the rest of the
39 * unwind sections get included.
40 */
41 /DISCARD/ : {
Nicolas Pitreab42fad2018-03-05 16:34:03 -050042 ARM_DISCARD
Russell King39df8882011-05-26 11:25:33 +010043#ifndef CONFIG_SMP_ON_UP
44 *(.alt.smp.init)
45#endif
46 }
47
Russell King9d4f13e2006-01-03 17:28:33 +000048 . = PAGE_OFFSET + TEXT_OFFSET;
Russell King1604d792011-07-05 22:56:41 +010049 .head.text : {
Russell Kinge2f81842011-07-06 10:53:22 +010050 _text = .;
Russell King1604d792011-07-05 22:56:41 +010051 HEAD_TEXT
52 }
Kees Cook1e6b4812014-04-03 17:28:11 -070053
Laura Abbott0f5bf6d2017-02-06 16:31:58 -080054#ifdef CONFIG_STRICT_KERNEL_RWX
Kees Cook1e6b4812014-04-03 17:28:11 -070055 . = ALIGN(1<<SECTION_SHIFT);
56#endif
57
Vladimir Murzin046835b2018-04-03 10:39:23 +010058#ifdef CONFIG_ARM_MPU
59 . = ALIGN(PMSAv8_MINALIGN);
60#endif
Russell King3835d692011-07-06 10:39:34 +010061 .text : { /* Real text segment */
Russell Kinge2f81842011-07-06 10:53:22 +010062 _stext = .; /* Text and read-only data */
Nicolas Pitre47b4c772018-03-05 16:34:03 -050063 ARM_TEXT
Russell King3835d692011-07-06 10:39:34 +010064 }
65
Kees Cook25362dc2016-01-26 01:19:36 +010066#ifdef CONFIG_DEBUG_ALIGN_RODATA
Kees Cook80d6b0c2014-04-03 13:29:50 -070067 . = ALIGN(1<<SECTION_SHIFT);
68#endif
Kees Cook14c4a532016-06-23 21:28:47 +010069 _etext = .; /* End of text section */
70
Russell King3835d692011-07-06 10:39:34 +010071 RO_DATA(PAGE_SIZE)
72
Stephen Boydee951c62012-10-29 19:19:34 +010073 . = ALIGN(4);
74 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
75 __start___ex_table = .;
Nicolas Pitreab42fad2018-03-05 16:34:03 -050076 ARM_MMU_KEEP(*(__ex_table))
Stephen Boydee951c62012-10-29 19:19:34 +010077 __stop___ex_table = .;
78 }
79
Russell King3835d692011-07-06 10:39:34 +010080#ifdef CONFIG_ARM_UNWIND
Nicolas Pitred9a46e62018-03-01 17:32:28 -050081 ARM_UNWIND_SECTIONS
Russell King3835d692011-07-06 10:39:34 +010082#endif
83
Laura Abbott0f5bf6d2017-02-06 16:31:58 -080084#ifdef CONFIG_STRICT_KERNEL_RWX
Kees Cook1e6b4812014-04-03 17:28:11 -070085 . = ALIGN(1<<SECTION_SHIFT);
Chris Brandt538bf462016-02-03 15:58:10 +010086#else
Russell King3835d692011-07-06 10:39:34 +010087 . = ALIGN(PAGE_SIZE);
Russell King3835d692011-07-06 10:39:34 +010088#endif
Chris Brandt538bf462016-02-03 15:58:10 +010089 __init_begin = .;
90
Nicolas Pitre91470952018-03-01 22:17:03 -050091 ARM_VECTORS
Russell King1604d792011-07-05 22:56:41 +010092 INIT_TEXT_SECTION(8)
93 .exit.text : {
94 ARM_EXIT_KEEP(EXIT_TEXT)
95 }
96 .init.proc.info : {
Russell King5085f3f2010-10-01 15:37:05 +010097 ARM_CPU_DISCARD(PROC_INFO)
Russell King1604d792011-07-05 22:56:41 +010098 }
99 .init.arch.info : {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 __arch_info_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100101 *(.arch.info.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 __arch_info_end = .;
Russell King1604d792011-07-05 22:56:41 +0100103 }
104 .init.tagtable : {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 __tagtable_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100106 *(.taglist.init)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 __tagtable_end = .;
Russell King1604d792011-07-05 22:56:41 +0100108 }
Russell Kingf00ec482010-09-04 10:47:48 +0100109#ifdef CONFIG_SMP_ON_UP
Russell King1604d792011-07-05 22:56:41 +0100110 .init.smpalt : {
Russell Kingf00ec482010-09-04 10:47:48 +0100111 __smpalt_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100112 *(.alt.smp.init)
Russell Kingf00ec482010-09-04 10:47:48 +0100113 __smpalt_end = .;
Russell King1604d792011-07-05 22:56:41 +0100114 }
Russell Kingf00ec482010-09-04 10:47:48 +0100115#endif
Russell King1604d792011-07-05 22:56:41 +0100116 .init.pv_table : {
Russell Kingdc21af92011-01-04 19:09:43 +0000117 __pv_table_begin = .;
Russell King1604d792011-07-05 22:56:41 +0100118 *(.pv_table)
Russell Kingdc21af92011-01-04 19:09:43 +0000119 __pv_table_end = .;
Russell King1604d792011-07-05 22:56:41 +0100120 }
Nicolas Pitre861e37d2017-08-29 16:33:57 -0400121
122 INIT_DATA_SECTION(16)
123
Russell King1604d792011-07-05 22:56:41 +0100124 .exit.data : {
125 ARM_EXIT_KEEP(EXIT_DATA)
126 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
David Brown99732902012-06-20 22:52:24 +0100128#ifdef CONFIG_SMP
Will Deaconf0d53752012-01-20 11:55:54 +0100129 PERCPU_SECTION(L1_CACHE_BYTES)
David Brown99732902012-06-20 22:52:24 +0100130#endif
Nelson Elhage78d75302009-10-02 16:32:47 -0400131
Nicolas Pitreb54290e2018-03-08 21:12:04 -0500132#ifdef CONFIG_HAVE_TCM
133 ARM_TCM
134#endif
135
Laura Abbott0f5bf6d2017-02-06 16:31:58 -0800136#ifdef CONFIG_STRICT_KERNEL_RWX
Kees Cook1e6b4812014-04-03 17:28:11 -0700137 . = ALIGN(1<<SECTION_SHIFT);
138#else
Russell King4f7a1812005-05-05 13:11:00 +0100139 . = ALIGN(THREAD_SIZE);
Kees Cook1e6b4812014-04-03 17:28:11 -0700140#endif
Yalin Wang562c85c2014-09-26 03:30:59 +0100141 __init_end = .;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
Nicolas Pitre861e37d2017-08-29 16:33:57 -0400143 _sdata = .;
Kees Cookc9174042019-10-29 14:13:35 -0700144 RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
Nicolas Pitre861e37d2017-08-29 16:33:57 -0400145 _edata = .;
Peter Zijlstrab5effd32017-03-30 17:49:27 +0200146
Nelson Elhage78d75302009-10-02 16:32:47 -0400147 BSS_SECTION(0, 0, 0)
Vladimir Murzin046835b2018-04-03 10:39:23 +0100148#ifdef CONFIG_ARM_MPU
149 . = ALIGN(PMSAv8_MINALIGN);
150#endif
Nelson Elhage78d75302009-10-02 16:32:47 -0400151 _end = .;
152
153 STABS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154}
155
Laura Abbott0f5bf6d2017-02-06 16:31:58 -0800156#ifdef CONFIG_STRICT_KERNEL_RWX
Russell King728f5c02005-11-17 16:43:14 +0000157/*
Kees Cook64ac2e72016-01-26 01:20:21 +0100158 * Without CONFIG_DEBUG_ALIGN_RODATA, __start_rodata_section_aligned will
159 * be the first section-aligned location after __start_rodata. Otherwise,
160 * it will be equal to __start_rodata.
161 */
162__start_rodata_section_aligned = ALIGN(__start_rodata, 1 << SECTION_SHIFT);
Arnd Bergmann91c617d2016-02-19 16:41:55 +0100163#endif
Kees Cook64ac2e72016-01-26 01:20:21 +0100164
Russell King728f5c02005-11-17 16:43:14 +0000165/*
166 * These must never be empty
167 * If you have to comment these two assert statements out, your
168 * binutils is too old (for other reasons as well)
169 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
171ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
Ard Biesheuvel06f75a12015-03-19 16:42:26 +0000172
Chris Brandt538bf462016-02-03 15:58:10 +0100173#endif /* CONFIG_XIP_KERNEL */