[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gas/13903] fails an external calling in "C" programm by inline asse
From: |
kdiman1982 at gmail dot com |
Subject: |
[Bug gas/13903] fails an external calling in "C" programm by inline assembler (Core i5 x86_64) |
Date: |
Mon, 26 Mar 2012 18:18:54 +0000 |
http://sourceware.org/bugzilla/show_bug.cgi?id=13903
kdiman <kdiman1982 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |x86_64-pc-linux-gnu
Host| |x86_64-pc-linux-gnu
--- Comment #1 from kdiman <kdiman1982 at gmail dot com> 2012-03-26 18:18:54
UTC ---
+++++++++++++++THIS CODE IS OK (32 bit)++++++++++++++++++
#include <stdio.h>
// g++ -m32 call32.c -o call32 && ./call32
int main(){
void *p_printf = (void *)&printf;
const char *str = "Hello from inline assembler is GNU Assembler\n";
printf("address of printf: %p\n", p_printf); // 0x8048374
asm ("movl %0, %%edx;" /* str into EDX */
"movl %1, %%ecx;" /* PRINTF into ECX */
"pushl %%edx;" /* str into stack */
"call *%%ecx;" /* call "printf" */
"popl %%edx;" /* remove arg from stack */
: /* output */
:"r"(str),"r"(p_printf) /* input */
:"%edx", "%ecx" /* clobbered register */
);
return 0;
}
+++++++++++++++THIS CODE IS OK (32 bit)++++++++++++++++++
+++++++++++++++FAILS CODE (64 bit)+++++++++++++++
#include <stdio.h>
// g++ -m64 call64.c -o call64 && ./call64
int main(){
void *p_printf = (void *)&printf;
const char *str = "Hello from inline assembler is GNU Assembler\n";
printf("address of printf: %p\n", p_printf); // 0x400490
asm ("movq %0, %%rdx;" /* str into RDX */
"movq %1, %%rcx;" /* PRINTF into RCX */
"pushq %%rdx;" /* str into stack */
"call *%%rcx;" /* call "printf" */
"popq %%rdx;" /* remove arg from stack */
: /* output */
:"r"(str),"r"(p_printf) /* input */
:"%rdx", "%rcx" /* clobbered register */
);
return 0;
}
+++++++++++++++FAILS CODE (64 bit)+++++++++++++++
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.