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.head : AT(ADDR(.text.head) - LOAD_OFFSET) {
35 _text = .; /* Text and read-only data */
40 .text : AT(ADDR(.text) - LOAD_OFFSET) {
41 . = ALIGN(PAGE_SIZE); /* not really needed, already page aligned */
50 _etext = .; /* End of text section */
55 . = ALIGN(16); /* Exception table */
56 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
57 __start___ex_table = .;
59 __stop___ex_table = .;
66 .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
72 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
80 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
86 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
87 *(.data.cacheline_aligned)
90 /* rarely changed data like cpu maps */
92 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
94 _edata = .; /* End of data section */
97 . = ALIGN(THREAD_SIZE); /* init_task */
98 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
102 /* might get freed after init */
103 . = ALIGN(PAGE_SIZE);
104 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
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.
115 . = ALIGN(PAGE_SIZE);
117 /* will be freed after init */
118 . = ALIGN(PAGE_SIZE); /* Init code and data */
119 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
125 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
129 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
134 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
135 __initcall_start = .;
139 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
140 __con_initcall_start = .;
141 *(.con_initcall.init)
142 __con_initcall_end = .;
144 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
145 __x86_cpu_dev_start = .;
147 __x86_cpu_dev_end = .;
151 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
152 __alt_instructions = .;
154 __alt_instructions_end = .;
156 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
157 *(.altinstr_replacement)
160 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
161 __parainstructions = .;
163 __parainstructions_end = .;
165 /* .exit.text is discard at runtime, not link time, to deal with references
166 from .altinstructions and .eh_frame */
167 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
170 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
173 #if defined(CONFIG_BLK_DEV_INITRD)
174 . = ALIGN(PAGE_SIZE);
175 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
176 __initramfs_start = .;
182 . = ALIGN(PAGE_SIZE);
183 /* freed after init ends here */
185 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
187 __bss_start = .; /* BSS */
194 .brk : AT(ADDR(.brk) - LOAD_OFFSET) {
195 . = ALIGN(PAGE_SIZE);
197 . += 64 * 1024 ; /* 64k alignment slop space */
198 *(.brk_reservation) /* areas brk users have reserved */
202 .end : AT(ADDR(.end) - LOAD_OFFSET) {
206 /* Sections to be discarded */
218 * Build-time check on the image size:
220 ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE),
221 "kernel image bigger than KERNEL_IMAGE_SIZE")
224 /* Link time checks */
225 #include <asm/kexec.h>
227 ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
228 "kexec control code size is too big")