diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2015-09-09 08:24:13 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2015-09-09 08:24:13 +0000 |
commit | f6180bfaa203662fa7c0ebc2e48f2a05761f61df (patch) | |
tree | 3976f133c0f40e1f502d0150cbce08861cb82e70 /lib/libc | |
parent | 3498210f4265efd6c30b524f09f673371b9e827d (diff) |
Backtrack a little bit and don't try to use the per-thread errno location if
r2 is zero. Some upcoming changes will probably change the offset at which
the errno pointer is stored, or might even store errno directly. Instead,
call __errno to get the location of errno. Make sure we go through the PLT
such that we call the version in libpthread if it is linked in. Set up r30
for this purpose. The ___cerrno function itself remains protected.
ok guenther@
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/arch/powerpc/sys/cerror.S | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/lib/libc/arch/powerpc/sys/cerror.S b/lib/libc/arch/powerpc/sys/cerror.S index 521ab9193b1..5dad24e0962 100644 --- a/lib/libc/arch/powerpc/sys/cerror.S +++ b/lib/libc/arch/powerpc/sys/cerror.S @@ -1,4 +1,4 @@ -/* $OpenBSD: cerror.S,v 1.11 2015/09/05 06:22:47 guenther Exp $ */ +/* $OpenBSD: cerror.S,v 1.12 2015/09/09 08:24:12 kettenis Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -35,30 +35,28 @@ WEAK_ALIAS(__cerror, ___cerror) .text .protected _ASM_LABEL(___cerror) ASENTRY(___cerror) - cmpwi 2, 0 - bne- .L_threaded - -#if defined (__PIC__) + stwu 1, -16(1) /* follow the SVR4 ABI */ mflr 3 /* error value is in r0, use r3 */ + stw 3, 20(1) + stw 31, 12(1) +#ifdef __PIC__ + stw 30, 8(1) bcl 20, 31, 1f -1: mflr 4 - addis 4, 4, _GLOBAL_OFFSET_TABLE_-1b@ha - addi 4, 4, _GLOBAL_OFFSET_TABLE_-1b@l - lwz 5,_C_LABEL(errno)@got(4) - mtlr 3 -#else - addis 5, 0, errno@H - ori 5, 5, errno@L +1: mflr 30 + addis 30, 30, _GLOBAL_OFFSET_TABLE_-1b@ha + addi 30, 30, _GLOBAL_OFFSET_TABLE_-1b@l #endif - b .L_do_store - -.L_threaded: - lwz 5, 4(2) - lwz 5, ERRNOPTR_OFFSET(5) - -.L_do_store: - stw 0, 0(5) - addi 3, 0, -1 - addi 4, 0, -1 + mr 31, 0 + bl PIC_PLT(__errno) + stw 31, 0(3) +#ifdef __PIC__ + lwz 30, 8(1) +#endif + lwz 31, 12(1) + lwz 0, 20(1) + mtlr 0 + addi 1, 1, 16 /* fllow the SVR4 ABI */ + li 3, -1 + li 4, -1 blr END(___cerror) |