Skip to content

Commit

Permalink
Rework sparc PIC macros so crt{i,n}.S can use them too.
Browse files Browse the repository at this point in the history
	* sysdeps/unix/sparc/sysdep.h (SPARC_PIC_THUNK): New macro.
	(SETUP_PIC_REG): Use SPARC_PIC_THUNK and don't save and restore
	%o7 across the call.
	(SETUP_PIC_REG_LEAF): Do %o7 save/restore in this new macro
	instead.
	* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h: Use
	SETUP_PIC_REG_LEAF.
	* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h: Likewise.
	* sysdeps/sparc/crti.S: Use SETUP_PIC_REG.
	* sysdeps/sparc/crtn.S: Likewise.
  • Loading branch information
David S. Miller committed Feb 19, 2012
1 parent 2bcc53a commit dd54084
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 26 deletions.
13 changes: 13 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
2012-02-18 David S. Miller <davem@davemloft.net>

* sysdeps/unix/sparc/sysdep.h (SPARC_PIC_THUNK): New macro.
(SETUP_PIC_REG): Use SPARC_PIC_THUNK and don't save and restore
%o7 across the call.
(SETUP_PIC_REG_LEAF): Do %o7 save/restore in this new macro
instead.
* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h: Use
SETUP_PIC_REG_LEAF.
* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h: Likewise.
* sysdeps/sparc/crti.S: Use SETUP_PIC_REG.
* sysdeps/sparc/crtn.S: Likewise.

2012-02-17 Ulrich Drepper <drepper@gmail.com>

* aout/Makefile: Remove.
Expand Down
13 changes: 1 addition & 12 deletions sysdeps/sparc/crti.S
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@
_init:
save %sp, -STACKFRAME_SIZE, %sp
#if PREINIT_FUNCTION_WEAK
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7
call __sparc_get_pc_thunk.l7
add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7
SETUP_PIC_REG(l7)
sethi %hi(PREINIT_FUNCTION), %g1
or %g1, %lo(PREINIT_FUNCTION), %g1
GOT_LOAD [%l7 + %g1], %g1
Expand All @@ -93,12 +91,3 @@ _init:
.type _fini, @function
_fini:
save %sp, -STACKFRAME_SIZE, %sp

.section .text.__sparc_get_pc_thunk.l7,"axG",@progbits,__sparc_get_pc_thunk.l7,comdat
.p2align 2
.weak __sparc_get_pc_thunk.l7
.hidden __sparc_get_pc_thunk.l7
.type __sparc_get_pc_thunk.l7, #function
__sparc_get_pc_thunk.l7:
jmp %o7 + 8
add %o7, %l7, %l7
15 changes: 11 additions & 4 deletions sysdeps/unix/sparc/sysdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
C name space. Make sure we use an innocuous name. */
#define syscall_error C_SYMBOL_NAME(__syscall_error)

#ifdef PIC
#define SETUP_PIC_REG(reg, tmp) \
#define SPARC_PIC_THUNK(reg) \
.ifndef __sparc_get_pc_thunk.reg; \
.section .text.__sparc_get_pc_thunk.reg,"axG",@progbits,__sparc_get_pc_thunk.reg,comdat; \
.align 32; \
Expand All @@ -38,13 +37,21 @@ __sparc_get_pc_thunk.reg: \
jmp %o7 + 8; \
add %o7, %reg, %##reg; \
.previous; \
.endif; \
.endif;

#define SETUP_PIC_REG(reg) \
SPARC_PIC_THUNK(reg) \
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %##reg; \
call __sparc_get_pc_thunk.reg; \
or %##reg, %lo(_GLOBAL_OFFSET_TABLE_+4), %##reg;

#define SETUP_PIC_REG_LEAF(reg, tmp) \
SPARC_PIC_THUNK(reg) \
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %##reg; \
mov %o7, %##tmp; \
call __sparc_get_pc_thunk.reg; \
or %##reg, %lo(_GLOBAL_OFFSET_TABLE_+4), %##reg; \
mov %##tmp, %o7;
#endif

#define ENTRY(name) \
.global C_SYMBOL_NAME(name); \
Expand Down
10 changes: 5 additions & 5 deletions sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 1997, 2002, 2003, 2004, 2006, 2008, 2011
/* Copyright (C) 1997, 2002, 2003, 2004, 2006, 2008, 2011, 2012
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Miguel de Icaza <miguel@gnu.ai.mit.edu>, January 1997.
Expand Down Expand Up @@ -89,7 +89,7 @@ ENTRY(name); \
#else
# if RTLD_PRIVATE_ERRNO
# define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG(o2,g1) \
0: SETUP_PIC_REG_LEAF(o2,g1) \
sethi %hi(rtld_errno), %g1; \
or %g1, %lo(rtld_errno), %g1; \
ld [%o2 + %g1], %g1; \
Expand All @@ -103,8 +103,8 @@ ENTRY(name); \
# else
# define SYSCALL_ERROR_ERRNO errno
# endif
# define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG(o2,g1) \
# define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG_LEAF(o2,g1) \
sethi %tie_hi22(SYSCALL_ERROR_ERRNO), %g1; \
add %g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1; \
ld [%o2 + %g1], %g1, %tie_ld(SYSCALL_ERROR_ERRNO); \
Expand All @@ -113,7 +113,7 @@ ENTRY(name); \
mov -1, %o0;
# else
# define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG(o2,g1) \
0: SETUP_PIC_REG_LEAF(o2,g1) \
sethi %hi(errno), %g1; \
or %g1, %lo(errno), %g1; \
ld [%o2 + %g1], %g1; \
Expand Down
10 changes: 5 additions & 5 deletions sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 1997, 2000, 2002, 2003, 2004, 2006, 2008, 2011
/* Copyright (C) 1997, 2000, 2002, 2003, 2004, 2006, 2008, 2011, 2012
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997.
Expand Down Expand Up @@ -96,7 +96,7 @@ ENTRY(name); \
#else
# if RTLD_PRIVATE_ERRNO
# define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG(o2,g1) \
0: SETUP_PIC_REG_LEAF(o2,g1) \
sethi %hi(rtld_errno), %g1; \
or %g1, %lo(rtld_errno), %g1; \
ldx [%o2 + %g1], %g1; \
Expand All @@ -110,8 +110,8 @@ ENTRY(name); \
# else
# define SYSCALL_ERROR_ERRNO errno
# endif
# define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG(o2,g1) \
# define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG_LEAF(o2,g1) \
sethi %tie_hi22(SYSCALL_ERROR_ERRNO), %g1; \
add %g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1; \
ldx [%o2 + %g1], %g1, %tie_ldx(SYSCALL_ERROR_ERRNO);\
Expand All @@ -120,7 +120,7 @@ ENTRY(name); \
mov -1, %o0;
# else
# define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG(o2,g1) \
0: SETUP_PIC_REG_LEAF(o2,g1) \
sethi %hi(errno), %g1; \
or %g1, %lo(errno), %g1; \
ldx [%o2 + %g1], %g1; \
Expand Down

0 comments on commit dd54084

Please sign in to comment.