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

J
Jeremy Fitzhardinge 已提交
63 64
  BUG_TABLE

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

72 73
  RODATA

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

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

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

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

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

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

G
Gerd Hoffmann 已提交
112 113 114
  /* might get freed after init */
  . = ALIGN(4096);
  .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
115
  	__smp_locks = .;
G
Gerd Hoffmann 已提交
116
	*(.smp_locks)
117
	__smp_locks_end = .;
G
Gerd Hoffmann 已提交
118
  }
119 120 121 122 123 124
  /* 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 已提交
125 126
  . = ALIGN(4096);

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

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

207 208 209
  STABS_DEBUG

  DWARF_DEBUG
210 211

  NOTES
L
Linus Torvalds 已提交
212
}