简体   繁体   中英

Finding out type of assembly language generated by `gcc hello_world.c -S`

hello_world.c

#include <stdio.h>
int main()
{
    printf("Hello World\n");
    return 0;
}

Running gcc hello_world.c -S generates a hello_world.s file in assembly language.

hello_world.s

    .file   "hello_world.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: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3"
    .section    .note.GNU-stack,"",@progbits

Is there some way to find out in what type of assembly language the code was generated in (besides knowing the syntax of all assembly languages.)?

Reference for myself or anyone else who didn't know this:

To get your processor architecture run the following :

uname -p

It is the AT&T syntax for the GNU assembler of the target code's CPU by default. There are options to alter that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM