Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 1 | /* ld script to make i386 Linux kernel |
| 2 | * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>; |
| 3 | * |
| 4 | * Don't define absolute symbols until and unless you know that symbol |
| 5 | * value is should remain constant even if kernel image is relocated |
| 6 | * at run time. Absolute symbols are not relocated. If symbol value should |
| 7 | * change if kernel is relocated, make the symbol section relative and |
| 8 | * put it inside the section definition. |
| 9 | */ |
| 10 | |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 11 | #define LOAD_OFFSET __PAGE_OFFSET |
| 12 | |
| 13 | #include <asm-generic/vmlinux.lds.h> |
| 14 | #include <asm/thread_info.h> |
Jeremy Fitzhardinge | 0341c14 | 2009-02-13 11:14:01 -0800 | [diff] [blame] | 15 | #include <asm/page_types.h> |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 16 | #include <asm/cache.h> |
| 17 | #include <asm/boot.h> |
| 18 | |
| 19 | OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") |
| 20 | OUTPUT_ARCH(i386) |
| 21 | ENTRY(phys_startup_32) |
| 22 | jiffies = jiffies_64; |
| 23 | |
| 24 | PHDRS { |
| 25 | text PT_LOAD FLAGS(5); /* R_E */ |
| 26 | data PT_LOAD FLAGS(7); /* RWE */ |
| 27 | note PT_NOTE FLAGS(0); /* ___ */ |
| 28 | } |
| 29 | SECTIONS |
| 30 | { |
| 31 | . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR; |
| 32 | phys_startup_32 = startup_32 - LOAD_OFFSET; |
| 33 | |
| 34 | .text.head : AT(ADDR(.text.head) - LOAD_OFFSET) { |
| 35 | _text = .; /* Text and read-only data */ |
| 36 | *(.text.head) |
| 37 | } :text = 0x9090 |
| 38 | |
| 39 | /* read-only */ |
| 40 | .text : AT(ADDR(.text) - LOAD_OFFSET) { |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 41 | . = ALIGN(PAGE_SIZE); /* not really needed, already page aligned */ |
Eric Dumazet | 4c49156 | 2008-01-30 13:32:50 +0100 | [diff] [blame] | 42 | *(.text.page_aligned) |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 43 | TEXT_TEXT |
| 44 | SCHED_TEXT |
| 45 | LOCK_TEXT |
| 46 | KPROBES_TEXT |
Ingo Molnar | 2bed844 | 2008-12-12 12:13:36 +0100 | [diff] [blame] | 47 | IRQENTRY_TEXT |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 48 | *(.fixup) |
| 49 | *(.gnu.warning) |
| 50 | _etext = .; /* End of text section */ |
| 51 | } :text = 0x9090 |
| 52 | |
Jan Beulich | 6360b1f | 2008-05-12 15:44:41 +0200 | [diff] [blame] | 53 | NOTES :text :note |
| 54 | |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 55 | . = ALIGN(16); /* Exception table */ |
| 56 | __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { |
| 57 | __start___ex_table = .; |
| 58 | *(__ex_table) |
| 59 | __stop___ex_table = .; |
Jan Beulich | 6360b1f | 2008-05-12 15:44:41 +0200 | [diff] [blame] | 60 | } :text = 0x9090 |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 61 | |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 62 | RODATA |
| 63 | |
| 64 | /* writeable */ |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 65 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 66 | .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */ |
| 67 | DATA_DATA |
| 68 | CONSTRUCTORS |
| 69 | } :data |
| 70 | |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 71 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 72 | .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { |
| 73 | __nosave_begin = .; |
| 74 | *(.data.nosave) |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 75 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 76 | __nosave_end = .; |
| 77 | } |
| 78 | |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 79 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 80 | .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) { |
| 81 | *(.data.page_aligned) |
| 82 | *(.data.idt) |
| 83 | } |
| 84 | |
| 85 | . = ALIGN(32); |
| 86 | .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) { |
| 87 | *(.data.cacheline_aligned) |
| 88 | } |
| 89 | |
| 90 | /* rarely changed data like cpu maps */ |
| 91 | . = ALIGN(32); |
| 92 | .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) { |
| 93 | *(.data.read_mostly) |
| 94 | _edata = .; /* End of data section */ |
| 95 | } |
| 96 | |
| 97 | . = ALIGN(THREAD_SIZE); /* init_task */ |
| 98 | .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) { |
| 99 | *(.data.init_task) |
| 100 | } |
| 101 | |
| 102 | /* might get freed after init */ |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 103 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 104 | .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) { |
| 105 | __smp_locks = .; |
| 106 | *(.smp_locks) |
| 107 | __smp_locks_end = .; |
| 108 | } |
| 109 | /* will be freed after init |
| 110 | * Following ALIGN() is required to make sure no other data falls on the |
| 111 | * same page where __smp_alt_end is pointing as that page might be freed |
| 112 | * after boot. Always make sure that ALIGN() directive is present after |
| 113 | * the section which contains __smp_alt_end. |
| 114 | */ |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 115 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 116 | |
| 117 | /* will be freed after init */ |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 118 | . = ALIGN(PAGE_SIZE); /* Init code and data */ |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 119 | .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { |
| 120 | __init_begin = .; |
| 121 | _sinittext = .; |
Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 122 | INIT_TEXT |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 123 | _einittext = .; |
| 124 | } |
Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 125 | .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { |
| 126 | INIT_DATA |
| 127 | } |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 128 | . = ALIGN(16); |
| 129 | .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { |
| 130 | __setup_start = .; |
| 131 | *(.init.setup) |
| 132 | __setup_end = .; |
| 133 | } |
| 134 | .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) { |
| 135 | __initcall_start = .; |
| 136 | INITCALLS |
| 137 | __initcall_end = .; |
| 138 | } |
| 139 | .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) { |
| 140 | __con_initcall_start = .; |
| 141 | *(.con_initcall.init) |
| 142 | __con_initcall_end = .; |
| 143 | } |
Yinghai Lu | 10a434f | 2008-09-04 21:09:45 +0200 | [diff] [blame] | 144 | .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) { |
| 145 | __x86_cpu_dev_start = .; |
| 146 | *(.x86_cpu_dev.init) |
| 147 | __x86_cpu_dev_end = .; |
Thomas Petazzoni | 03ae576 | 2008-02-15 12:00:23 +0100 | [diff] [blame] | 148 | } |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 149 | SECURITY_INIT |
| 150 | . = ALIGN(4); |
| 151 | .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) { |
| 152 | __alt_instructions = .; |
| 153 | *(.altinstructions) |
| 154 | __alt_instructions_end = .; |
| 155 | } |
| 156 | .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) { |
| 157 | *(.altinstr_replacement) |
| 158 | } |
| 159 | . = ALIGN(4); |
| 160 | .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) { |
| 161 | __parainstructions = .; |
| 162 | *(.parainstructions) |
| 163 | __parainstructions_end = .; |
| 164 | } |
| 165 | /* .exit.text is discard at runtime, not link time, to deal with references |
| 166 | from .altinstructions and .eh_frame */ |
Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 167 | .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { |
| 168 | EXIT_TEXT |
| 169 | } |
| 170 | .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { |
| 171 | EXIT_DATA |
| 172 | } |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 173 | #if defined(CONFIG_BLK_DEV_INITRD) |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 174 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 175 | .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { |
| 176 | __initramfs_start = .; |
| 177 | *(.init.ramfs) |
| 178 | __initramfs_end = .; |
| 179 | } |
| 180 | #endif |
Tejun Heo | a698c82 | 2009-01-13 20:41:35 +0900 | [diff] [blame] | 181 | PERCPU(PAGE_SIZE) |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 182 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 183 | /* freed after init ends here */ |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 184 | |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 185 | .bss : AT(ADDR(.bss) - LOAD_OFFSET) { |
| 186 | __init_end = .; |
| 187 | __bss_start = .; /* BSS */ |
| 188 | *(.bss.page_aligned) |
| 189 | *(.bss) |
| 190 | . = ALIGN(4); |
| 191 | __bss_stop = .; |
Jeremy Fitzhardinge | 704439d | 2009-03-14 23:20:47 -0700 | [diff] [blame] | 192 | } |
Jeremy Fitzhardinge | 93dbda7 | 2009-02-26 17:35:44 -0800 | [diff] [blame] | 193 | |
Jeremy Fitzhardinge | 704439d | 2009-03-14 23:20:47 -0700 | [diff] [blame] | 194 | .brk : AT(ADDR(.brk) - LOAD_OFFSET) { |
Jeremy Fitzhardinge | 93dbda7 | 2009-02-26 17:35:44 -0800 | [diff] [blame] | 195 | . = ALIGN(PAGE_SIZE); |
| 196 | __brk_base = . ; |
Jeremy Fitzhardinge | 704439d | 2009-03-14 23:20:47 -0700 | [diff] [blame] | 197 | . += 64 * 1024 ; /* 64k alignment slop space */ |
Jeremy Fitzhardinge | 796216a | 2009-03-12 16:09:49 -0700 | [diff] [blame] | 198 | *(.brk_reservation) /* areas brk users have reserved */ |
Jeremy Fitzhardinge | 93dbda7 | 2009-02-26 17:35:44 -0800 | [diff] [blame] | 199 | __brk_limit = . ; |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 200 | } |
| 201 | |
H. Peter Anvin | 0a699af | 2009-03-17 14:14:31 -0700 | [diff] [blame] | 202 | .end : AT(ADDR(.end) - LOAD_OFFSET) { |
| 203 | _end = . ; |
| 204 | } |
Jeremy Fitzhardinge | 704439d | 2009-03-14 23:20:47 -0700 | [diff] [blame] | 205 | |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 206 | /* Sections to be discarded */ |
| 207 | /DISCARD/ : { |
| 208 | *(.exitcall.exit) |
Jeremy Fitzhardinge | 796216a | 2009-03-12 16:09:49 -0700 | [diff] [blame] | 209 | *(.discard) |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | STABS_DEBUG |
| 213 | |
| 214 | DWARF_DEBUG |
| 215 | } |
Huang Ying | fb45daa | 2008-08-15 00:40:23 -0700 | [diff] [blame] | 216 | |
Yinghai Lu | 2bd2753 | 2009-03-09 01:15:57 -0700 | [diff] [blame] | 217 | /* |
| 218 | * Build-time check on the image size: |
| 219 | */ |
| 220 | ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE), |
| 221 | "kernel image bigger than KERNEL_IMAGE_SIZE") |
| 222 | |
Huang Ying | fb45daa | 2008-08-15 00:40:23 -0700 | [diff] [blame] | 223 | #ifdef CONFIG_KEXEC |
| 224 | /* Link time checks */ |
| 225 | #include <asm/kexec.h> |
| 226 | |
| 227 | ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE, |
| 228 | "kexec control code size is too big") |
| 229 | #endif |