FreeFlyOS【二十五】:elf部分详解

本文详细探讨了FreeFlyOS内核如何作为ELF文件,阐述了内核在硬盘和内存中大小的区别。通过特定命令获取ELF文件基本信息,强调硬盘上的ELF文件不包含BSS段,而内存加载时需为BSS段分配空间以避免页错误。
摘要由CSDN通过智能技术生成
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0x100000
  Start of program headers:          52 (bytes into file)
  Start of section headers:          241288 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         5
  Size of section headers:           40 (bytes)
  Number of section headers:         23
  Section header string table index: 22

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .init.text        PROGBITS        00100000 001000 0001f5 00  AX  0   0  1
  [ 2] .init.data        PROGBITS        00101000 002000 008000 00  WA  0   0 4096
  [ 3] .user.text        PROGBITS        40000000 019000 00167c 00  AX  0   0  1
  [ 4] .user.data        PROGBITS        4000167c 01a67c 000004 00  WA  0   0  4
  [ 5] .user.rodata      PROGBITS        40001680 01a680 000623 00   A  0   0  4
  [ 6] .user.bss         NOBITS          40001cc0 01aca3 0004c0 00  WA  0   0 32
  [ 7] .text             PROGBITS        c1000000 00a000 00af40 00  AX  0   0  1
  [ 8] .rodata           PROGBITS        c100af40 014f40 001967 00   A  0   0  4
  [ 9] .data             PROGBITS        c100d000 017000 001b2c 00  WA  0   0 32
  [10] .bss              NOBITS          c100f000 018b2c a053c0 00  WA  0   0 4096
  [11] .debug_info       PROGBITS        00000000 01aca3 00c8f4 00      0   0  1
  [12] .debug_abbrev     PROGBITS        00000000 027597 003372 00      0   0  1
  [13] .debug_aranges    PROGBITS        00000000 02a909 000400 00      0   0  1
  [14] .debug_ranges     PROGBITS        00000000 02ad09 000060 00      0   0  1
  [15] .debug_line       PROGBITS        00000000 02ad69 0065c3 00      0   0  1
  [16] .debug_str        PROGBITS        00000000 03132c 002a67 01  MS  0   0  1
  [17] .comment          PROGBITS        00000000 033d93 000011 01  MS  0   0  1
  [18] .stab             PROGBITS        00000000 033da4 002610 0c     19   0  4
  [19] .stabstr          STRTAB          00000000 0363b4 0001d4 00      0   0  1
  [20] .symtab           SYMTAB          00000000 036588 002dc0 10     21 211  4
  [21] .strtab           STRTAB          00000000 039348 001a7b 00      0   0  1
  [22] .shstrtab         STRTAB          00000000 03adc3 0000c4 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  p (processor specific)

There are no section groups in this file.

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x001000 0x00100000 0x00100000 0x001f5 0x001f5 R E 0x1000
  LOAD           0x002000 0x00101000 0x00101000 0x08000 0x08000 RW  0x1000
  LOAD           0x00a000 0xc1000000 0x01000000 0x0c8a7 0x0c8a7 R E 0x1000
  LOAD           0x017000 0xc100d000 0x0100d000 0x01b2c 0xa073c0 RW  0x1000
  LOAD           0x019000 0x40000000 0x40000000 0x01ca3 0x02180 RWE 0x1000

 Section to Segment mapping:
  Segment Sections...
   00     .init.text 
   01     .init.data 
   02     .text .rodata 
   03     .data .bss 
   04     .user.text .user.data .user.rodata .user.bss 

There is no dynamic section in this file.

There are no relocations in this file.

The decoding of unwind sections for machine type Intel 80386 is not currently supported.

Symbol table '.symtab' contains 732 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 00100000     0 SECTION LOCAL  DEFAULT    1 
     2: 00101000     0 SECTION LOCAL  DEFAULT    2 
     3: 40000000     0 SECTION LOCAL  DEFAULT    3 
     4: 4000167c     0 SECTION LOCAL  DEFAULT    4 
     5: 40001680     0 SECTION LOCAL  DEFAULT    5 
     6: 40001cc0     0 SECTION LOCAL  DEFAULT    6 
     7: c1000000     0 SECTION LOCAL  DEFAULT    7 
     8: c100af40     0 SECTION LOCAL  DEFAULT    8 
     9: c100d000     0 SECTION LOCAL  DEFAULT    9 
    10: c100f000     0 SECTION LOCAL  DEFAULT   10 
    11: 00000000     0 SECTION LOCAL  DEFAULT   11 
    12: 00000000     0 SECTION LOCAL  DEFAULT   12 
    13: 00000000     0 SECTION LOCAL  DEFAULT   13 
    14: 00000000     0 SECTION LOCAL  DEFAULT   14 
    15: 00000000     0 SECTION LOCAL  DEFAULT   15 
    16: 00000000     0 SECTION LOCAL  DEFAULT   16 
    17: 00000000     0 SECTION LOCAL  DEFAULT   17 
    18: 00000000     0 SECTION LOCAL  DEFAULT   18 
    19: 00000000     0 SECTION LOCAL  DEFAULT   19 
    20: 00000000     0 FILE    LOCAL  DEFAULT  ABS init.c
    21: 00000000     0 FILE    LOCAL  DEFAULT  ABS user_main.c
    22: 40000000    47 FUNC    LOCAL  DEFAULT    3 delay
    23: 00000000     0 FILE    LOCAL  DEFAULT  ABS user_syscall.c
    24: 400000ba    92 FUNC    LOCAL  DEFAULT    3 user_syscall
    25: 00000000     0 FILE    LOCAL  DEFAULT  ABS stdio.c
    26: 00000000     0 FILE    LOCAL  DEFAULT  ABS shell.c
    27: 400020c0   128 OBJECT  LOCAL  DEFAULT    6 cmd_line
    28: 40002140    64 OBJECT  LOCAL  DEFAULT    6 argv
    29: 4000069d   176 FUNC    LOCAL  DEFAULT    3 user_readline
    30: 4000074d   196 FUNC    LOCAL  DEFAULT    3 cmd_parse
    31: 00000000     0 FILE    LOCAL  DEFAULT  ABS string.c
    32: 40000ba2    44 FUNC    LOCAL  DEFAULT    3 __memset
    33: 40000c34    61 FUNC    LOCAL  DEFAULT    3 __strcmp
    34: 40000ceb    61 FUNC    LOCAL  DEFAULT    3 __memcpy
    35: 00000000     0 FILE    LOCAL  DEFAULT  ABS buildin_cmd.c
    36: 40000d6e    94 FUNC    LOCAL  DEFAULT    3 path_parse
    37: 40000dcc   330 FUNC    LOCAL  DEFAULT    3 wash_path
    38: 00000000     0 FILE    LOCAL  DEFAULT  ABS asm.c
    39: c100007e    44 FUNC    LOCAL  DEFAULT    7 __memset
    40: c10000cb    61 FUNC    LOCAL  DEFAULT    7 __memcpy
    41: c1000146    61 FUNC    LOCAL  DEFAULT    7 __strcmp
    42: 00000000     0 FILE    LOCAL  DEFAULT  ABS debug.c
    43: 00000000     0 FILE    LOCAL  DEFAULT  ABS monitor.c
    44: 00000000     0 FILE    LOCAL  DEFAULT  ABS readline.c
    45: c100f000  1024 OBJECT  LOCAL  DEFAULT   10 buf
    46: 00000000     0 FILE    LOCAL  DEFAULT  ABS dt.c
    47: c100f400  2048 OBJECT  LOCAL  DEFAULT   10 idt
    48: c100d078     6 OBJECT  LOCAL  DEFAULT    9 gdtinfo
    49: c100fc00   104 OBJECT  LOCAL  DEFAULT   10 ts
    50: c100d080     6 OBJECT  LOCAL  DEFAULT    9 idtinfo
    51: c1000685    54 FUNC    LOCAL  DEFAULT    7 lgdt
    52: c10007ba    12 FUNC    LOCAL  DEFAULT    7 lidt
    53: 00000000     0 FILE    LOCAL  DEFAULT  ABS trap.c
    54: c10009bf    37 FUNC    LOCAL  DEFAULT    7 hash32
    55: c100d0a0    96 OBJECT  LOCAL  DEFAULT    9 IA32flags
    56: c1000bfb   303 FUNC    LOCAL  DEFAULT    7 trap_dispatch
    57: 00000000     0 FILE    LOCAL  DEFAULT  ABS syscall.c
    58: c1001867    37 FUNC    LOCAL  DEFAULT    7 hash32
    59: c100188c    35 FUNC    LOCAL  DEFAULT    7 syscall_exit
    60: c10018af    47 FUNC    LOCAL  DEFAULT    7 sys_fork
    61: c10018de    30 FUNC    LOCAL  DEFAULT    7 syscall_wait
    62: c10018fc    44 FUNC    LOCAL  DEFAULT    7 sys_exec
    63: c1001928     6 FUNC    LOCAL  DEFAULT    7 sys_yield
    64: c100192e    17 FUNC    LOCAL  DEFAULT    7 sys_kill
    65: c100193f    13 FUNC    LOCAL  DEFAULT    7 sys_getpid
    66: c100194c    41 FUNC    LOCAL  DEFAULT    7 sys_print_char
    67: c1001975    39 FUNC    LOCAL  DEFAULT    7 sys_print_string
    68: c100199c    92 FUNC    LOCAL  DEFAULT    7 sys_print_num
    69: c10019f8    18 FUNC    LOCAL  DEFAULT    7 sys_backtrace
    70: c1001a0a    10 FUNC    LOCAL  DEFAULT    7 sys_pgdir
    71: c1001a14    56 FUNC    LOCAL  DEFAULT    7 sys_fdread
    72: c1001a4c    46 FUNC    LOCAL  DEFAULT    7 syscall_open
    73: c1001a7a    30 FUNC    LOCAL  DEFAULT    7 syscall_close
    74: c1001a98    56 FUNC    LOCAL  DEFAULT    7 syscall_write
    75: c1001ad0    60 FUNC    LOCAL  DEFAULT    7 syscall_lseek
    76: c1001b0c    30 FUNC    LOCAL  DEFAULT    7 syscall_unlink
    77: c1001b2a    30 FUNC    LOCAL  DEFAULT    7 syscall_mkdir
    78: c1001b48    30 FUNC    LOCAL  DEFAULT    7 syscall_rmdir
    79: c1001b66    35 FUNC    LOCAL  DEFAULT    7 syscall_rewinddir
    80: c1001b89    42 FUNC    LOCAL  DEFAULT    7 syscall_getcwd
    81: c1001bb3    30 FUNC    LOCAL  DEFAULT    7 syscall_chdir
    82: c1001bd1    44 FUNC    LOCAL  DEFAULT    7 syscall_stat
    83: c1001bfd    30 FUNC    LOCAL  DEFAULT    7 syscall_opendir
    84: c1001c1b    30 FUNC    LOCAL  DEFAULT    7 syscall_closedir
    85: c1001c39    30 FUNC    LOCAL  DEFAULT    7 syscall_readdir
    86: c1001c57    18 FUNC    LOCAL  DEFAULT    7 syscall_print_task
    87: c1001c69    30 FUNC    LOCAL  DEFAULT    7 syscall_malloc
    88: c1001c87    47 FUNC    LOCAL  DEFAULT    7 syscall_free
    89: c1001cb6    35 FUNC    LOCAL  DEFAULT    7 syscall_pipe
    90: c100d500   236 OBJECT  LOCAL  DEFAULT    9 syscalls
    91: 00000000     0 FILE    LOCAL  DEFAULT  ABS keyboard.c
    92: c100d600   256 OBJECT  LOCAL  DEFAULT    9 shiftcode
    93: c100d700   256 OBJECT  LOCAL  DEFAULT    9 togglecode
    94: c100d800   256 OBJECT  LOCAL  DEFAULT    9 normalmap
    95: c100d900   256 OBJECT  LOCAL  DEFAUL
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值