【问题标题】:entry0 meaning in radare2雷达2中的entry0含义
【发布时间】:2017-08-09 23:38:36
【问题描述】:

我是二进制分析的新手。我正在尝试分析我通过 gcc 从我的 C 代码编译的一个简单程序。

我按照以下步骤操作:
1。 aaa
2。 afl

我得到了这个输出:

0x00000608    3 23           sym._init
0x00000630    1 8            sym.imp.puts
0x00000638    1 8            sym.imp._IO_getc
0x00000640    1 8            sym.imp.__printf_chk
0x00000648    1 8            sym.imp.__cxa_finalize
0x00000650    4 77           sym.main
0x000006a0    1 43           entry0
0x000006d0    4 50   -> 44   sym.deregister_tm_clones
0x00000710    4 66   -> 57   sym.register_tm_clones
0x00000760    5 50           sym.__do_global_dtors_aux
0x000007a0    4 48   -> 42   sym.frame_dummy
0x000007d0    1 24           sym.smth
0x000007f0    4 101          sym.__libc_csu_init
0x00000860    1 2            sym.__libc_csu_fini
0x00000864    1 9            sym._fini

我可以得到 main 是程序的主要起点,但我担心 entry0 是什么。显然从我所看到的不是一个符号。我尝试运行ag @ entry0ag @ main,我看到的图表非常不同。通过查看反汇编代码,我看到了 entry0:

我想这可能是一种 ELF 模板函数,用于加载二进制文件并从 main 运行它。 entry0 到底是什么?

抱歉,拖了这么久。提前致谢。

【问题讨论】:

    标签: reverse-engineering binaryfiles


    【解决方案1】:

    您应该在 https://reverseengineering.stackexchange.com/ 上发布 RE 问题。

    entry0_start 符号的别名,对应于_start 函数。

    • _start 的内存地址是程序入口点,控制从加载程序传递给程序。
    • _start 函数源自名为 crt1.o 的可重定位 ELF 对象文件,该文件链接到需要 C 运行时环境的二进制文件中。
    $ objdump -dj .text /usr/lib/x86_64-linux-gnu/crt1.o 
    
    /usr/lib/x86_64-linux-gnu/crt1.o:     file format elf64-x86-64
    
    
    Disassembly of section .text:
    
    0000000000000000 <_start>:
       0: 31 ed                   xor    %ebp,%ebp
       2: 49 89 d1                mov    %rdx,%r9
       5: 5e                      pop    %rsi
       6: 48 89 e2                mov    %rsp,%rdx
       9: 48 83 e4 f0             and    $0xfffffffffffffff0,%rsp
       d: 50                      push   %rax
       e: 54                      push   %rsp
       f: 49 c7 c0 00 00 00 00    mov    $0x0,%r8
      16: 48 c7 c1 00 00 00 00    mov    $0x0,%rcx
      1d: 48 c7 c7 00 00 00 00    mov    $0x0,%rdi
      24: e8 00 00 00 00          callq  29 <_start+0x29>
      29: f4                      hlt
    

    /bin/cat为例:

    $ readelf -h /bin/cat
    ELF Header:
      Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
      Class:                             ELF64
      Data:                              2's complement, little endian
      Version:                           1 (current)
      OS/ABI:                            UNIX - System V
      ABI Version:                       0
      Type:                              EXEC (Executable file)
      Machine:                           Advanced Micro Devices X86-64
      Version:                           0x1
      Entry point address:               0x402602                      <-----
      Start of program headers:          64 (bytes into file)
      Start of section headers:          46112 (bytes into file)
      Flags:                             0x0
      Size of this header:               64 (bytes)
      Size of program headers:           56 (bytes)
      Number of program headers:         9
      Size of section headers:           64 (bytes)
      Number of section headers:         28
      Section header string table index: 27
    

    入口点的内存地址是0x402602

      402602:       31 ed                   xor    %ebp,%ebp
      402604:       49 89 d1                mov    %rdx,%r9
      402607:       5e                      pop    %rsi
      402608:       48 89 e2                mov    %rsp,%rdx
      40260b:       48 83 e4 f0             and    $0xfffffffffffffff0,%rsp
      40260f:       50                      push   %rax
      402610:       54                      push   %rsp
      402611:       49 c7 c0 60 89 40 00    mov    $0x408960,%r8
      402618:       48 c7 c1 f0 88 40 00    mov    $0x4088f0,%rcx
      40261f:       48 c7 c7 40 1a 40 00    mov    $0x401a40,%rdi
      402626:       e8 d5 f1 ff ff          callq  401800 <__libc_start_main@plt>
      40262b:       f4                      hlt 
    

    推荐阅读:

    Linux x86 Program Start Up or - How the heck do we get to main()?

    What is the use of _start() in C?

    Generic System V ABI

    【讨论】:

    • 这是一个很棒的介绍,链接也很棒。也是的,我下次会在 RE 上发帖。谢谢!
    猜你喜欢
    • 2020-10-03
    • 2020-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多