diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2012-09-04 19:08:16 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2012-09-04 19:08:16 +0000 |
commit | af1d6e1ef5d045fda635aed4b791869781761e1a (patch) | |
tree | 2a20fe84f615f923d776d2d0886c3018d965eef7 /lib/libc | |
parent | c081a94223a6ecd5ca49a29b347509f7d279f59f (diff) |
Add support for -fPIC
ok kettenis
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/arch/sparc/SYS.h | 10 | ||||
-rw-r--r-- | lib/libc/arch/sparc/gen/sigsetjmp.S | 28 | ||||
-rw-r--r-- | lib/libc/arch/sparc/sys/brk.S | 14 | ||||
-rw-r--r-- | lib/libc/arch/sparc/sys/cerror.S | 9 | ||||
-rw-r--r-- | lib/libc/arch/sparc/sys/sbrk.S | 8 |
5 files changed, 61 insertions, 8 deletions
diff --git a/lib/libc/arch/sparc/SYS.h b/lib/libc/arch/sparc/SYS.h index f4610e88c3f..d44e0797fe4 100644 --- a/lib/libc/arch/sparc/SYS.h +++ b/lib/libc/arch/sparc/SYS.h @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: SYS.h,v 1.14 2012/08/22 17:19:35 pascal Exp $ + * $OpenBSD: SYS.h,v 1.15 2012/09/04 19:08:13 deraadt Exp $ */ #include <machine/asm.h> @@ -49,9 +49,17 @@ * ERROR branches to cerror. */ #ifdef __PIC__ +#if __PIC__ == 1 #define ERROR() \ PIC_PROLOGUE(%g1,%g2); \ ld [%g1+_C_LABEL(__cerror)],%g2; jmp %g2; nop +#else /* __PIC__ == 2 */ +#define ERROR() \ + PIC_PROLOGUE(%g1,%g2); \ + sethi %hi(_C_LABEL(__cerror)),%g2; \ + or %g2,%lo(_C_LABEL(__cerror)),%g2; \ + ld [%g1+%g2],%g2; jmp %g2; nop +#endif #else #define ERROR() \ sethi %hi(_C_LABEL(__cerror)),%g1; \ diff --git a/lib/libc/arch/sparc/gen/sigsetjmp.S b/lib/libc/arch/sparc/gen/sigsetjmp.S index 76c1628844e..ad62e7e3d1b 100644 --- a/lib/libc/arch/sparc/gen/sigsetjmp.S +++ b/lib/libc/arch/sparc/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsetjmp.S,v 1.6 2012/08/22 17:19:35 pascal Exp $ */ +/* $OpenBSD: sigsetjmp.S,v 1.7 2012/09/04 19:08:15 deraadt Exp $ */ /* * Copyright (c) 1995 Paul Kranenburg * All rights reserved. @@ -38,10 +38,20 @@ ENTRY(sigsetjmp) PIC_PROLOGUE(%g1,%g2) ! %g1 = _GLOBAL_OFFSET_TABLE cmp %o1,0 st %o1,[%o0+40] ! jmpbuf[JBLEN] +#if __PIC__ == 1 bne,a 1f - ld [%g1+_C_LABEL(setjmp)], %g1 ! if (%o1 != 0) goto setjmp; + ld [%g1+_C_LABEL(setjmp)], %g1 ! if (%o1 != 0) goto setjmp; ld [%g1+_C_LABEL(_setjmp)], %g1 ! else goto _setjmp; 1: +#else /* __PIC__ == 2 */ + be 1f + sethi %hi(_C_LABEL(setjmp)), %g2 ! if (%o1 != 0) goto setjmp; + or %g2, %lo(_C_LABEL(setjmp)), %g2 + ba,a 2f +1: sethi %hi(_C_LABEL(_setjmp)), %g2 ! else goto _setjmp; + or %g2, %lo(_C_LABEL(_setjmp)), %g2 +2: ld [%g1 + %g2], %g1 +#endif jmp %g1 nop @@ -49,10 +59,20 @@ ENTRY(siglongjmp) PIC_PROLOGUE(%g1,%g2) ! %g1 = _GLOBAL_OFFSET_TABLE ld [%o0+40],%g2 ! jmpbuf[JBLEN] cmp %g2,0 +#if __PIC__ == 1 bne,a 1f - ld [%g1+_C_LABEL(longjmp)], %g1 ! if (%g2 != 0) goto longjmp; - ld [%g1+_C_LABEL(_longjmp)], %g1 ! else goto _longjmp; + ld [%g1+_C_LABEL(longjmp)], %g1 ! if (%g2 != 0) goto longjmp; + ld [%g1+_C_LABEL(_longjmp)], %g1 ! else goto _longjmp; 1: +#else /* __PIC__ == 2 */ + be 1f + sethi %hi(_C_LABEL(longjmp)), %g2 ! if (%g2 != 0) goto longjmp; + or %g2, %lo(_C_LABEL(longjmp)), %g2 + ba,a 2f +1: sethi %hi(_C_LABEL(_longjmp)), %g2 ! else goto _longjmp; + or %g2, %lo(_C_LABEL(_longjmp)), %g2 +2: ld [%g1 + %g2], %g1 +#endif jmp %g1 nop unimp 0 diff --git a/lib/libc/arch/sparc/sys/brk.S b/lib/libc/arch/sparc/sys/brk.S index 96dd6ef5cb0..408d6f41afc 100644 --- a/lib/libc/arch/sparc/sys/brk.S +++ b/lib/libc/arch/sparc/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.7 2012/08/22 17:19:35 pascal Exp $ */ +/* $OpenBSD: brk.S,v 1.8 2012/09/04 19:08:15 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -44,7 +44,13 @@ minbrk: .long _end ! lower brk limit; also for gmon code #ifdef __PIC__ ENTRY(brk) PIC_PROLOGUE(%o5,%o4) +#if __PIC__ == 1 ld [%o5 + minbrk], %o4 +#else /* __PIC__ == 2 */ + sethi %hi(minbrk), %o4 + or %o4, %lo(minbrk), %o4 + ld [%o5 + %o4], %o4 +#endif ld [%o4], %o1 ! %o1 = minbrk cmp %o1, %o0 ! if (minbrk > %o0) bgu,a 0f @@ -54,7 +60,13 @@ ENTRY(brk) mov SYS_break, %g1 t ST_SYSCALL bcc,a 1f +#if __PIC__ == 1 ld [%o5 + __curbrk], %o4 +#else /* __PIC__ == 2 */ + sethi %hi(__curbrk), %o4 + or %o4, %lo(__curbrk), %o4 + ld [%o5 + %o4], %o4 +#endif ERROR() 1: retl ! success, return 0 & record new break diff --git a/lib/libc/arch/sparc/sys/cerror.S b/lib/libc/arch/sparc/sys/cerror.S index 8287c0bf742..5b565a70ebd 100644 --- a/lib/libc/arch/sparc/sys/cerror.S +++ b/lib/libc/arch/sparc/sys/cerror.S @@ -1,4 +1,4 @@ -/* $OpenBSD: cerror.S,v 1.7 2012/08/22 17:19:35 pascal Exp $ */ +/* $OpenBSD: cerror.S,v 1.8 2012/09/04 19:08:15 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -41,8 +41,15 @@ WEAK_ALIAS(__cerror, ___cerror) FUNC(_C_LABEL(___cerror)) #ifdef __PIC__ +#if __PIC__ == 1 ld [%g1 + _C_LABEL(errno)], %g1 st %o0, [%g1] +#else /* __PIC__ == 2 */ + sethi %hi(_C_LABEL(errno)), %g2 + or %g2, %lo(_C_LABEL(errno)), %g2 + ld [%g1 + %g2], %g1 + st %o0, [%g1] +#endif #else sethi %hi(_C_LABEL(errno)), %g1 st %o0, [%g1 + %lo(_C_LABEL(errno))] diff --git a/lib/libc/arch/sparc/sys/sbrk.S b/lib/libc/arch/sparc/sys/sbrk.S index 90bd7717247..c5df545c51d 100644 --- a/lib/libc/arch/sparc/sys/sbrk.S +++ b/lib/libc/arch/sparc/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.6 2012/08/22 17:19:35 pascal Exp $ */ +/* $OpenBSD: sbrk.S,v 1.7 2012/09/04 19:08:15 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -44,7 +44,13 @@ __curbrk: .long _end ENTRY(sbrk) #ifdef __PIC__ PIC_PROLOGUE(%o5,%o4) +#if __PIC__ == 1 ld [%o5 + __curbrk], %o2 +#else /* __PIC__ == 2 */ + sethi %hi(__curbrk), %o2 + or %o2, %lo(__curbrk), %o2 + ld [%o5 + %o2], %o2 +#endif ld [%o2], %o3 ! %o3 = old break add %o3, %o0, %o4 ! %o4 = new break mov %o4, %o0 ! copy for syscall |