- vmlinux.lds.S用于对ld的输出进行组版,这个文件的格式在ld.info手册中有详细的说明。vmlinu
- x.lds.S的主要目的是对输出文件中段进行排序,并定义相关的符号名,以下是简要注释。
- /* ld script to make i386 Linux kernel
- * Written by Martin Mares ;
- */
- OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
- OUTPUT_ARCH(i386) /* 输出格式 */
- ENTRY(_start) /* 定义_start作为入口点 */
- SECTIONS
- {
- . = PAGE_OFFSET_RAW + 0x100000; /* 定义当前段的偏移量(.代表当前计数器) */
- _text = .; /* 定义符号_text为当前位置 */
- .text : { /* 定义段.text (": {"是段定义符)*/
- *(.text) /* 将所有输入文件中.text段合并到这里 */
- *(.fixup) /* 将所有输入文件中的.fixup段合并到这里 */
- *(.gnu.warning) /* 将所有输入文件中的.gnu.warning段合并到这里 */
- } = 0x9090 /* 合并中的空隙用0x9090填充 */
- /* 以下的语法含义可以类推 */
- .text.lock : { *(.text.lock) } /* out-of-line lock text */
- .rodata : { *(.rodata) }
- .kstrtab : { *(.kstrtab) }
- . = ALIGN(16); /* Exception table */
- __start___ex_table = .; /* 定义__start_ex_table符号为当前位置 */
- __ex_table : { *(__ex_table) }
- __stop___ex_table = .;
- __start___ksymtab = .; /* Kernel symbol table */
- __ksymtab : { *(__ksymtab) }
- __stop___ksymtab = .;
- _etext = .; /* End of text section */
- .data : { /* Data */
- *(.data)
- CONSTRUCTORS /* 将C++的构造函数指针段合并到这里 */
- }
- _edata = .; /* End of data section */
- . = ALIGN(8192); /* init_task */
- .data.init_task : { *(.data.init_task) }
- . = ALIGN(4096); /* Init code and data */
- __init_begin = .;
- .text.init : { *(.text.init) }
- .data.init : { *(.data.init) }
- . = ALIGN(4096); /* 输出计数器在页边界上对齐 */
- __init_end = .;
- . = ALIGN(32);
- .data.cacheline_aligned : { *(.data.cacheline_aligned) }
- . = ALIGN(4096);
- .data.page_aligned : { *(.data.idt) }
- __bss_start = .; /* BSS */
- .bss : {
- *(.bss)
- }
- _end = . ;
- /* Stabs debugging sections. */
- .stab 0 : { *(.stab) } /* 0 是段属性,代表段的起始地址 */
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
- }
编译内核生成vmlinux
objdump --headers vmlinux 可以对照着看一下。
以下:
- [root@localhost linux-2.6.18.i686]# objdump --headers vmlinux
- vmlinux: file format elf32-i386
- Sections:
- Idx Name Size VMA LMA File off Algn
- 0 .text.head 000000a4 c0400000 00400000 00001000 2**2
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
- 1 .text 0021f9e6 c0401000 00401000 00002000 2**12
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
- 2 __ex_table 00000ea0 c06209f0 006209f0 002219f0 2**3
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
- 3 .rodata 0004da85 c0622000 00622000 00223000 2**5
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
- 4 .pci_fixup 00000608 c066fa88 0066fa88 00270a88 2**2
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
- 5 __ksymtab 00005310 c0670090 00670090 00271090 2**2
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
- 6 __ksymtab_gpl 000015b0 c06753a0 006753a0 002763a0 2**2
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
- 7 __ksymtab_gpl_future 00000018 c0676950 00676950 00277950 2**2
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
- 8 __kcrctab 00002988 c0676968 00676968 00277968 2**2
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
- 9 __kcrctab_gpl 00000ad8 c06792f0 006792f0 0027a2f0 2**2
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
- 10 __kcrctab_gpl_future 0000000c c0679dc8 00679dc8 0027adc8 2**2
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
- 11 __ksymtab_strings 0000ea6c c0679de0 00679de0 0027ade0 2**5
- CONTENTS, ALLOC, LOAD, READONLY, DATA
- 12 __param 0000080c c0689000 00689000 0028a000 2**2
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
- 13 .data 00069248 c068a000 0068a000 0028b000 2**7
- CONTENTS, ALLOC, LOAD, RELOC, DATA
- 14 .data_nosave 00002000 c06f4000 006f4000 002f5000 2**12
- CONTENTS, ALLOC, LOAD, DATA
- 15 .data.page_aligned 00000800 c06f6000 006f6000 002f7000 2**5
- CONTENTS, ALLOC, LOAD, DATA
- 16 .data.cacheline_aligned 0000c400 c06f6800 006f6800 002f7800 2**7
- CONTENTS, ALLOC, LOAD, RELOC, DATA
- 17 .data.read_mostly 00000dfc c0702c00 00702c00 00303c00 2**7
- CONTENTS, ALLOC, LOAD, RELOC, DATA
- 18 .data.init_task 00001000 c0704000 00704000 00305000 2**5
- CONTENTS, ALLOC, LOAD, RELOC, DATA
- 19 .smp_locks 000039d0 c0705000 00705000 00306000 2**2
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
- 20 .init.text 0001f9fa c0709000 00709000 0030a000 2**0
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
- 21 .init.data 0000e453 c0729000 00729000 0032a000 2**12
- CONTENTS, ALLOC, LOAD, RELOC, DATA
- 22 .init.setup 000006a8 c0737460 00737460 00338460 2**2
- CONTENTS, ALLOC, LOAD, RELOC, DATA
- 23 .initcall.init 00000458 c0737b08 00737b08 00338b08 2**2
- CONTENTS, ALLOC, LOAD, RELOC, DATA
- 24 .con_initcall.init 0000000c c0737f60 00737f60 00338f60 2**2
- CONTENTS, ALLOC, LOAD, RELOC, DATA
- 25 .security_initcall.init 00000008 c0737f6c 00737f6c 00338f6c 2**2
- CONTENTS, ALLOC, LOAD, RELOC, DATA
- 26 .altinstructions 00002b1f c0737f74 00737f74 00338f74 2**2
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
- 27 .altinstr_replacement 00000bf3 c073aa93 0073aa93 0033ba93 2**0
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
- 28 .exit.text 00000b31 c073b686 0073b686 0033c686 2**0
- CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
- 29 .init.ramfs 00000086 c073d000 0073d000 0033e000 2**0
- CONTENTS, ALLOC, LOAD, READONLY, DATA
- 30 .data.percpu 00004e44 c073d100 0073d100 0033e100 2**7
- CONTENTS, ALLOC, LOAD, RELOC, DATA
- 31 .bss 000b7000 c0742000 00742000 00342f44 2**12
- ALLOC
- 32 .comment 0000b188 00000000 00000000 00342f44 2**0
- CONTENTS, READONLY
- 33 .debug_aranges 00009898 00000000 00000000 0034e0cc 2**0
- CONTENTS, RELOC, READONLY, DEBUGGING
- 34 .debug_pubnames 000322f6 00000000 00000000 00357964 2**0
- CONTENTS, RELOC, READONLY, DEBUGGING
- 35 .debug_info 022f80a7 00000000 00000000 00389c5a 2**0
- CONTENTS, RELOC, READONLY, DEBUGGING
- 36 .debug_abbrev 001115b5 00000000 00000000 02681d01 2**0
- CONTENTS, READONLY, DEBUGGING
- 37 .debug_line 001db4e8 00000000 00000000 027932b6 2**0
- CONTENTS, RELOC, READONLY, DEBUGGING
- 38 .debug_frame 0008f154 00000000 00000000 0296e7a0 2**2
- CONTENTS, RELOC, READONLY, DEBUGGING
- 39 .debug_str 000dac29 00000000 00000000 029fd8f4 2**0
- CONTENTS, READONLY, DEBUGGING
- 40 .debug_loc 00322d57 00000000 00000000 02ad851d 2**0
- CONTENTS, RELOC, READONLY, DEBUGGING
- 41 .debug_ranges 0006d9f8 00000000 00000000 02dfb274 2**0
- CONTENTS, RELOC, READONLY, DEBUGGING
阅读(6490) | 评论(1) | 转发(1) |