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