Skip to content

Instantly share code, notes, and snippets.

@tony

tony/hi2.c

Created Jun 15, 2016
Embed
What would you like to do?
what's the story with AS_CFI_PSEUDO_OP tests
#include <stdio.h>
// run: clang -S hi2.c
int main(){
printf("HI");
}
.text
.file "hi2.c"
.globl main
.align 16, 0x90
.type main,@function
main: # @main
.cfi_startproc
# BB#0: # %entry
pushq %rbp
.Ltmp0:
.cfi_def_cfa_offset 16
.Ltmp1:
.cfi_offset %rbp, -16
movq %rsp, %rbp
.Ltmp2:
.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
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main
.cfi_endproc
.type .L.str,@object # @.str
.section .rodata.str1.1,"aMS",@progbits,1
.L.str:
.asciz "HI"
.size .L.str, 3
.ident "clang version 3.8.0 (tags/RELEASE_380/final)"
.section ".note.GNU-stack","",@progbits
// run: clang --target=armv8a--linux-gnueabi -c test_cfi_pseudo_op.c
// (assuming your llvm supports to the target, works!)
// run: clang -c test_cfi_pseudo_opt.c
// on most desktop, that won't compile, despite clang -S hi2.c producing cfi_startproc
// in the same architecture. confusing
int main() {
asm(".cfi_startproc\n\t.cfi_endproc");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment