本文介绍了在哪里可以找到在GCC汇编输出中调用的过程的汇编代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在玩GCC的Assembly Output开关:

I've been playing around with the assembly output switch for GCC:

gcc -S -c helloworld.c

helloworld.c :

#include <stdio.h>

int main(void){
    printf("Hello World!\n");
    return 0;
}

helloworld.s :

    .file   "helloworld.c"
    .section    .rodata
.LC0:
    .string "Hello World!"
    .text
    .globl  main
    .type   main, @function
main:
.LFB0:
    .cfi_startproc
    pushq   %rbp
    .cfi_def_cfa_offset 16
    .cfi_offset 6, -16
    movq    %rsp, %rbp
    .cfi_def_cfa_register 6
    movl    $.LC0, %edi
    call    puts
    movl    $0, %eax
    popq    %rbp
    .cfi_def_cfa 7, 8
    ret
    .cfi_endproc
.LFE0:
    .size   main, .-main
    .ident  "GCC: (Debian 4.7.2-5) 4.7.2"
    .section    .note.GNU-stack,"",@progbits

在输出的 helloworld.s 文件中,我注意到输出"Hello World!"的汇编命令.文字很简单:

In the output helloworld.s file, I notice that the assembly command to output the "Hello World!" text is simply:

call puts

但是, helloworld.s1 文件中没有 put 过程程序集代码.我在哪里可以查看此汇编代码?

However, the helloworld.s1 file doesn't have the puts procedure assembly code within it. Where would I be able to view this assembly code?

推荐答案

作为用户展开:

因此,我使用 objdump 来反汇编 libc.a ,并在< puts> 部分下找到了汇编代码: objdump-d/usr/lib/x86_64-linux-gnu/libc.a

So I used objdump to disassemble libc.a and found the assembly code under the <puts> section: objdump -d /usr/lib/x86_64-linux-gnu/libc.a

这篇关于在哪里可以找到在GCC汇编输出中调用的过程的汇编代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 11:21