Hi,
I wrote the following code for send() [of socket.h],
Code:
char buffer[4];
strcpy(buffer, "hi");
__asm__("sub $16,%%esp\n"
"movl %%ebx,(%%esp)\n"
"movl %%ecx,4(%%esp)\n"
"movl $3,8(%%esp)\n"
"movl $0,12(%%esp)\n"
"movl $102,%%eax\n" // Interrupt number
"movl $16,%%ebx\n" // defined in net.h to be SYS_SENDMSG
"movl %%esp,%%ecx\n"
"int $0x80\n"
"add $16,%%esp\n"
: "=a" (s)
:"b"(sockD), "c"(buffer)
);
It returns a negative number, and I ran a strace on it, which gave me the following error:
Code:
sendmsg(3, {msg_name(0)=ptrace: umoven: Input/output error
{...}, msg_iov(0)=[], msg_controllen=2000ptrace: umoven: Input/output error
, msg_control=0x3, msg_flags=0}, MSG_OOB|MSG_PEEK) = -1 EFAULT (Bad address)
So I guess I cannot pass a char buffer like this in asm. Can someone help me on how to pass it for this problem? The socket() call and connect() call before the send are going through fine.