Chinaunix首页 | 论坛 | 博客
  • 博客访问: 773057
  • 博文数量: 215
  • 博客积分: 291
  • 博客等级: 二等列兵
  • 技术积分: 1031
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-12 18:17
文章分类

全部博文(215)

文章存档

2016年(16)

2015年(16)

2014年(123)

2013年(60)

分类: LINUX

2014-01-06 14:47:11

  1. vmlinux.lds.S用于对ld的输出进行组版,这个文件的格式在ld.info手册中有详细的说明。vmlinu
  2. x.lds.S的主要目的是对输出文件中段进行排序,并定义相关的符号名,以下是简要注释。

  3. /* ld script to make i386 Linux kernel
  4.  * Written by Martin Mares ;
  5.  */
  6. OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
  7. OUTPUT_ARCH(i386)        /* 输出格式 */
  8. ENTRY(_start)            /* 定义_start作为入口点 */
  9. SECTIONS
  10. {
  11.   . = PAGE_OFFSET_RAW + 0x100000; /* 定义当前段的偏移量(.代表当前计数器) */
  12.   _text = .;            /* 定义符号_text为当前位置 */
  13.   .text : {        /* 定义段.text (": {"是段定义符)*/
  14.     *(.text)    /* 将所有输入文件中.text段合并到这里 */
  15.     *(.fixup)    /* 将所有输入文件中的.fixup段合并到这里 */
  16.     *(.gnu.warning) /* 将所有输入文件中的.gnu.warning段合并到这里 */
  17.     } = 0x9090    /* 合并中的空隙用0x9090填充 */
  18.             /* 以下的语法含义可以类推 */
  19.   .text.lock : { *(.text.lock) }    /* out-of-line lock text */
  20.   .rodata : { *(.rodata) }
  21.   .kstrtab : { *(.kstrtab) }

  22.   . = ALIGN(16);        /* Exception table */
  23.   __start___ex_table = .;    /* 定义__start_ex_table符号为当前位置 */
  24.   __ex_table : { *(__ex_table) }
  25.   __stop___ex_table = .;

  26.   __start___ksymtab = .;    /* Kernel symbol table */
  27.   __ksymtab : { *(__ksymtab) }
  28.   __stop___ksymtab = .;

  29.   _etext = .;            /* End of text section */

  30.   .data : {            /* Data */
  31.     *(.data)
  32.     CONSTRUCTORS        /* 将C++的构造函数指针段合并到这里 */
  33.     }

  34.   _edata = .;            /* End of data section */

  35.   . = ALIGN(8192);        /* init_task */
  36.   .data.init_task : { *(.data.init_task) }

  37.   . = ALIGN(4096);        /* Init code and data */
  38.   __init_begin = .;
  39.   .text.init : { *(.text.init) }
  40.   .data.init : { *(.data.init) }
  41.   . = ALIGN(4096);        /* 输出计数器在页边界上对齐 */
  42.   __init_end = .;

  43.   . = ALIGN(32);
  44.   .data.cacheline_aligned : { *(.data.cacheline_aligned) }

  45.   . = ALIGN(4096);
  46.   .data.page_aligned : { *(.data.idt) }


  47.   __bss_start = .;        /* BSS */
  48.   .bss : {
  49.     *(.bss)
  50.     }
  51.   _end = . ;

  52.   /* Stabs debugging sections. */
  53.   .stab 0 : { *(.stab) }    /* 0 是段属性,代表段的起始地址 */
  54.   .stabstr 0 : { *(.stabstr) }
  55.   .stab.excl 0 : { *(.stab.excl) }
  56.   .stab.exclstr 0 : { *(.stab.exclstr) }
  57.   .stab.index 0 : { *(.stab.index) }
  58.   .stab.indexstr 0 : { *(.stab.indexstr) }
  59.   .comment 0 : { *(.comment) }
  60. }

编译内核生成vmlinux
 objdump --headers vmlinux 可以对照着看一下。

以下:

 

  1. [root@localhost linux-2.6.18.i686]# objdump --headers vmlinux

  2. vmlinux: file format elf32-i386

  3. Sections:
  4. Idx Name Size VMA LMA File off Algn
  5.   0 .text.head 000000a4 c0400000 00400000 00001000 2**2
  6.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  7.   1 .text 0021f9e6 c0401000 00401000 00002000 2**12
  8.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  9.   2 __ex_table 00000ea0 c06209f0 006209f0 002219f0 2**3
  10.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  11.   3 .rodata 0004da85 c0622000 00622000 00223000 2**5
  12.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  13.   4 .pci_fixup 00000608 c066fa88 0066fa88 00270a88 2**2
  14.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  15.   5 __ksymtab 00005310 c0670090 00670090 00271090 2**2
  16.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  17.   6 __ksymtab_gpl 000015b0 c06753a0 006753a0 002763a0 2**2
  18.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  19.   7 __ksymtab_gpl_future 00000018 c0676950 00676950 00277950 2**2
  20.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  21.   8 __kcrctab 00002988 c0676968 00676968 00277968 2**2
  22.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  23.   9 __kcrctab_gpl 00000ad8 c06792f0 006792f0 0027a2f0 2**2
  24.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  25.  10 __kcrctab_gpl_future 0000000c c0679dc8 00679dc8 0027adc8 2**2
  26.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  27.  11 __ksymtab_strings 0000ea6c c0679de0 00679de0 0027ade0 2**5
  28.                   CONTENTS, ALLOC, LOAD, READONLY, DATA
  29.  12 __param 0000080c c0689000 00689000 0028a000 2**2
  30.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  31.  13 .data 00069248 c068a000 0068a000 0028b000 2**7
  32.                   CONTENTS, ALLOC, LOAD, RELOC, DATA
  33.  14 .data_nosave 00002000 c06f4000 006f4000 002f5000 2**12
  34.                   CONTENTS, ALLOC, LOAD, DATA
  35.  15 .data.page_aligned 00000800 c06f6000 006f6000 002f7000 2**5
  36.                   CONTENTS, ALLOC, LOAD, DATA
  37.  16 .data.cacheline_aligned 0000c400 c06f6800 006f6800 002f7800 2**7
  38.                   CONTENTS, ALLOC, LOAD, RELOC, DATA
  39.  17 .data.read_mostly 00000dfc c0702c00 00702c00 00303c00 2**7
  40.                   CONTENTS, ALLOC, LOAD, RELOC, DATA
  41.  18 .data.init_task 00001000 c0704000 00704000 00305000 2**5
  42.                   CONTENTS, ALLOC, LOAD, RELOC, DATA
  43.  19 .smp_locks 000039d0 c0705000 00705000 00306000 2**2
  44.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  45.  20 .init.text 0001f9fa c0709000 00709000 0030a000 2**0
  46.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  47.  21 .init.data 0000e453 c0729000 00729000 0032a000 2**12
  48.                   CONTENTS, ALLOC, LOAD, RELOC, DATA
  49.  22 .init.setup 000006a8 c0737460 00737460 00338460 2**2
  50.                   CONTENTS, ALLOC, LOAD, RELOC, DATA
  51.  23 .initcall.init 00000458 c0737b08 00737b08 00338b08 2**2
  52.                   CONTENTS, ALLOC, LOAD, RELOC, DATA
  53.  24 .con_initcall.init 0000000c c0737f60 00737f60 00338f60 2**2
  54.                   CONTENTS, ALLOC, LOAD, RELOC, DATA
  55.  25 .security_initcall.init 00000008 c0737f6c 00737f6c 00338f6c 2**2
  56.                   CONTENTS, ALLOC, LOAD, RELOC, DATA
  57.  26 .altinstructions 00002b1f c0737f74 00737f74 00338f74 2**2
  58.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  59.  27 .altinstr_replacement 00000bf3 c073aa93 0073aa93 0033ba93 2**0
  60.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  61.  28 .exit.text 00000b31 c073b686 0073b686 0033c686 2**0
  62.                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  63.  29 .init.ramfs 00000086 c073d000 0073d000 0033e000 2**0
  64.                   CONTENTS, ALLOC, LOAD, READONLY, DATA
  65.  30 .data.percpu 00004e44 c073d100 0073d100 0033e100 2**7
  66.                   CONTENTS, ALLOC, LOAD, RELOC, DATA
  67.  31 .bss 000b7000 c0742000 00742000 00342f44 2**12
  68.                   ALLOC
  69.  32 .comment 0000b188 00000000 00000000 00342f44 2**0
  70.                   CONTENTS, READONLY
  71.  33 .debug_aranges 00009898 00000000 00000000 0034e0cc 2**0
  72.                   CONTENTS, RELOC, READONLY, DEBUGGING
  73.  34 .debug_pubnames 000322f6 00000000 00000000 00357964 2**0
  74.                   CONTENTS, RELOC, READONLY, DEBUGGING
  75.  35 .debug_info 022f80a7 00000000 00000000 00389c5a 2**0
  76.                   CONTENTS, RELOC, READONLY, DEBUGGING
  77.  36 .debug_abbrev 001115b5 00000000 00000000 02681d01 2**0
  78.                   CONTENTS, READONLY, DEBUGGING
  79.  37 .debug_line 001db4e8 00000000 00000000 027932b6 2**0
  80.                   CONTENTS, RELOC, READONLY, DEBUGGING
  81.  38 .debug_frame 0008f154 00000000 00000000 0296e7a0 2**2
  82.                   CONTENTS, RELOC, READONLY, DEBUGGING
  83.  39 .debug_str 000dac29 00000000 00000000 029fd8f4 2**0
  84.                   CONTENTS, READONLY, DEBUGGING
  85.  40 .debug_loc 00322d57 00000000 00000000 02ad851d 2**0
  86.                   CONTENTS, RELOC, READONLY, DEBUGGING
  87.  41 .debug_ranges 0006d9f8 00000000 00000000 02dfb274 2**0
  88.                   CONTENTS, RELOC, READONLY, DEBUGGING
阅读(797) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~