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> |
| 15 | #include <asm/page.h> |
| 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 |
| 47 | *(.fixup) |
| 48 | *(.gnu.warning) |
| 49 | _etext = .; /* End of text section */ |
| 50 | } :text = 0x9090 |
| 51 | |
| 52 | . = ALIGN(16); /* Exception table */ |
| 53 | __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { |
| 54 | __start___ex_table = .; |
| 55 | *(__ex_table) |
| 56 | __stop___ex_table = .; |
| 57 | } |
| 58 | |
| 59 | NOTES :text :note |
| 60 | |
| 61 | BUG_TABLE :text |
| 62 | |
| 63 | . = ALIGN(4); |
| 64 | .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { |
| 65 | __tracedata_start = .; |
| 66 | *(.tracedata) |
| 67 | __tracedata_end = .; |
| 68 | } |
| 69 | |
| 70 | RODATA |
| 71 | |
| 72 | /* writeable */ |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 73 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 74 | .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */ |
| 75 | DATA_DATA |
| 76 | CONSTRUCTORS |
| 77 | } :data |
| 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_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { |
| 81 | __nosave_begin = .; |
| 82 | *(.data.nosave) |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 83 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 84 | __nosave_end = .; |
| 85 | } |
| 86 | |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 87 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 88 | .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) { |
| 89 | *(.data.page_aligned) |
| 90 | *(.data.idt) |
| 91 | } |
| 92 | |
| 93 | . = ALIGN(32); |
| 94 | .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) { |
| 95 | *(.data.cacheline_aligned) |
| 96 | } |
| 97 | |
| 98 | /* rarely changed data like cpu maps */ |
| 99 | . = ALIGN(32); |
| 100 | .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) { |
| 101 | *(.data.read_mostly) |
| 102 | _edata = .; /* End of data section */ |
| 103 | } |
| 104 | |
| 105 | . = ALIGN(THREAD_SIZE); /* init_task */ |
| 106 | .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) { |
| 107 | *(.data.init_task) |
| 108 | } |
| 109 | |
| 110 | /* might get freed after init */ |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 111 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 112 | .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) { |
| 113 | __smp_locks = .; |
| 114 | *(.smp_locks) |
| 115 | __smp_locks_end = .; |
| 116 | } |
| 117 | /* will be freed after init |
| 118 | * Following ALIGN() is required to make sure no other data falls on the |
| 119 | * same page where __smp_alt_end is pointing as that page might be freed |
| 120 | * after boot. Always make sure that ALIGN() directive is present after |
| 121 | * the section which contains __smp_alt_end. |
| 122 | */ |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 123 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 124 | |
| 125 | /* will be freed after init */ |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 126 | . = ALIGN(PAGE_SIZE); /* Init code and data */ |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 127 | .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { |
| 128 | __init_begin = .; |
| 129 | _sinittext = .; |
Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 130 | INIT_TEXT |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 131 | _einittext = .; |
| 132 | } |
Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 133 | .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { |
| 134 | INIT_DATA |
| 135 | } |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 136 | . = ALIGN(16); |
| 137 | .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { |
| 138 | __setup_start = .; |
| 139 | *(.init.setup) |
| 140 | __setup_end = .; |
| 141 | } |
| 142 | .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) { |
| 143 | __initcall_start = .; |
| 144 | INITCALLS |
| 145 | __initcall_end = .; |
| 146 | } |
| 147 | .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) { |
| 148 | __con_initcall_start = .; |
| 149 | *(.con_initcall.init) |
| 150 | __con_initcall_end = .; |
| 151 | } |
Thomas Petazzoni | 03ae576 | 2008-02-15 12:00:23 +0100 | [diff] [blame] | 152 | .x86cpuvendor.init : AT(ADDR(.x86cpuvendor.init) - LOAD_OFFSET) { |
| 153 | __x86cpuvendor_start = .; |
| 154 | *(.x86cpuvendor.init) |
| 155 | __x86cpuvendor_end = .; |
| 156 | } |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 157 | SECURITY_INIT |
| 158 | . = ALIGN(4); |
| 159 | .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) { |
| 160 | __alt_instructions = .; |
| 161 | *(.altinstructions) |
| 162 | __alt_instructions_end = .; |
| 163 | } |
| 164 | .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) { |
| 165 | *(.altinstr_replacement) |
| 166 | } |
| 167 | . = ALIGN(4); |
| 168 | .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) { |
| 169 | __parainstructions = .; |
| 170 | *(.parainstructions) |
| 171 | __parainstructions_end = .; |
| 172 | } |
| 173 | /* .exit.text is discard at runtime, not link time, to deal with references |
| 174 | from .altinstructions and .eh_frame */ |
Sam Ravnborg | 01ba2bd | 2008-01-20 14:15:03 +0100 | [diff] [blame] | 175 | .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { |
| 176 | EXIT_TEXT |
| 177 | } |
| 178 | .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { |
| 179 | EXIT_DATA |
| 180 | } |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 181 | #if defined(CONFIG_BLK_DEV_INITRD) |
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 | .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { |
| 184 | __initramfs_start = .; |
| 185 | *(.init.ramfs) |
| 186 | __initramfs_end = .; |
| 187 | } |
| 188 | #endif |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 189 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 190 | .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { |
| 191 | __per_cpu_start = .; |
| 192 | *(.data.percpu) |
| 193 | *(.data.percpu.shared_aligned) |
| 194 | __per_cpu_end = .; |
| 195 | } |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 196 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 197 | /* freed after init ends here */ |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 198 | |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 199 | .bss : AT(ADDR(.bss) - LOAD_OFFSET) { |
| 200 | __init_end = .; |
| 201 | __bss_start = .; /* BSS */ |
| 202 | *(.bss.page_aligned) |
| 203 | *(.bss) |
| 204 | . = ALIGN(4); |
| 205 | __bss_stop = .; |
| 206 | _end = . ; |
| 207 | /* This is where the kernel creates the early boot page tables */ |
Cyrill Gorcunov | 3cdac41 | 2008-02-17 18:17:17 +0300 | [diff] [blame] | 208 | . = ALIGN(PAGE_SIZE); |
Thomas Gleixner | a60b778 | 2007-10-11 11:12:11 +0200 | [diff] [blame] | 209 | pg0 = . ; |
| 210 | } |
| 211 | |
| 212 | /* Sections to be discarded */ |
| 213 | /DISCARD/ : { |
| 214 | *(.exitcall.exit) |
| 215 | } |
| 216 | |
| 217 | STABS_DEBUG |
| 218 | |
| 219 | DWARF_DEBUG |
| 220 | } |