代码之家  ›  专栏  ›  技术社区  ›  Abhishek Sagar

反汇编代码中对外部函数的引用

  •  0
  • Abhishek Sagar  · 技术社区  · 5 年前

    我在下面实现了一个简单的函数 add_caller.c

    extern int add(int a, int b);
    int
    main(int argc, char **argv){
    
        int a = 45;
        int b = 43;
        int c = add(45,43);
        return 0;
    }
    

    功能 add 在其他C文件中定义。 add_caller.o 使用命令的文件:

    gcc -g -c add_caller.c -o add_caller.o
    

    现在我反汇编add\u caller.o文件。我想看看反汇编代码如何将引用放到外部 添加

    vmx@vmx:~/Documents/NASMAssembly$ objdump -S --disassemble add_caller.o
    
    add_caller.o:     file format elf32-i386
    
    
    Disassembly of section .text:
    
    00000000 <main>:
    extern int add(int a, int b);
    
    int
    main(int argc, char **argv){
       0:   55                      push   %ebp
       1:   89 e5                   mov    %esp,%ebp
       3:   83 e4 f0                and    $0xfffffff0,%esp
       6:   83 ec 20                sub    $0x20,%esp
    
        int a = 45;
       9:   c7 44 24 14 2d 00 00    movl   $0x2d,0x14(%esp)
      10:   00
        int b = 43;
      11:   c7 44 24 18 2b 00 00    movl   $0x2b,0x18(%esp)
      18:   00
        int c = add(45,43);
      19:   c7 44 24 04 2b 00 00    movl   $0x2b,0x4(%esp)
      20:   00
      21:   c7 04 24 2d 00 00 00    movl   $0x2d,(%esp)
      28:   e8 fc ff ff ff          call   29 <main+0x29>
      2d:   89 44 24 1c             mov    %eax,0x1c(%esp)
        return 0;
      31:   b8 00 00 00 00          mov    $0x0,%eax
    }
      36:   c9                      leave
      37:   c3                      ret
    

    在上面的反汇编代码中,我完全理解它,除了我期待一些与 添加 29 <main+0x29> 平均线

    `28:   e8 fc ff ff ff          call   29 <main+0x29>`
    
    0 回复  |  直到 5 年前