This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: PATCH: Update x86-64/sysdep.h
On Tue, May 22, 2012 at 1:11 AM, Andreas Jaeger <aj@suse.com> wrote:
> On Tuesday, May 22, 2012 00:12:09 H.J. Lu wrote:
>> On Mon, May 21, 2012 at 2:22 PM, Roland McGrath <roland@hack.frob.com>
> wrote:
>> >> Here is what I implemented. ?Since I need to refine
>> >> SYSCALL_ERROR_HANDLER anyway, I use it to define my own error
>> >> handler. ?Does it look OK?
>> >>
>> >> I noticed that SYSCALL_ERROR_HANDLER has
>> >>
>> >> ? xorl %edx, %edx; ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
>> >> ? subq %rax, %rdx; ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
>> >> ? movl %edx, (%rcx); ? ? ? ? ? ? ? ? ? ? ? ? ?\
>> >> ? orq $-1, %rax; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
>> >> ? jmp L(pseudo_end);
>> >>
>> >> Why not simply "neg %rax"?
>> >
>> > No idea. ?It appears it was done that way in the first version of this
>> > file, added by AJ.
>> >
>> >> Also why not just "ret" instead of jmp?
>
> I don't remember why I did this but see the same code in i386/sysdep.h. If
> we change the x86-64 code, I suggest to revisit the i386 one as well.
>
> This part looks fine to me.
I checked in this part. Here is the patch for i386. Tested on Linux/i386.
OK to install?
Thanks.
H.J.
--
* sysdeps/unix/sysv/linux/i386/sysdep.h (SYSCALL_ERROR_HANDLER):
Use "neg %eax".
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h
b/sysdeps/unix/sysv/linux/i386/sysdep.h
index e7d7103..6c4f778 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -112,9 +112,8 @@
# define SYSCALL_ERROR_HANDLER \
0:SETUP_PIC_REG(cx); \
addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
- xorl %edx, %edx; \
- subl %eax, %edx; \
- movl %edx, rtld_errno@GOTOFF(%ecx); \
+ negl %eax; \
+ movl %eax, rtld_errno@GOTOFF(%ecx); \
orl $-1, %eax; \
jmp L(pseudo_end);
@@ -129,9 +128,8 @@
0:SETUP_PIC_REG (cx); \
addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
movl SYSCALL_ERROR_ERRNO@GOTNTPOFF(%ecx), %ecx; \
- xorl %edx, %edx; \
- subl %eax, %edx; \
- SYSCALL_ERROR_HANDLER_TLS_STORE (%edx, %ecx); \
+ negl %eax; \
+ SYSCALL_ERROR_HANDLER_TLS_STORE (%eax, %ecx); \
orl $-1, %eax; \
jmp L(pseudo_end);
# ifndef NO_TLS_DIRECT_SEG_REFS
@@ -147,10 +145,9 @@
# define SYSCALL_ERROR_HANDLER \
0:SETUP_PIC_REG(cx); \
addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
- xorl %edx, %edx; \
- subl %eax, %edx; \
+ negl %eax; \
movl errno@GOT(%ecx), %ecx; \
- movl %edx, (%ecx); \
+ movl %eax, (%ecx); \
orl $-1, %eax; \
jmp L(pseudo_end);
# endif /* _LIBC_REENTRANT */
H.J.