浏览代码

i386: store errno value before using __set_errno()

The __syscall_error() function stores the errno value in the edx register
before invoking the __set_errno() macro.  When using the pthread library
this macro calls thread_self() to determine the errno location, which might
clobber the edx register.  The errno value must be stored in a "real"
variable so the compiler can take care of saving/restoring it if necessary.

Signed-off-by: Ingo van Lil <inguin@gmx.de>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Ingo van Lil 16 年之前
父节点
当前提交
38265c7af5
共有 1 个文件被更改,包括 3 次插入4 次删除
  1. 3 4
      libc/sysdeps/linux/i386/__syscall_error.c

+ 3 - 4
libc/sysdeps/linux/i386/__syscall_error.c

@@ -28,9 +28,8 @@
 int __syscall_error(void) attribute_hidden;
 int __syscall_error(void)
 {
-	register int edx __asm__ ("%edx");
-	__asm__ ("mov %eax, %edx\n\t"
-		 "negl %edx");
-	__set_errno (edx);
+	register int eax __asm__ ("%eax");
+	int _errno = -eax;
+	__set_errno (_errno);
 	return -1;
 }