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