Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22063

Why can't GCC compile assembly produced by CLANG?

$
0
0

So, I noticed that CLANG produces assembly that can't be compiled with GCC. For instance, for a simple "Hello world!" program in C, CLANG produces the following assembly:

    .text    .file   "hello.c"    .globl  main                    # -- Begin function main    .p2align    4, 0x90    .type   main,@functionmain:                                   # @main    .cfi_startproc# %bb.0:    pushq   %rbp    .cfi_def_cfa_offset 16    .cfi_offset %rbp, -16    movq    %rsp, %rbp    .cfi_def_cfa_register %rbp    subq    $16, %rsp    movabsq $.L.str, %rdi    movb    $0, %al    callq   printf    xorl    %ecx, %ecx    movl    %eax, -4(%rbp)          # 4-byte Spill    movl    %ecx, %eax    addq    $16, %rsp    popq    %rbp    .cfi_def_cfa %rsp, 8    retq.Lfunc_end0:    .size   main, .Lfunc_end0-main    .cfi_endproc                                        # -- End function    .type   .L.str,@object          # @.str    .section    .rodata.str1.1,"aMS",@progbits,1.L.str:    .asciz  "Hello world!\n"    .size   .L.str, 14    .ident  "clang version 10.0.0 "    .section    ".note.GNU-stack","",@progbits    .addrsig    .addrsig_sym printf

But, when I attempt to compile that Assembly with gcc hello.s, I get:

hello.s: Assembler messages:hello.s:37: Error: unknown pseudo-op: `.addrsig'hello.s:38: Error: unknown pseudo-op: `.addrsig_sym'

But both GCC and CLANG use the same assembler, the GNU Assembler. So, what's actually going on here?


Viewing all articles
Browse latest Browse all 22063

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>