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