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) {
L
Linus Torvalds 已提交
47 48 49
	*(.text)
	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 */
L
Linus Torvalds 已提交
77 78
	*(.data)
	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 91 92
  .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
	*(.data.idt)
  }
L
Linus Torvalds 已提交
93 94

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

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

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

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

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

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

206 207 208
  STABS_DEBUG

  DWARF_DEBUG
209 210

  NOTES
L
Linus Torvalds 已提交
211
}