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: Update x86-64/sysdep.h


On Wed, May 23, 2012 at 12:22 AM, Andreas Jaeger <aj@suse.com> wrote:
>
>> But I'm not sure whether this change is really correct, have a look at
>> sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
>>
>> It contains:
>> L(pseudo_end):
>> ? ? ? ? add ? ? $0x8, %rsp
>> ? ? ? ? cfi_adjust_cfa_offset(-8)
>> ? ? ? ? ret
>>
>> A simple return in the error case would be wrong.
>>
>> Since both i386 and x86-64 do this, I would not make the change Roland
>> proposes unless we have reviewed all code that does cleanup after the
>> pseudo_end label.
>>
>> So, please do not put this in for now.
>
>
> I reviewed all usage of pseudo end in sysdeps, only the two sched_getcpu.S
> versions were wrong.
>
> HJ, please prepare a patch for both i386 and x86-64 to use ret instead of
> jmp and then send it again for review.
>

Here is the patch.  Tested on Linux/x32,i386,x86-64.  OK to install?

Thanks.


-- 
H.J.
---
	* sysdeps/unix/sysv/linux/i386/sysdep.h (SYSCALL_ERROR_HANDLER):
	Replace "jmp L(pseudo_end)" with "ret".
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (SYSCALL_ERROR_HANDLER):
	Likewise.

diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h
b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 6c4f778..17b816d 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -115,7 +115,7 @@
   negl %eax;								      \
   movl %eax, rtld_errno@GOTOFF(%ecx);					      \
   orl $-1, %eax;							      \
-  jmp L(pseudo_end);
+  ret;

 # elif defined _LIBC_REENTRANT

@@ -131,7 +131,7 @@
   negl %eax;								      \
   SYSCALL_ERROR_HANDLER_TLS_STORE (%eax, %ecx);				      \
   orl $-1, %eax;							      \
-  jmp L(pseudo_end);
+  ret;
 #  ifndef NO_TLS_DIRECT_SEG_REFS
 #   define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff)		      \
   movl src, %gs:(destoff)
@@ -149,7 +149,7 @@
   movl errno@GOT(%ecx), %ecx;						      \
   movl %eax, (%ecx);							      \
   orl $-1, %eax;							      \
-  jmp L(pseudo_end);
+  ret;
 # endif	/* _LIBC_REENTRANT */
 #endif	/* PIC */

diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index cde8652..1c3cbd6 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -136,7 +136,7 @@
 0:						\
   SYSCALL_SET_ERRNO;				\
   or $-1, %RAX_LP;				\
-  jmp L(pseudo_end);
+  ret;
 # endif	/* PIC */

 /* The Linux/x86-64 kernel expects the system call parameters in
-- 
1.7.6.5


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