参考上文:
http://www.cnblogs.com/long123king/p/3543872.html
http://www.cnblogs.com/long123king/p/3545688.html
补充:linker script documentation
http://www.nacad.ufrj.br/online/sgi/860-0247-001/sgi_html/ldLinker_scripts.html
参考:http://blog.chinaunix.net/uid-20499746-id-1663135.html
http://blog.csdn.net/redredbird/article/details/5986035
同类文章参考:
http://blog.chinaunix.net/uid-1701789-id-148056.html
http://www.cnblogs.com/cybertitan/archive/2012/09/29/2708184.html
1. 内核代码的布局
我们知道,内核代码被加载到物理内存1MB处,然后in_pm32跳转到1MB物理内存处执行。
那么1MB物理内存处存放的是什么代码呢?
我们先看一个链接器的脚本文件arch/x86/boot/compressed/vmlinux.lds.S
asm-generic/vmlinux.lds.h>
2:
3: OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT)
4:
#undef i386
6:
asm/cache.h>
asm/page_types.h>
9:
#ifdef CONFIG_X86_64
11: OUTPUT_ARCH(i386:x86-64)
12: ENTRY(startup_64)
#else
14: OUTPUT_ARCH(i386)
15: ENTRY(startup_32)
#endif
17:
18: SECTIONS
19: {
/* Be careful parts of head_64.S assume startup_32 is at
* address 0.
*/
23: . = 0;
24: .head.text : {
25: _head = . ;
26: HEAD_TEXT
27: _ehead = . ;
28: }
29: .rodata..compressed : {
30: *(.rodata..compressed)
31: }
32: .text : {
/* Text */
34: *(.text)
35: *(.text.*)
36: _etext = . ;
37: }
38: .rodata : {
39: _rodata = . ;
/* read-only data */
41: *(.rodata.*)
42: _erodata = . ;
43: }
44: .got : {
45: _got = .;
46: KEEP(*(.got.plt))
47: KEEP(*(.got))
48: _egot = .;
49: }
50: .data : {
51: _data = . ;
52: *(.data)
53: *(.data.*)
54: _edata = . ;
55: }
56: . = ALIGN(L1_CACHE_BYTES);
57: .bss : {
58: _bss = . ;
59: *(.bss)
60: *(.bss.*)
61: *(COMMON)
/* For convenience during zeroing */
63: _ebss = .;
64: }
#ifdef CONFIG_X86_64
66: . = ALIGN(PAGE_SIZE);
67: .pgtable : {
68: _pgtable = . ;
69: *(.pgtable)
70: _epgtable = . ;
71: }
#endif
73: _end = .;
74: }