Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* ld script to make i386 Linux kernel |
| 2 | * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>; |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
Vivek Goyal | 79929fd | 2006-12-07 02:14:10 +0100 | [diff] [blame] | 11 | /* Don't define absolute symbols until and unless you know that symbol |
| 12 | * value is should remain constant even if kernel image is relocated |
| 13 | * at run time. Absolute symbols are not relocated. If symbol value should |
| 14 | * change if kernel is relocated, make the symbol section relative and |
| 15 | * put it inside the section definition. |
| 16 | */ |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 17 | #define LOAD_OFFSET __PAGE_OFFSET |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <asm-generic/vmlinux.lds.h> |
| 20 | #include <asm/thread_info.h> |
| 21 | #include <asm/page.h> |
Zach Brown | 379b544 | 2006-01-27 14:02:47 -0800 | [diff] [blame] | 22 | #include <asm/cache.h> |
Vivek Goyal | e69f202 | 2006-12-07 02:14:04 +0100 | [diff] [blame] | 23 | #include <asm/boot.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") |
| 26 | OUTPUT_ARCH(i386) |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 27 | ENTRY(phys_startup_32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | jiffies = jiffies_64; |
Andi Kleen | 1bac3b3 | 2006-12-09 21:33:36 +0100 | [diff] [blame] | 29 | _proxy_pda = 0; |
Jeremy Fitzhardinge | 9c9b8b3 | 2006-09-25 23:32:26 -0700 | [diff] [blame] | 30 | |
| 31 | PHDRS { |
| 32 | text PT_LOAD FLAGS(5); /* R_E */ |
| 33 | data PT_LOAD FLAGS(7); /* RWE */ |
| 34 | note PT_NOTE FLAGS(4); /* R__ */ |
| 35 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | SECTIONS |
| 37 | { |
Vivek Goyal | e69f202 | 2006-12-07 02:14:04 +0100 | [diff] [blame] | 38 | . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR; |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 39 | phys_startup_32 = startup_32 - LOAD_OFFSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | /* read-only */ |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 41 | .text : AT(ADDR(.text) - LOAD_OFFSET) { |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 42 | _text = .; /* Text and read-only data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | *(.text) |
| 44 | SCHED_TEXT |
| 45 | LOCK_TEXT |
Prasanna S Panchamukhi | 3d97ae5 | 2005-09-06 15:19:27 -0700 | [diff] [blame] | 46 | KPROBES_TEXT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | *(.fixup) |
| 48 | *(.gnu.warning) |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 49 | _etext = .; /* End of text section */ |
| 50 | } :text = 0x9090 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
| 52 | . = ALIGN(16); /* Exception table */ |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 53 | __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { |
| 54 | __start___ex_table = .; |
| 55 | *(__ex_table) |
| 56 | __stop___ex_table = .; |
| 57 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | RODATA |
| 60 | |
Jeremy Fitzhardinge | 91768d6 | 2006-12-08 02:36:21 -0800 | [diff] [blame] | 61 | BUG_TABLE |
| 62 | |
Linus Torvalds | eb71c87 | 2006-06-24 14:27:42 -0700 | [diff] [blame] | 63 | . = ALIGN(4); |
Linus Torvalds | eb71c87 | 2006-06-24 14:27:42 -0700 | [diff] [blame] | 64 | .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 65 | __tracedata_start = .; |
Linus Torvalds | eb71c87 | 2006-06-24 14:27:42 -0700 | [diff] [blame] | 66 | *(.tracedata) |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 67 | __tracedata_end = .; |
Linus Torvalds | eb71c87 | 2006-06-24 14:27:42 -0700 | [diff] [blame] | 68 | } |
Linus Torvalds | eb71c87 | 2006-06-24 14:27:42 -0700 | [diff] [blame] | 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | /* writeable */ |
Vivek Goyal | c06cb8b | 2006-11-08 17:44:41 -0800 | [diff] [blame] | 71 | . = ALIGN(4096); |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 72 | .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | *(.data) |
| 74 | CONSTRUCTORS |
Jeremy Fitzhardinge | 9c9b8b3 | 2006-09-25 23:32:26 -0700 | [diff] [blame] | 75 | } :data |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
Rusty Russell | c9ccf30 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 77 | .paravirtprobe : AT(ADDR(.paravirtprobe) - LOAD_OFFSET) { |
Vivek Goyal | 79929fd | 2006-12-07 02:14:10 +0100 | [diff] [blame] | 78 | __start_paravirtprobe = .; |
Rusty Russell | c9ccf30 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 79 | *(.paravirtprobe) |
Vivek Goyal | 79929fd | 2006-12-07 02:14:10 +0100 | [diff] [blame] | 80 | __stop_paravirtprobe = .; |
Rusty Russell | c9ccf30 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 81 | } |
Rusty Russell | c9ccf30 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 82 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | . = ALIGN(4096); |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 84 | .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { |
| 85 | __nosave_begin = .; |
| 86 | *(.data.nosave) |
| 87 | . = ALIGN(4096); |
| 88 | __nosave_end = .; |
| 89 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | |
| 91 | . = ALIGN(4096); |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 92 | .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) { |
| 93 | *(.data.idt) |
| 94 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
| 96 | . = ALIGN(32); |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 97 | .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) { |
| 98 | *(.data.cacheline_aligned) |
| 99 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | |
Christoph Lameter | 6c03652 | 2005-07-07 17:56:59 -0700 | [diff] [blame] | 101 | /* rarely changed data like cpu maps */ |
| 102 | . = ALIGN(32); |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 103 | .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) { |
| 104 | *(.data.read_mostly) |
| 105 | _edata = .; /* End of data section */ |
| 106 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
| 108 | . = ALIGN(THREAD_SIZE); /* init_task */ |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 109 | .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) { |
| 110 | *(.data.init_task) |
| 111 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
Gerd Hoffmann | 9a0b581 | 2006-03-23 02:59:32 -0800 | [diff] [blame] | 113 | /* might get freed after init */ |
| 114 | . = ALIGN(4096); |
Gerd Hoffmann | 9a0b581 | 2006-03-23 02:59:32 -0800 | [diff] [blame] | 115 | .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) { |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 116 | __smp_alt_begin = .; |
| 117 | __smp_alt_instructions = .; |
Gerd Hoffmann | 9a0b581 | 2006-03-23 02:59:32 -0800 | [diff] [blame] | 118 | *(.smp_altinstructions) |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 119 | __smp_alt_instructions_end = .; |
Gerd Hoffmann | 9a0b581 | 2006-03-23 02:59:32 -0800 | [diff] [blame] | 120 | } |
Gerd Hoffmann | 9a0b581 | 2006-03-23 02:59:32 -0800 | [diff] [blame] | 121 | . = ALIGN(4); |
Gerd Hoffmann | 9a0b581 | 2006-03-23 02:59:32 -0800 | [diff] [blame] | 122 | .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) { |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 123 | __smp_locks = .; |
Gerd Hoffmann | 9a0b581 | 2006-03-23 02:59:32 -0800 | [diff] [blame] | 124 | *(.smp_locks) |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 125 | __smp_locks_end = .; |
Gerd Hoffmann | 9a0b581 | 2006-03-23 02:59:32 -0800 | [diff] [blame] | 126 | } |
Gerd Hoffmann | 9a0b581 | 2006-03-23 02:59:32 -0800 | [diff] [blame] | 127 | .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) { |
| 128 | *(.smp_altinstr_replacement) |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 129 | __smp_alt_end = .; |
Gerd Hoffmann | 9a0b581 | 2006-03-23 02:59:32 -0800 | [diff] [blame] | 130 | } |
Vivek Goyal | 6ed0188 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 131 | /* will be freed after init |
| 132 | * Following ALIGN() is required to make sure no other data falls on the |
| 133 | * same page where __smp_alt_end is pointing as that page might be freed |
| 134 | * after boot. Always make sure that ALIGN() directive is present after |
| 135 | * the section which contains __smp_alt_end. |
| 136 | */ |
Gerd Hoffmann | 9a0b581 | 2006-03-23 02:59:32 -0800 | [diff] [blame] | 137 | . = ALIGN(4096); |
Gerd Hoffmann | 9a0b581 | 2006-03-23 02:59:32 -0800 | [diff] [blame] | 138 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | /* will be freed after init */ |
| 140 | . = ALIGN(4096); /* Init code and data */ |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 141 | .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 142 | __init_begin = .; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | _sinittext = .; |
| 144 | *(.init.text) |
| 145 | _einittext = .; |
| 146 | } |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 147 | .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | . = ALIGN(16); |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 149 | .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { |
| 150 | __setup_start = .; |
| 151 | *(.init.setup) |
| 152 | __setup_end = .; |
| 153 | } |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 154 | .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) { |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 155 | __initcall_start = .; |
Andrew Morton | 61ce1ef | 2006-10-27 11:41:44 -0700 | [diff] [blame] | 156 | INITCALLS |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 157 | __initcall_end = .; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | } |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 159 | .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) { |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 160 | __con_initcall_start = .; |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 161 | *(.con_initcall.init) |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 162 | __con_initcall_end = .; |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 163 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | SECURITY_INIT |
| 165 | . = ALIGN(4); |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 166 | .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) { |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 167 | __alt_instructions = .; |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 168 | *(.altinstructions) |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 169 | __alt_instructions_end = .; |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 170 | } |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 171 | .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) { |
| 172 | *(.altinstr_replacement) |
| 173 | } |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 174 | . = ALIGN(4); |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 175 | .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) { |
Vivek Goyal | 79929fd | 2006-12-07 02:14:10 +0100 | [diff] [blame] | 176 | __start_parainstructions = .; |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 177 | *(.parainstructions) |
Vivek Goyal | 79929fd | 2006-12-07 02:14:10 +0100 | [diff] [blame] | 178 | __stop_parainstructions = .; |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 179 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | /* .exit.text is discard at runtime, not link time, to deal with references |
| 181 | from .altinstructions and .eh_frame */ |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 182 | .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) } |
| 183 | .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) } |
Jean-Paul Saman | 67d3822 | 2007-02-10 01:44:44 -0800 | [diff] [blame^] | 184 | #if defined(CONFIG_BLK_DEV_INITRD) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | . = ALIGN(4096); |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 186 | .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { |
| 187 | __initramfs_start = .; |
| 188 | *(.init.ramfs) |
| 189 | __initramfs_end = .; |
| 190 | } |
Jean-Paul Saman | 67d3822 | 2007-02-10 01:44:44 -0800 | [diff] [blame^] | 191 | #endif |
Zach Brown | 379b544 | 2006-01-27 14:02:47 -0800 | [diff] [blame] | 192 | . = ALIGN(L1_CACHE_BYTES); |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 193 | .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { |
| 194 | __per_cpu_start = .; |
| 195 | *(.data.percpu) |
| 196 | __per_cpu_end = .; |
| 197 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | . = ALIGN(4096); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | /* freed after init ends here */ |
| 200 | |
Eric W. Biederman | ad0d75e | 2005-06-25 14:57:47 -0700 | [diff] [blame] | 201 | .bss : AT(ADDR(.bss) - LOAD_OFFSET) { |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 202 | __init_end = .; |
| 203 | __bss_start = .; /* BSS */ |
| 204 | *(.bss.page_aligned) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | *(.bss) |
Vivek Goyal | 6569580 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 206 | . = ALIGN(4); |
| 207 | __bss_stop = .; |
| 208 | _end = . ; |
| 209 | /* This is where the kernel creates the early boot page tables */ |
| 210 | . = ALIGN(4096); |
| 211 | pg0 = . ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | |
| 214 | /* Sections to be discarded */ |
| 215 | /DISCARD/ : { |
| 216 | *(.exitcall.exit) |
| 217 | } |
| 218 | |
Paolo 'Blaisorblade' Giarrusso | a7d0c21 | 2005-09-10 19:44:54 +0200 | [diff] [blame] | 219 | STABS_DEBUG |
| 220 | |
| 221 | DWARF_DEBUG |
Jeremy Fitzhardinge | 9c9b8b3 | 2006-09-25 23:32:26 -0700 | [diff] [blame] | 222 | |
| 223 | NOTES |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | } |