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