Don't write errno to the GOT, but properly follow the indirection
authorSimon Schubert <corecode@dragonflybsd.org>
Sat, 19 Jan 2008 13:30:51 +0000 (13:30 +0000)
committerSimon Schubert <corecode@dragonflybsd.org>
Sat, 19 Jan 2008 13:30:51 +0000 (13:30 +0000)
This only applies to PIC objects without TLS support, i.e. rtld.
This was broken since long but didn't get caught, because rtld is the
only consumer of this configuration and doesn't deal with errno a lot.

Noticed-by: godlkwrth on IRC while porting WINE
lib/libc/i386/sys/cerror.S

index 97e6720..ec892bd 100644 (file)
@@ -34,7 +34,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/lib/libc/i386/sys/cerror.S,v 1.10 1999/08/27 23:59:38 peter Exp $
- * $DragonFly: src/lib/libc/i386/sys/cerror.S,v 1.5 2005/05/11 19:46:54 dillon Exp $
+ * $DragonFly: src/lib/libc/i386/sys/cerror.S,v 1.6 2008/01/19 13:30:51 corecode Exp $
  */
 
 #include "SYS.h"
@@ -47,11 +47,11 @@ HIDENAME(cerror):
 #ifdef PIC
        /* The caller must execute the PIC prologue before jumping to cerror. */
 #ifdef __thread
-       movl    %eax, PIC_GOT(CNAME(errno))
+       movl    PIC_GOT(CNAME(errno)),%edx
 #else
        movl    %gs:12,%edx
-       movl    %eax,(%edx)
 #endif
+       movl    %eax,(%edx)
        PIC_EPILOGUE
 #else
 
@@ -73,7 +73,8 @@ HIDENAME(cerror):
 #ifdef PIC
        /* The caller must execute the PIC prologue before jumping to cerror. */
 #ifdef __thread
-       movl    %eax, PIC_GOT(CNAME(errno))
+       movl    PIC_GOT(CNAME(errno)),%ecx
+       movl    %eax,(%ecx)
 #else
        pushl   %eax
        leal    errno@TLSGD(,%ebx,1), %eax