This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix x86_64/sched_getcpu.S error code


n Wed, May 23, 2012 at 12:19 AM, Andreas Jaeger <aj@suse.com> wrote:
>
> HJ, we need the same fix for the x32 version of the file - could you test
> and commit, please?
>
> Thanks,
> Andreas
>
>
> On 05/22/2012 10:08 PM, Andreas Jaeger wrote:
>>
>>
>> As discussed with Roland (see sysdep.h) the function is wrong in the
>> static case.
>>
>> Tested on Linux/x86-64.
>>
>> Ok to commit?
>> Andreas
>>
>> 2012-05-22 ?Andreas Jaeger<aj@suse.de>
>>
>> ? ? ? ?* sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S: Rearrange code so
>> ? ? ? ?that pseudo_end is just ret and the stack pointer is correct also
>> ? ? ? ?for static library in error case.
This is the patch I tested and committed.

Thanks.

-- 
H.J.
---
	* sysdeps/unix/sysv/linux/x86_64/x32/sched_getcpu.S: Rearrange
	code so that pseudo_end is just ret and the stack pointer is
	correct also for static library in error case.

diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/sched_getcpu.S
b/sysdeps/unix/sysv/linux/x86_64/x32/sched_getcpu.S
index f3ba9f1..789552e 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/sched_getcpu.S
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/sched_getcpu.S
@@ -33,14 +33,18 @@ ENTRY (sched_getcpu)

 	call	__getcpu

+	/* Local variable is result if the call is successful.  */
+	mov	(%rsp), %edx
+	/* Restore stack pointer before we might jump to
+	   SYSCALL_ERROR_LABEL which returns to the caller.  */
+	add	$0x8, %esp
+	cfi_adjust_cfa_offset(-8)
+
 	cmp	$-4095, %eax
 	jae	SYSCALL_ERROR_LABEL

-	mov	(%rsp), %eax
-
+	mov	%edx, %eax
 L(pseudo_end):
-	add	$0x8, %esp
-	cfi_adjust_cfa_offset(-8)
 	ret
 PSEUDO_END(sched_getcpu)
 #endif
-- 
1.7.6.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]