I wanted to try and learn some assembly recently, and, having some knowledge of the C programming language, I thought that it'd be a good idea to look at the assembly equivalent of my C code.
main.c
:
int main()
{
return 2;
}
main.s
after gcc -S main.c -o main.s
:
.file "main.c"
.text
.def __main; .scl 2; .type 32; .endef
.globl main
.def main; .scl 2; .type 32; .endef
.seh_proc main
main:
pushq %rbp
.seh_pushreg %rbp
movq %rsp, %rbp
.seh_setframe %rbp, 0
subq $32, %rsp
.seh_stackalloc 32
.seh_endprologue
call __main
movl $2, %eax
addq $32, %rsp
popq %rbp
ret
.seh_endproc
.ident "GCC: (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0"
As you can see, the assembly equivalent of my C code is very verbose and it seems that a lot of it is unnecessary. Is there a way to make the assembly code neater, like a flag that removes the preamble or something similar?