1 /* ld script to make i386 Linux kernel
2 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
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.
11 #define LOAD_OFFSET __PAGE_OFFSET
13 #include <asm-generic/vmlinux.lds.h>
14 #include <asm/thread_info.h>
15 #include <asm/page_types.h>
16 #include <asm/cache.h>
19 OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
21 ENTRY(phys_startup_32)
25 text PT_LOAD FLAGS(5); /* R_E */
26 data PT_LOAD FLAGS(7); /* RWE */
27 note PT_NOTE FLAGS(0); /* ___ */
31 . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
32 phys_startup_32 = startup_32 - LOAD_OFFSET;
34 /* Text and read-only data */
35 .text.head : AT(ADDR(.text.head) - LOAD_OFFSET) {
41 .text : AT(ADDR(.text) - LOAD_OFFSET) {
42 /* not really needed, already page aligned */
52 /* End of text section */
60 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
61 __start___ex_table = .;
63 __stop___ex_table = .;
71 .data : AT(ADDR(.data) - LOAD_OFFSET) {
77 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
85 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
91 .data.cacheline_aligned :
92 AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
93 *(.data.cacheline_aligned)
96 /* rarely changed data like cpu maps */
98 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
101 /* End of data section */
106 . = ALIGN(THREAD_SIZE);
107 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
111 . = ALIGN(PAGE_SIZE);
112 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
113 /* might get freed after init */
118 /* will be freed after init
119 * Following ALIGN() is required to make sure no other data falls on the
120 * same page where __smp_alt_end is pointing as that page might be freed
121 * after boot. Always make sure that ALIGN() directive is present after
122 * the section which contains __smp_alt_end.
124 . = ALIGN(PAGE_SIZE);
126 /* Init code and data - will be freed after init */
127 . = ALIGN(PAGE_SIZE);
128 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
135 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
140 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
145 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
146 __initcall_start = .;
151 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
152 __con_initcall_start = .;
153 *(.con_initcall.init)
154 __con_initcall_end = .;
157 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
158 __x86_cpu_dev_start = .;
160 __x86_cpu_dev_end = .;
166 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
167 __alt_instructions = .;
169 __alt_instructions_end = .;
172 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
173 *(.altinstr_replacement)
177 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
178 __parainstructions = .;
180 __parainstructions_end = .;
184 * .exit.text is discard at runtime, not link time, to deal with
185 * references from .altinstructions and .eh_frame
187 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
191 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
195 #if defined(CONFIG_BLK_DEV_INITRD)
196 . = ALIGN(PAGE_SIZE);
197 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
198 __initramfs_start = .;
206 . = ALIGN(PAGE_SIZE);
207 /* freed after init ends here */
210 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
219 .brk : AT(ADDR(.brk) - LOAD_OFFSET) {
220 . = ALIGN(PAGE_SIZE);
222 . += 64 * 1024; /* 64k alignment slop space */
223 *(.brk_reservation) /* areas brk users have reserved */
227 .end : AT(ADDR(.end) - LOAD_OFFSET) {
231 /* Sections to be discarded */
242 * Build-time check on the image size:
244 ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE),
245 "kernel image bigger than KERNEL_IMAGE_SIZE")
248 /* Link time checks */
249 #include <asm/kexec.h>
251 ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
252 "kexec control code size is too big")