vmlinux.lds.S 5.3 KB
Newer Older
L
Linus Torvalds 已提交
1 2
/* ld script to make i386 Linux kernel
 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
3 4 5 6 7 8
 *
 * Don't define absolute symbols until and unless you know that symbol
 * value is should remain constant even if kernel image is relocated
 * at run time. Absolute symbols are not relocated. If symbol value should
 * change if kernel is relocated, make the symbol section relative and
 * put it inside the section definition.
L
Linus Torvalds 已提交
9 10
 */

11 12 13 14 15 16
/* Don't define absolute symbols until and unless you know that symbol
 * value is should remain constant even if kernel image is relocated
 * at run time. Absolute symbols are not relocated. If symbol value should
 * change if kernel is relocated, make the symbol section relative and
 * put it inside the section definition.
 */
17 18
#define LOAD_OFFSET __PAGE_OFFSET

L
Linus Torvalds 已提交
19 20 21
#include <asm-generic/vmlinux.lds.h>
#include <asm/thread_info.h>
#include <asm/page.h>
22
#include <asm/cache.h>
23
#include <asm/boot.h>
L
Linus Torvalds 已提交
24 25 26

OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH(i386)
27
ENTRY(phys_startup_32)
L
Linus Torvalds 已提交
28
jiffies = jiffies_64;
29 30 31 32

PHDRS {
	text PT_LOAD FLAGS(5);	/* R_E */
	data PT_LOAD FLAGS(7);	/* RWE */
33
	note PT_NOTE FLAGS(0);	/* ___ */
34
}
L
Linus Torvalds 已提交
35 36
SECTIONS
{
37
  . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
38
  phys_startup_32 = startup_32 - LOAD_OFFSET;
39 40 41 42 43 44

  .text.head : AT(ADDR(.text.head) - LOAD_OFFSET) {
  	_text = .;			/* Text and read-only data */
	*(.text.head)
  } :text = 0x9090

L
Linus Torvalds 已提交
45
  /* read-only */
46
  .text : AT(ADDR(.text) - LOAD_OFFSET) {
47
	TEXT_TEXT
L
Linus Torvalds 已提交
48 49
	SCHED_TEXT
	LOCK_TEXT
50
	KPROBES_TEXT
L
Linus Torvalds 已提交
51 52
	*(.fixup)
	*(.gnu.warning)
53 54
  	_etext = .;			/* End of text section */
  } :text = 0x9090
L
Linus Torvalds 已提交
55 56

  . = ALIGN(16);		/* Exception table */
57 58 59 60 61
  __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
  	__start___ex_table = .;
	 *(__ex_table)
  	__stop___ex_table = .;
  }
L
Linus Torvalds 已提交
62

63 64 65
  NOTES :text :note

  BUG_TABLE :text
J
Jeremy Fitzhardinge 已提交
66

67 68
  . = ALIGN(4);
  .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
69
  	__tracedata_start = .;
70
	*(.tracedata)
71
  	__tracedata_end = .;
72 73
  }

74 75
  RODATA

L
Linus Torvalds 已提交
76
  /* writeable */
77
  . = ALIGN(4096);
78
  .data : AT(ADDR(.data) - LOAD_OFFSET) {	/* Data */
79
	DATA_DATA
L
Linus Torvalds 已提交
80
	CONSTRUCTORS
81
	} :data
L
Linus Torvalds 已提交
82 83

  . = ALIGN(4096);
84 85 86 87 88 89
  .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
  	__nosave_begin = .;
	*(.data.nosave)
  	. = ALIGN(4096);
  	__nosave_end = .;
  }
L
Linus Torvalds 已提交
90 91

  . = ALIGN(4096);
92
  .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
93
	*(.data.page_aligned)
94 95
	*(.data.idt)
  }
L
Linus Torvalds 已提交
96 97

  . = ALIGN(32);
98 99 100
  .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
	*(.data.cacheline_aligned)
  }
L
Linus Torvalds 已提交
101

102 103
  /* rarely changed data like cpu maps */
  . = ALIGN(32);
104 105 106 107
  .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
	*(.data.read_mostly)
	_edata = .;		/* End of data section */
  }
L
Linus Torvalds 已提交
108 109

  . = ALIGN(THREAD_SIZE);	/* init_task */
110 111 112
  .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
	*(.data.init_task)
  }
L
Linus Torvalds 已提交
113

G
Gerd Hoffmann 已提交
114 115 116
  /* might get freed after init */
  . = ALIGN(4096);
  .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
117
  	__smp_locks = .;
G
Gerd Hoffmann 已提交
118
	*(.smp_locks)
119
	__smp_locks_end = .;
G
Gerd Hoffmann 已提交
120
  }
121 122 123 124 125 126
  /* will be freed after init
   * Following ALIGN() is required to make sure no other data falls on the
   * same page where __smp_alt_end is pointing as that page might be freed
   * after boot. Always make sure that ALIGN() directive is present after
   * the section which contains __smp_alt_end.
   */
G
Gerd Hoffmann 已提交
127 128
  . = ALIGN(4096);

L
Linus Torvalds 已提交
129 130
  /* will be freed after init */
  . = ALIGN(4096);		/* Init code and data */
131
  .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
132
  	__init_begin = .;
L
Linus Torvalds 已提交
133 134 135 136
	_sinittext = .;
	*(.init.text)
	_einittext = .;
  }
137
  .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
L
Linus Torvalds 已提交
138
  . = ALIGN(16);
139 140 141 142 143
  .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
  	__setup_start = .;
	*(.init.setup)
  	__setup_end = .;
   }
144
  .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
145
  	__initcall_start = .;
146
	INITCALLS
147
  	__initcall_end = .;
L
Linus Torvalds 已提交
148
  }
149
  .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
150
  	__con_initcall_start = .;
151
	*(.con_initcall.init)
152
  	__con_initcall_end = .;
153
  }
L
Linus Torvalds 已提交
154 155
  SECURITY_INIT
  . = ALIGN(4);
156
  .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
157
  	__alt_instructions = .;
158
	*(.altinstructions)
159
	__alt_instructions_end = .;
160 161 162 163
  }
  .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
	*(.altinstr_replacement)
  }
164 165
  . = ALIGN(4);
  .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
166
  	__parainstructions = .;
167
	*(.parainstructions)
168
  	__parainstructions_end = .;
169
  }
L
Linus Torvalds 已提交
170 171
  /* .exit.text is discard at runtime, not link time, to deal with references
     from .altinstructions and .eh_frame */
172 173
  .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
  .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
174
#if defined(CONFIG_BLK_DEV_INITRD)
L
Linus Torvalds 已提交
175
  . = ALIGN(4096);
176 177 178 179 180
  .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
	__initramfs_start = .;
	*(.init.ramfs)
	__initramfs_end = .;
  }
181
#endif
182
  . = ALIGN(4096);
183 184 185
  .data.percpu  : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
	__per_cpu_start = .;
	*(.data.percpu)
186
	*(.data.percpu.shared_aligned)
187 188
	__per_cpu_end = .;
  }
L
Linus Torvalds 已提交
189 190 191
  . = ALIGN(4096);
  /* freed after init ends here */
	
192
  .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
193 194 195
	__init_end = .;
	__bss_start = .;		/* BSS */
	*(.bss.page_aligned)
L
Linus Torvalds 已提交
196
	*(.bss)
197 198 199 200 201 202
	. = ALIGN(4);
	__bss_stop = .;
  	_end = . ;
	/* This is where the kernel creates the early boot page tables */
	. = ALIGN(4096);
	pg0 = . ;
L
Linus Torvalds 已提交
203 204 205 206 207 208 209
  }

  /* Sections to be discarded */
  /DISCARD/ : {
	*(.exitcall.exit)
	}

210 211 212
  STABS_DEBUG

  DWARF_DEBUG
L
Linus Torvalds 已提交
213
}