[PATCH] [BZ #19363] Use INTERNAL_SYSCALL_TIMES for Linux times

H.J. Lu hjl.tools@gmail.com
Wed Dec 16 13:49:00 GMT 2015


On Tue, Dec 15, 2015 at 5:52 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Dec 14, 2015 at 9:25 PM, Dmitry V. Levin <ldv@altlinux.org> wrote:
>> On Mon, Dec 14, 2015 at 07:27:33PM -0800, H.J. Lu wrote:
>>> The Linux times function, which returns clock_t, is implemented with
>>> INTERNAL_SYSCALL.  Since INTERNAL_SYSCALL returns 32-bit integer and
>>> and clock_t is 64-bit on x32, there is mismatch on x32.  times is the
>>> only such function since there is lseek.S for x32.  This patch replaces
>>> INTERNAL_SYSCALL in Linux times.c with INTERNAL_SYSCALL_TIMES which is
>>> default to INTERNAL_SYSCALL and provides x32 times.c with proper
>>> INTERNAL_SYSCALL_TIMES.
>>>
>>> There is no code change on times for i686 nor x86-64.  For x32, before
>>> this patch, there are
>>>
>>> 0000000 <__times>:
>>>    0: b8 64 00 00 40          mov    $0x40000064,%eax
>>>    5: 0f 05                   syscall
>>>    7: 48 63 d0                movslq %eax,%rdx
>>>                                 ^^^^^^^^^^ Incorrect signed extension
>>>    a: 48 83 fa f2             cmp    $0xfffffffffffffff2,%rdx
>>>    e: 75 07                   jne    17 <__times+0x17>
>>>   10: 3d 00 f0 ff ff          cmp    $0xfffff000,%eax
>>>   15: 77 11                   ja     28 <__times+0x28>
>>>   17: 48 83 fa ff             cmp    $0xffffffffffffffff,%rdx
>>>   1b: b8 00 00 00 00          mov    $0x0,%eax
>>>   20: 48 0f 45 c2             cmovne %rdx,%rax
>>>   24: c3                      retq
>>>
>>> After this patch, there are
>>>
>>> 00000000 <__times>:
>>>    0: b8 64 00 00 40          mov    $0x40000064,%eax
>>>    5: 0f 05                   syscall
>>>    7: 48 83 f8 f2             cmp    $0xfffffffffffffff2,%rax
>>>    b: 75 07                   jne    14 <__times+0x14>
>>>    d: 3d 00 f0 ff ff          cmp    $0xfffff000,%eax
>>
>> Looks like there is another truncation remaining here that comes
>> from INTERNAL_SYSCALL_ERROR_P.
>>
>
> You are right.  Here is the updated patch with all INTERNAL_SYSCALL*
> macros replaced by INTERNAL_SYSCALL_TIMES* macros.
>
> There is no code change on i686 nor x86-64.  OK for master?

Here is the updated patch using REGISTERS_CLOBBERED_BY_SYSCALL.
OK for master?


-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Use-INTERNAL_SYSCALL_TIMES-macros-for-Linux-times.patch
Type: text/x-patch
Size: 5903 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20151216/c211bbf8/attachment.bin>


More information about the Libc-alpha mailing list