OK. I know I can do that, but I would need to do it for every syscall since
every syscall can potentially clobber rbx.
Also, it is very strange that it is only one of the inlines the compiler
complains about. I have another inline (which uses rbx as input), but that
doesn't generate any error:
#define RdosUserGateEbxEdiEcxParRetEax(nr, rbx, rdi, rcx, res) do { \
register int _id asm("r14") = nr; \
register typeof(rbx) _rbx asm("rbx") = (rbx); \
register typeof(rdi) _rdi asm("rdi") = (rdi); \
register typeof(rcx) _rcx asm("r8") = (rcx); \
register int _size asm("r12") = (rcx); \
asm volatile ( \
"syscall\n\t" \
"jnc 1f\n\t" \
"xorq %%rax,%%rax\n\t" \
"1: \n\t" \
: "=a" (res) : "r" (_id), "r" (_rbx), "r" (_rdi), "r" (_rcx), "r"
(_size) : "rdx", "rsi" \
); \
} while(0);
inline int RdosWriteFile(int Handle, void *Buf, int Size)
{
int res;
RdosUserGateEbxEdiEcxParRetEax(usergate_read_file, Handle, Buf, Size,
res);
return res;
}
Why is not this inline causing the problem? Might that be because it will
not use rbx, but instead another register? OTOH, the code seems to work and
rbx is not assigned to PIC at the point of the call, but to the defined
parameter.
Regards,
Leif Ekblad
----- Original Message -----
From: "Jakub Jelinek" <ja...@redhat.com>
To: "Leif Ekblad" <l...@rdos.net>
Cc: "Uros Bizjak" <ubiz...@gmail.com>; "Richard Henderson" <r...@redhat.com>;
"Andi Kleen" <a...@firstfloor.org>; "Mike Frysinger" <vap...@gentoo.org>;
<gcc-patches@gcc.gnu.org>; <j...@suse.cz>; "H.J. Lu" <hjl.to...@gmail.com>
Sent: Friday, January 04, 2013 10:42 PM
Subject: Re: [RFC PATCH, i386]: Use %r15 for REAL_PIC_OFFSET_TABLE_REGNUM on
x86_64
On Fri, Jan 04, 2013 at 10:39:05PM +0100, Leif Ekblad wrote:
I just tried the patch, but it seems to produce some problems for
me. The other patch which used a 64-bit specific register (r15)
instead of rbx was easier to adapt to. The problem for me is that
syscalls might clobber higher-half of all 32-bit registers, and that
I cannot use the stack to preserve rbx in the call because of the
red-zone.
Of course you can use the stack, just subtract the red zone size (plus
whatever you need) from %rsp first, then save to stack, do syscall,
then restore from stack and finally increment %rsp back.
Jakub