Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* ld script to make ARM Linux kernel |
| 2 | * taken from the i386 version by Russell King |
| 3 | * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz> |
| 4 | */ |
| 5 | |
| 6 | #include <asm-generic/vmlinux.lds.h> |
Russell King | 4f7a181 | 2005-05-05 13:11:00 +0100 | [diff] [blame] | 7 | #include <asm/thread_info.h> |
Nicolas Pitre | 37d07b7 | 2005-10-29 21:44:56 +0100 | [diff] [blame] | 8 | #include <asm/memory.h> |
Linus Walleij | f6430a9 | 2009-06-24 23:38:56 +0100 | [diff] [blame] | 9 | #include <asm/page.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
Russell King | 5085f3f | 2010-10-01 15:37:05 +0100 | [diff] [blame] | 11 | #define PROC_INFO \ |
| 12 | VMLINUX_SYMBOL(__proc_info_begin) = .; \ |
| 13 | *(.proc.info.init) \ |
| 14 | VMLINUX_SYMBOL(__proc_info_end) = .; |
| 15 | |
| 16 | #ifdef CONFIG_HOTPLUG_CPU |
| 17 | #define ARM_CPU_DISCARD(x) |
| 18 | #define ARM_CPU_KEEP(x) x |
| 19 | #else |
| 20 | #define ARM_CPU_DISCARD(x) x |
| 21 | #define ARM_CPU_KEEP(x) |
| 22 | #endif |
| 23 | |
Simon Glass | 87e040b | 2011-08-16 23:44:26 +0100 | [diff] [blame^] | 24 | #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \ |
| 25 | defined(CONFIG_GENERIC_BUG) |
Russell King | a9ad21f | 2011-02-21 10:13:36 +0000 | [diff] [blame] | 26 | #define ARM_EXIT_KEEP(x) x |
| 27 | #else |
| 28 | #define ARM_EXIT_KEEP(x) |
| 29 | #endif |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | OUTPUT_ARCH(arm) |
| 32 | ENTRY(stext) |
Nicolas Pitre | 37d07b7 | 2005-10-29 21:44:56 +0100 | [diff] [blame] | 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #ifndef __ARMEB__ |
| 35 | jiffies = jiffies_64; |
| 36 | #else |
| 37 | jiffies = jiffies_64 + 4; |
| 38 | #endif |
Nicolas Pitre | 37d07b7 | 2005-10-29 21:44:56 +0100 | [diff] [blame] | 39 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | SECTIONS |
| 41 | { |
Russell King | 39df888 | 2011-05-26 11:25:33 +0100 | [diff] [blame] | 42 | /* |
| 43 | * unwind exit sections must be discarded before the rest of the |
| 44 | * unwind sections get included. |
| 45 | */ |
| 46 | /DISCARD/ : { |
| 47 | *(.ARM.exidx.exit.text) |
| 48 | *(.ARM.extab.exit.text) |
| 49 | ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text)) |
| 50 | ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text)) |
| 51 | #ifndef CONFIG_HOTPLUG |
| 52 | *(.ARM.exidx.devexit.text) |
| 53 | *(.ARM.extab.devexit.text) |
| 54 | #endif |
| 55 | #ifndef CONFIG_MMU |
| 56 | *(.fixup) |
| 57 | *(__ex_table) |
| 58 | #endif |
| 59 | #ifndef CONFIG_SMP_ON_UP |
| 60 | *(.alt.smp.init) |
| 61 | #endif |
| 62 | } |
| 63 | |
Russell King | 9d4f13e | 2006-01-03 17:28:33 +0000 | [diff] [blame] | 64 | #ifdef CONFIG_XIP_KERNEL |
| 65 | . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR); |
| 66 | #else |
| 67 | . = PAGE_OFFSET + TEXT_OFFSET; |
| 68 | #endif |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 69 | .head.text : { |
Russell King | e2f8184 | 2011-07-06 10:53:22 +0100 | [diff] [blame] | 70 | _text = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 71 | HEAD_TEXT |
| 72 | } |
Russell King | 3835d69 | 2011-07-06 10:39:34 +0100 | [diff] [blame] | 73 | .text : { /* Real text segment */ |
Russell King | e2f8184 | 2011-07-06 10:53:22 +0100 | [diff] [blame] | 74 | _stext = .; /* Text and read-only data */ |
Russell King | 3835d69 | 2011-07-06 10:39:34 +0100 | [diff] [blame] | 75 | __exception_text_start = .; |
| 76 | *(.exception.text) |
| 77 | __exception_text_end = .; |
| 78 | IRQENTRY_TEXT |
| 79 | TEXT_TEXT |
| 80 | SCHED_TEXT |
| 81 | LOCK_TEXT |
| 82 | KPROBES_TEXT |
| 83 | #ifdef CONFIG_MMU |
| 84 | *(.fixup) |
| 85 | #endif |
| 86 | *(.gnu.warning) |
| 87 | *(.glue_7) |
| 88 | *(.glue_7t) |
| 89 | . = ALIGN(4); |
| 90 | *(.got) /* Global offset table */ |
| 91 | ARM_CPU_KEEP(PROC_INFO) |
| 92 | } |
| 93 | |
| 94 | RO_DATA(PAGE_SIZE) |
| 95 | |
| 96 | #ifdef CONFIG_ARM_UNWIND |
| 97 | /* |
| 98 | * Stack unwinding tables |
| 99 | */ |
| 100 | . = ALIGN(8); |
| 101 | .ARM.unwind_idx : { |
| 102 | __start_unwind_idx = .; |
| 103 | *(.ARM.exidx*) |
| 104 | __stop_unwind_idx = .; |
| 105 | } |
| 106 | .ARM.unwind_tab : { |
| 107 | __start_unwind_tab = .; |
| 108 | *(.ARM.extab*) |
| 109 | __stop_unwind_tab = .; |
| 110 | } |
| 111 | #endif |
| 112 | |
| 113 | _etext = .; /* End of text and rodata section */ |
| 114 | |
| 115 | #ifndef CONFIG_XIP_KERNEL |
| 116 | . = ALIGN(PAGE_SIZE); |
| 117 | __init_begin = .; |
| 118 | #endif |
| 119 | |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 120 | INIT_TEXT_SECTION(8) |
| 121 | .exit.text : { |
| 122 | ARM_EXIT_KEEP(EXIT_TEXT) |
| 123 | } |
| 124 | .init.proc.info : { |
Russell King | 5085f3f | 2010-10-01 15:37:05 +0100 | [diff] [blame] | 125 | ARM_CPU_DISCARD(PROC_INFO) |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 126 | } |
| 127 | .init.arch.info : { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | __arch_info_begin = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 129 | *(.arch.info.init) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | __arch_info_end = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 131 | } |
| 132 | .init.tagtable : { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | __tagtable_begin = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 134 | *(.taglist.init) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | __tagtable_end = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 136 | } |
Russell King | f00ec48 | 2010-09-04 10:47:48 +0100 | [diff] [blame] | 137 | #ifdef CONFIG_SMP_ON_UP |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 138 | .init.smpalt : { |
Russell King | f00ec48 | 2010-09-04 10:47:48 +0100 | [diff] [blame] | 139 | __smpalt_begin = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 140 | *(.alt.smp.init) |
Russell King | f00ec48 | 2010-09-04 10:47:48 +0100 | [diff] [blame] | 141 | __smpalt_end = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 142 | } |
Russell King | f00ec48 | 2010-09-04 10:47:48 +0100 | [diff] [blame] | 143 | #endif |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 144 | .init.pv_table : { |
Russell King | dc21af9 | 2011-01-04 19:09:43 +0000 | [diff] [blame] | 145 | __pv_table_begin = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 146 | *(.pv_table) |
Russell King | dc21af9 | 2011-01-04 19:09:43 +0000 | [diff] [blame] | 147 | __pv_table_end = .; |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 148 | } |
| 149 | .init.data : { |
| 150 | #ifndef CONFIG_XIP_KERNEL |
| 151 | INIT_DATA |
| 152 | #endif |
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 153 | INIT_SETUP(16) |
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 154 | INIT_CALLS |
| 155 | CON_INITCALL |
| 156 | SECURITY_INITCALL |
| 157 | INIT_RAM_FS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | } |
Russell King | 1604d79 | 2011-07-05 22:56:41 +0100 | [diff] [blame] | 159 | #ifndef CONFIG_XIP_KERNEL |
| 160 | .exit.data : { |
| 161 | ARM_EXIT_KEEP(EXIT_DATA) |
| 162 | } |
| 163 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
Tejun Heo | 0415b00d1 | 2011-03-24 18:50:09 +0100 | [diff] [blame] | 165 | PERCPU_SECTION(32) |
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 166 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | #ifdef CONFIG_XIP_KERNEL |
| 168 | __data_loc = ALIGN(4); /* location in binary */ |
Russell King | 9d4f13e | 2006-01-03 17:28:33 +0000 | [diff] [blame] | 169 | . = PAGE_OFFSET + TEXT_OFFSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | #else |
Russell King | 3835d69 | 2011-07-06 10:39:34 +0100 | [diff] [blame] | 171 | __init_end = .; |
Russell King | 4f7a181 | 2005-05-05 13:11:00 +0100 | [diff] [blame] | 172 | . = ALIGN(THREAD_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | __data_loc = .; |
| 174 | #endif |
| 175 | |
| 176 | .data : AT(__data_loc) { |
Russell King | 37efe64 | 2008-12-01 11:53:07 +0000 | [diff] [blame] | 177 | _data = .; /* address in memory */ |
Catalin Marinas | 8c7e657 | 2009-05-30 14:00:17 +0100 | [diff] [blame] | 178 | _sdata = .; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | |
| 180 | /* |
| 181 | * first, the init task union, aligned |
| 182 | * to an 8192 byte boundary. |
| 183 | */ |
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 184 | INIT_TASK_DATA(THREAD_SIZE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | |
| 186 | #ifdef CONFIG_XIP_KERNEL |
Linus Walleij | f6430a9 | 2009-06-24 23:38:56 +0100 | [diff] [blame] | 187 | . = ALIGN(PAGE_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | __init_begin = .; |
Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 189 | INIT_DATA |
Russell King | a9ad21f | 2011-02-21 10:13:36 +0000 | [diff] [blame] | 190 | ARM_EXIT_KEEP(EXIT_DATA) |
Linus Walleij | f6430a9 | 2009-06-24 23:38:56 +0100 | [diff] [blame] | 191 | . = ALIGN(PAGE_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | __init_end = .; |
| 193 | #endif |
| 194 | |
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 195 | NOSAVE_DATA |
| 196 | CACHELINE_ALIGNED_DATA(32) |
Russell King | daf8741 | 2010-12-04 17:08:32 +0000 | [diff] [blame] | 197 | READ_MOSTLY_DATA(32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | |
| 199 | /* |
Nicolas Pitre | 13b1f64 | 2005-10-13 22:04:37 +0100 | [diff] [blame] | 200 | * The exception fixup table (might need resorting at runtime) |
| 201 | */ |
| 202 | . = ALIGN(32); |
| 203 | __start___ex_table = .; |
Russell King | 9641c7c | 2006-06-21 20:38:17 +0100 | [diff] [blame] | 204 | #ifdef CONFIG_MMU |
Nicolas Pitre | 13b1f64 | 2005-10-13 22:04:37 +0100 | [diff] [blame] | 205 | *(__ex_table) |
Russell King | 9641c7c | 2006-06-21 20:38:17 +0100 | [diff] [blame] | 206 | #endif |
Nicolas Pitre | 13b1f64 | 2005-10-13 22:04:37 +0100 | [diff] [blame] | 207 | __stop___ex_table = .; |
| 208 | |
| 209 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | * and the usual data section |
| 211 | */ |
Sam Ravnborg | ca96725 | 2007-05-17 13:38:44 +0200 | [diff] [blame] | 212 | DATA_DATA |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | CONSTRUCTORS |
| 214 | |
| 215 | _edata = .; |
| 216 | } |
Nicolas Pitre | e98ff7f | 2007-02-22 16:18:09 +0100 | [diff] [blame] | 217 | _edata_loc = __data_loc + SIZEOF(.data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | |
Linus Walleij | bc58177 | 2009-09-15 17:30:37 +0100 | [diff] [blame] | 219 | #ifdef CONFIG_HAVE_TCM |
| 220 | /* |
| 221 | * We align everything to a page boundary so we can |
| 222 | * free it after init has commenced and TCM contents have |
| 223 | * been copied to its destination. |
| 224 | */ |
| 225 | .tcm_start : { |
| 226 | . = ALIGN(PAGE_SIZE); |
| 227 | __tcm_start = .; |
| 228 | __itcm_start = .; |
| 229 | } |
| 230 | |
| 231 | /* |
| 232 | * Link these to the ITCM RAM |
| 233 | * Put VMA to the TCM address and LMA to the common RAM |
| 234 | * and we'll upload the contents from RAM to TCM and free |
| 235 | * the used RAM after that. |
| 236 | */ |
| 237 | .text_itcm ITCM_OFFSET : AT(__itcm_start) |
| 238 | { |
| 239 | __sitcm_text = .; |
| 240 | *(.tcm.text) |
| 241 | *(.tcm.rodata) |
| 242 | . = ALIGN(4); |
| 243 | __eitcm_text = .; |
| 244 | } |
| 245 | |
| 246 | /* |
| 247 | * Reset the dot pointer, this is needed to create the |
| 248 | * relative __dtcm_start below (to be used as extern in code). |
| 249 | */ |
| 250 | . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm); |
| 251 | |
| 252 | .dtcm_start : { |
| 253 | __dtcm_start = .; |
| 254 | } |
| 255 | |
| 256 | /* TODO: add remainder of ITCM as well, that can be used for data! */ |
| 257 | .data_dtcm DTCM_OFFSET : AT(__dtcm_start) |
| 258 | { |
| 259 | . = ALIGN(4); |
| 260 | __sdtcm_data = .; |
| 261 | *(.tcm.data) |
| 262 | . = ALIGN(4); |
| 263 | __edtcm_data = .; |
| 264 | } |
| 265 | |
| 266 | /* Reset the dot pointer or the linker gets confused */ |
| 267 | . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm); |
| 268 | |
| 269 | /* End marker for freeing TCM copy in linked object */ |
| 270 | .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){ |
| 271 | . = ALIGN(PAGE_SIZE); |
| 272 | __tcm_end = .; |
| 273 | } |
| 274 | #endif |
| 275 | |
Pawel Moll | dc810ef | 2011-02-16 18:54:01 +0100 | [diff] [blame] | 276 | NOTES |
| 277 | |
Nelson Elhage | 78d7530 | 2009-10-02 16:32:47 -0400 | [diff] [blame] | 278 | BSS_SECTION(0, 0, 0) |
| 279 | _end = .; |
| 280 | |
| 281 | STABS_DEBUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | .comment 0 : { *(.comment) } |
Alan Jenkins | e3f28c1 | 2009-11-07 21:03:52 +0000 | [diff] [blame] | 283 | |
| 284 | /* Default discards */ |
| 285 | DISCARDS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | } |
| 287 | |
Russell King | 728f5c0 | 2005-11-17 16:43:14 +0000 | [diff] [blame] | 288 | /* |
| 289 | * These must never be empty |
| 290 | * If you have to comment these two assert statements out, your |
| 291 | * binutils is too old (for other reasons as well) |
| 292 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support") |
| 294 | ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined") |