Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* 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 Brandt | 538bf46 | 2016-02-03 15:58:10 +0100 | [diff] [blame] | 7 | #ifdef CONFIG_XIP_KERNEL |
| 8 | #include "vmlinux-xip.lds.S" |
| 9 | #else |
| 10 | |
Mike Rapoport | 65fddcf | 2020-06-08 21:32:42 -0700 | [diff] [blame] | 11 | #include <linux/pgtable.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <asm-generic/vmlinux.lds.h> |
Will Deacon | f0d5375 | 2012-01-20 11:55:54 +0100 | [diff] [blame] | 13 | #include <asm/cache.h> |
Russell King | 4f7a181 | 2005-05-05 13:11:00 +0100 | [diff] [blame] | 14 | #include <asm/thread_info.h> |
Nicolas Pitre | 37d07b7 | 2005-10-29 21:44:56 +0100 | [diff] [blame] | 15 | #include <asm/memory.h> |
Vladimir Murzin | 046835b | 2018-04-03 10:39:23 +0100 | [diff] [blame] | 16 | #include <asm/mpu.h> |
Linus Walleij | f6430a9 | 2009-06-24 23:38:56 +0100 | [diff] [blame] | 17 | #include <asm/page.h> |
Ard Biesheuvel | e60a1fe | 2015-03-23 10:52:57 +0000 | [diff] [blame] | 18 | |
Nicolas Pitre | 2f181e0 | 2018-02-27 22:39:27 -0500 | [diff] [blame] | 19 | #include "vmlinux.lds.h" |
Russell King | a9ad21f | 2011-02-21 10:13:36 +0000 | [diff] [blame] | 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | OUTPUT_ARCH(arm) |
| 22 | ENTRY(stext) |
Nicolas Pitre | 37d07b7 | 2005-10-29 21:44:56 +0100 | [diff] [blame] | 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #ifndef __ARMEB__ |
| 25 | jiffies = jiffies_64; |
| 26 | #else |
| 27 | jiffies = jiffies_64 + 4; |
| 28 | #endif |
Nicolas Pitre | 37d07b7 | 2005-10-29 21:44:56 +0100 | [diff] [blame] | 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | SECTIONS |
| 31 | { |
Russell King | 39df888 | 2011-05-26 11:25:33 +0100 | [diff] [blame] | 32 | /* |
Russell King | 6760b10 | 2011-09-20 23:35:15 +0100 | [diff] [blame] | 33 | * 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 King | 39df888 | 2011-05-26 11:25:33 +0100 | [diff] [blame] | 38 | * unwind exit sections must be discarded before the rest of the |
| 39 | * unwind sections get included. |
| 40 | */ |
| 41 | /DISCARD/ : { |
Nicolas Pitre | ab42fad | 2018-03-05 16:34:03 -0500 | [diff] [blame] | 42 | ARM_DISCARD |
Russell King | 39df888 | 2011-05-26 11:25:33 +0100 | [diff] [blame] | 43 | #ifndef CONFIG_SMP_ON_UP |
| 44 | *(.alt.smp.init) |
| 45 | #endif |
| 46 | } |
| 47 | |
Russell King | 9d4f13e | 2006-01-03 17:28:33 +0000 | [diff] [blame] | 48 | . = PAGE_OFFSET + TEXT_OFFSET; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 49 | .head.text : { |
Russell King | e2f8184 | 2011-07-06 10:53:22 +0100 | [diff] [blame] | 50 | _text = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 51 | HEAD_TEXT |
| 52 | } |
Kees Cook | 1e6b481 | 2014-04-03 17:28:11 -0700 | [diff] [blame] | 53 | |
Laura Abbott | 0f5bf6d | 2017-02-06 16:31:58 -0800 | [diff] [blame] | 54 | #ifdef CONFIG_STRICT_KERNEL_RWX |
Kees Cook | 1e6b481 | 2014-04-03 17:28:11 -0700 | [diff] [blame] | 55 | . = ALIGN(1<<SECTION_SHIFT); |
| 56 | #endif |
| 57 | |
Vladimir Murzin | 046835b | 2018-04-03 10:39:23 +0100 | [diff] [blame] | 58 | #ifdef CONFIG_ARM_MPU |
| 59 | . = ALIGN(PMSAv8_MINALIGN); |
| 60 | #endif |
Russell King | 3835d69 | 2011-07-06 10:39:34 +0100 | [diff] [blame] | 61 | .text : { /* Real text segment */ |
Russell King | e2f8184 | 2011-07-06 10:53:22 +0100 | [diff] [blame] | 62 | _stext = .; /* Text and read-only data */ |
Nicolas Pitre | 47b4c77 | 2018-03-05 16:34:03 -0500 | [diff] [blame] | 63 | ARM_TEXT |
Russell King | 3835d69 | 2011-07-06 10:39:34 +0100 | [diff] [blame] | 64 | } |
| 65 | |
Kees Cook | 25362dc | 2016-01-26 01:19:36 +0100 | [diff] [blame] | 66 | #ifdef CONFIG_DEBUG_ALIGN_RODATA |
Kees Cook | 80d6b0c | 2014-04-03 13:29:50 -0700 | [diff] [blame] | 67 | . = ALIGN(1<<SECTION_SHIFT); |
| 68 | #endif |
Kees Cook | 14c4a53 | 2016-06-23 21:28:47 +0100 | [diff] [blame] | 69 | _etext = .; /* End of text section */ |
| 70 | |
Russell King | 3835d69 | 2011-07-06 10:39:34 +0100 | [diff] [blame] | 71 | RO_DATA(PAGE_SIZE) |
| 72 | |
Stephen Boyd | ee951c6 | 2012-10-29 19:19:34 +0100 | [diff] [blame] | 73 | . = ALIGN(4); |
| 74 | __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { |
| 75 | __start___ex_table = .; |
Nicolas Pitre | ab42fad | 2018-03-05 16:34:03 -0500 | [diff] [blame] | 76 | ARM_MMU_KEEP(*(__ex_table)) |
Stephen Boyd | ee951c6 | 2012-10-29 19:19:34 +0100 | [diff] [blame] | 77 | __stop___ex_table = .; |
| 78 | } |
| 79 | |
Russell King | 3835d69 | 2011-07-06 10:39:34 +0100 | [diff] [blame] | 80 | #ifdef CONFIG_ARM_UNWIND |
Nicolas Pitre | d9a46e6 | 2018-03-01 17:32:28 -0500 | [diff] [blame] | 81 | ARM_UNWIND_SECTIONS |
Russell King | 3835d69 | 2011-07-06 10:39:34 +0100 | [diff] [blame] | 82 | #endif |
| 83 | |
Laura Abbott | 0f5bf6d | 2017-02-06 16:31:58 -0800 | [diff] [blame] | 84 | #ifdef CONFIG_STRICT_KERNEL_RWX |
Kees Cook | 1e6b481 | 2014-04-03 17:28:11 -0700 | [diff] [blame] | 85 | . = ALIGN(1<<SECTION_SHIFT); |
Chris Brandt | 538bf46 | 2016-02-03 15:58:10 +0100 | [diff] [blame] | 86 | #else |
Russell King | 3835d69 | 2011-07-06 10:39:34 +0100 | [diff] [blame] | 87 | . = ALIGN(PAGE_SIZE); |
Russell King | 3835d69 | 2011-07-06 10:39:34 +0100 | [diff] [blame] | 88 | #endif |
Chris Brandt | 538bf46 | 2016-02-03 15:58:10 +0100 | [diff] [blame] | 89 | __init_begin = .; |
| 90 | |
Nicolas Pitre | 9147095 | 2018-03-01 22:17:03 -0500 | [diff] [blame] | 91 | ARM_VECTORS |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 92 | INIT_TEXT_SECTION(8) |
| 93 | .exit.text : { |
| 94 | ARM_EXIT_KEEP(EXIT_TEXT) |
| 95 | } |
| 96 | .init.proc.info : { |
Russell King | 5085f3f | 2010-10-01 15:37:05 +0100 | [diff] [blame] | 97 | ARM_CPU_DISCARD(PROC_INFO) |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 98 | } |
| 99 | .init.arch.info : { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | __arch_info_begin = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 101 | *(.arch.info.init) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | __arch_info_end = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 103 | } |
| 104 | .init.tagtable : { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | __tagtable_begin = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 106 | *(.taglist.init) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | __tagtable_end = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 108 | } |
Russell King | f00ec48 | 2010-09-04 10:47:48 +0100 | [diff] [blame] | 109 | #ifdef CONFIG_SMP_ON_UP |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 110 | .init.smpalt : { |
Russell King | f00ec48 | 2010-09-04 10:47:48 +0100 | [diff] [blame] | 111 | __smpalt_begin = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 112 | *(.alt.smp.init) |
Russell King | f00ec48 | 2010-09-04 10:47:48 +0100 | [diff] [blame] | 113 | __smpalt_end = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 114 | } |
Russell King | f00ec48 | 2010-09-04 10:47:48 +0100 | [diff] [blame] | 115 | #endif |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 116 | .init.pv_table : { |
Russell King | dc21af9 | 2011-01-04 19:09:43 +0000 | [diff] [blame] | 117 | __pv_table_begin = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 118 | *(.pv_table) |
Russell King | dc21af9 | 2011-01-04 19:09:43 +0000 | [diff] [blame] | 119 | __pv_table_end = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 120 | } |
Nicolas Pitre | 861e37d | 2017-08-29 16:33:57 -0400 | [diff] [blame] | 121 | |
| 122 | INIT_DATA_SECTION(16) |
| 123 | |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 124 | .exit.data : { |
| 125 | ARM_EXIT_KEEP(EXIT_DATA) |
| 126 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | |
David Brown | 9973290 | 2012-06-20 22:52:24 +0100 | [diff] [blame] | 128 | #ifdef CONFIG_SMP |
Will Deacon | f0d5375 | 2012-01-20 11:55:54 +0100 | [diff] [blame] | 129 | PERCPU_SECTION(L1_CACHE_BYTES) |
David Brown | 9973290 | 2012-06-20 22:52:24 +0100 | [diff] [blame] | 130 | #endif |
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 131 | |
Nicolas Pitre | b54290e | 2018-03-08 21:12:04 -0500 | [diff] [blame] | 132 | #ifdef CONFIG_HAVE_TCM |
| 133 | ARM_TCM |
| 134 | #endif |
| 135 | |
Laura Abbott | 0f5bf6d | 2017-02-06 16:31:58 -0800 | [diff] [blame] | 136 | #ifdef CONFIG_STRICT_KERNEL_RWX |
Kees Cook | 1e6b481 | 2014-04-03 17:28:11 -0700 | [diff] [blame] | 137 | . = ALIGN(1<<SECTION_SHIFT); |
| 138 | #else |
Russell King | 4f7a181 | 2005-05-05 13:11:00 +0100 | [diff] [blame] | 139 | . = ALIGN(THREAD_SIZE); |
Kees Cook | 1e6b481 | 2014-04-03 17:28:11 -0700 | [diff] [blame] | 140 | #endif |
Yalin Wang | 562c85c | 2014-09-26 03:30:59 +0100 | [diff] [blame] | 141 | __init_end = .; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
Nicolas Pitre | 861e37d | 2017-08-29 16:33:57 -0400 | [diff] [blame] | 143 | _sdata = .; |
Kees Cook | c917404 | 2019-10-29 14:13:35 -0700 | [diff] [blame] | 144 | RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) |
Nicolas Pitre | 861e37d | 2017-08-29 16:33:57 -0400 | [diff] [blame] | 145 | _edata = .; |
Peter Zijlstra | b5effd3 | 2017-03-30 17:49:27 +0200 | [diff] [blame] | 146 | |
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 147 | BSS_SECTION(0, 0, 0) |
Vladimir Murzin | 046835b | 2018-04-03 10:39:23 +0100 | [diff] [blame] | 148 | #ifdef CONFIG_ARM_MPU |
| 149 | . = ALIGN(PMSAv8_MINALIGN); |
| 150 | #endif |
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 151 | _end = .; |
| 152 | |
| 153 | STABS_DEBUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | } |
| 155 | |
Laura Abbott | 0f5bf6d | 2017-02-06 16:31:58 -0800 | [diff] [blame] | 156 | #ifdef CONFIG_STRICT_KERNEL_RWX |
Russell King | 728f5c0 | 2005-11-17 16:43:14 +0000 | [diff] [blame] | 157 | /* |
Kees Cook | 64ac2e7 | 2016-01-26 01:20:21 +0100 | [diff] [blame] | 158 | * 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 Bergmann | 91c617d | 2016-02-19 16:41:55 +0100 | [diff] [blame] | 163 | #endif |
Kees Cook | 64ac2e7 | 2016-01-26 01:20:21 +0100 | [diff] [blame] | 164 | |
Russell King | 728f5c0 | 2005-11-17 16:43:14 +0000 | [diff] [blame] | 165 | /* |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support") |
| 171 | ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined") |
Ard Biesheuvel | 06f75a1 | 2015-03-19 16:42:26 +0000 | [diff] [blame] | 172 | |
Chris Brandt | 538bf46 | 2016-02-03 15:58:10 +0100 | [diff] [blame] | 173 | #endif /* CONFIG_XIP_KERNEL */ |