How to create 'raw' assembly code with gcc(Intel syntax)
05:16 05 Sep 2014

I want to create some assembly code with gcc. When I use gcc -masm=intel -S test.c I get assembly code full of .def and .cfi labels which I cannot assemble. Is there a way to create assembly code without this labels?

E.g.: A simple c code like:

int main() {
    return 0;
}

Compiles to:

.file   "test.c"
.intel_syntax noprefix
.def    ___main;    .scl    2;  .type   32; .endef
.text
.globl  _main
.def    _main;  .scl    2;  .type   32; .endef
_main:
LFB0:
.cfi_startproc
push    ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
mov ebp, esp
.cfi_def_cfa_register 5
and esp, -16
call    ___main
mov eax, 0
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
LFE0:

But what I want is something like:

_main:
    push    ebp
    mov ebp, esp
    and esp, -16
    call    ___main
    mov eax, 0
    leave
    ret

I hope there's a way to do this.

c gcc assembly intel-syntax