[Top] [All Lists]

Re: Is r25 saved across syscalls?

To: Rich Felker <>, Ralf Baechle <>
Subject: Re: Is r25 saved across syscalls?
From: "Maciej W. Rozycki" <>
Date: Tue, 11 Sep 2012 01:29:52 +0100 (BST)
In-reply-to: <>
List-archive: <>
List-help: <>
List-id: linux-mips <>
List-owner: <>
List-post: <>
List-software: Ecartis version 1.0.0
List-subscribe: <>
List-unsubscribe: <>
References: <> <> <>
User-agent: Alpine 2.00 (LFD 1167 2008-08-23)
On Mon, 10 Sep 2012, Rich Felker wrote:

> As for my problem, I can use r7 as the temp ("move $2,$7 ; syscall")
> for syscalls with 3 or fewer args, but for the 4-arg syscall, $7 is
> occupied by an argument, and I'd need to spill the syscall number to
> the stack to be able to restore it if $25 is not available...

 If performance or some other factors require you to avoid spilling the 
syscall number to the stack or other readily-accessible (e.g. GP-relative) 
memory and the number is not a constant you could load with LI, then you 
can always store it in a call-saved register, one of $s0-$s8, that are 
guaranteed by the syscall ABI to be preserved across.

 Relying on any call-clobbered registers, including $7 to be preserved 
across a syscall is risky, to say the least, as this is not guaranteed by 
the syscall ABI.  I do wonder however why we have these instructions to 
save/restore $25 in SAVE_SOME/RESTORE_SOME.  This dates back to 2.4 at the 
very least.

 Ralf, any insights?


<Prev in Thread] Current Thread [Next in Thread>