Created
December 31, 2013 03:28
-
-
Save NalaGinrut/8192163 to your computer and use it in GitHub Desktop.
A case for %Pn in GCC inline ASM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat test.c | |
------------------------------------------------------------ | |
int main(int argc, char * argv[]) { | |
__asm__ ("call __foo_bar_%P0" : : "i"(42)); | |
return 0; | |
} | |
------------------------------------------------------------ | |
gcc -S test.c | |
cat test.s | |
------------------------------------------------------------- | |
.file "test.c" | |
.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 %edi, -4(%rbp) | |
movq %rsi, -16(%rbp) | |
#APP | |
# 3 "test.c" 1 | |
call __foo_bar_42 | |
# 0 "" 2 | |
#NO_APP | |
movl $0, %eax | |
popq %rbp | |
.cfi_def_cfa 7, 8 | |
ret | |
.cfi_endproc | |
.LFE0: | |
.size main, .-main | |
.ident "GCC: 4.8.1" | |
.section .note.GNU-stack,"",@progbits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment