[PATCH 2/2] Properly support lseek for n32 and x32

H.J. Lu hjl.tools at gmail.com
Sun Apr 15 20:20:02 UTC 2012


On Sun, Apr 15, 2012 at 12:54 PM, Denys Vlasenko <dvlasenk at redhat.com> wrote:
> On 04/15/2012 08:21 PM, H.J. Lu wrote:
>>
>> Hi,
>>
>> Linux kernel v3.4 adds x32 support.  Both x32 and n32 use 64bit offset
>> for lseek parameter and return value.  We need u_lrval to handle it
>> properly.  Also we shouldn't check HAVE_LONG_LONG_OFF_T for n32 lseek.
>
>
> Please explain further. Not many people are familiar with MIPS...
>
> Do syscalls on MIPS-n32 return 64-bit values even to 32-bit userspace?
> How userspace is supposed to read that? Is 32-bit MIPS code
> able to read 64-registers, or what?

For both n32 and x32, only one system call, lseek, returns 64bit value.
>From what I read in n32 port of glibc, lseek return value is stored in 64bit
register r2.  You can read register r2 to get 64bit return value.

>> This patch fixes it properly and prepares lseek for x32.
>
>
> Can you explain a bit further?
> On x86, every syscall returns one long-sized (i.e., register-sized)
> value in EAX/RAX. NO syscalls ever returned wider data.
> If there was a need to do that, it was returned by reference.
>
> Or it used to - did anything change? Or am I wrong?
>
> How x32 lseek returns its value? In register pair?
> Are there other such syscalls?

X32 is the 32bit ABI for x86-64:

https://sites.google.com/site/x32abi/

Its system call can return 64bit value in RAX.  On x32, lseek is
the only system call which returns 64bit value.

-- 
H.J.




More information about the Strace-devel mailing list