Use sparc GOTDATA relocations whenever possible.

* sysdeps/sparc/crti.S: Try to use GOTDATA relocs.
	* sysdeps/sparc/sparc32/dl-machine.h (RTLD_START): Likewise.
	* sysdeps/sparc/sparc32/elf/start.S: Likewise.
	* sysdeps/sparc/sparc64/dl-machine.h (RTLD_START): Likewise.
	* sysdeps/sparc/sparc64/elf/start.S: Likewise.
	* sysdeps/sparc/sparc64/multiarch/memcpy.S: Likewise.
	* sysdeps/sparc/sparc64/multiarch/memset.S: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/____longjmp_chk.S: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
	(SYSCALL_ERROR_HANDLER): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/____longjmp_chk.S: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/brk.S: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
	(SYSCALL_ERROR_HANDLER): Likewise.
This commit is contained in:
David S. Miller 2012-02-21 15:42:42 -08:00
parent c80098a9a0
commit 3d2b3019e0
13 changed files with 202 additions and 96 deletions

View File

@ -1,5 +1,20 @@
2012-02-20 David S. Miller <davem@davemloft.net> 2012-02-20 David S. Miller <davem@davemloft.net>
* sysdeps/sparc/crti.S: Try to use GOTDATA relocs.
* sysdeps/sparc/sparc32/dl-machine.h (RTLD_START): Likewise.
* sysdeps/sparc/sparc32/elf/start.S: Likewise.
* sysdeps/sparc/sparc64/dl-machine.h (RTLD_START): Likewise.
* sysdeps/sparc/sparc64/elf/start.S: Likewise.
* sysdeps/sparc/sparc64/multiarch/memcpy.S: Likewise.
* sysdeps/sparc/sparc64/multiarch/memset.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/____longjmp_chk.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
(SYSCALL_ERROR_HANDLER): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/____longjmp_chk.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/brk.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
(SYSCALL_ERROR_HANDLER): Likewise.
* config.h.in (HAVE_BINUTILS_GOTDATA): New. * config.h.in (HAVE_BINUTILS_GOTDATA): New.
(HAVE_GCC_GOTDATA): New. (HAVE_GCC_GOTDATA): New.
* sysdeps/sparc/elf/configure.in: Test for GOTDATA * sysdeps/sparc/elf/configure.in: Test for GOTDATA

View File

@ -71,9 +71,15 @@ _init:
save %sp, -STACKFRAME_SIZE, %sp save %sp, -STACKFRAME_SIZE, %sp
#if PREINIT_FUNCTION_WEAK #if PREINIT_FUNCTION_WEAK
SETUP_PIC_REG(l7) SETUP_PIC_REG(l7)
#ifdef HAVE_BINUTILS_GOTDATA
sethi %gdop_hix22(PREINIT_FUNCTION), %g1
xor %g1, %gdop_lox10(PREINIT_FUNCTION), %g1
GOT_LOAD [%l7 + %g1], %g1, %gdop(PREINIT_FUNCTION)
#else
sethi %hi(PREINIT_FUNCTION), %g1 sethi %hi(PREINIT_FUNCTION), %g1
or %g1, %lo(PREINIT_FUNCTION), %g1 or %g1, %lo(PREINIT_FUNCTION), %g1
GOT_LOAD [%l7 + %g1], %g1 GOT_LOAD [%l7 + %g1], %g1
#endif
cmp %g1, 0 cmp %g1, 0
be 1f be 1f
nop nop

View File

@ -216,6 +216,18 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
The C function `_dl_start' is the real entry point; The C function `_dl_start' is the real entry point;
its return value is the user program's entry point. */ its return value is the user program's entry point. */
#ifdef HAVE_BINUTILS_GOTDATA
#define RTLD_GOT_ADDRESS(pic_reg, reg, symbol) \
"sethi %gdop_hix22(" #symbol "), " #reg "\n\t" \
"xor " #reg ", %gdop_lox10(" #symbol "), " #reg "\n\t" \
"ld [" #pic_reg " + " #reg "], " #reg ", %gdop(" #symbol ")"
#else
#define RTLD_GOT_ADDRESS(pic_reg, reg, symbol) \
"sethi %hi(" #symbol "), " #reg "\n\t" \
"or " #reg ", %lo(" #symbol "), " #reg "\n\t" \
"ld [" #pic_reg " + " #reg "], " #reg
#endif
#define RTLD_START __asm__ ("\ #define RTLD_START __asm__ ("\
.text\n\ .text\n\
.globl _start\n\ .globl _start\n\
@ -240,17 +252,13 @@ _dl_start_user:\n\
mov %o0, %l0\n\ mov %o0, %l0\n\
/* See if we were run as a command with the executable file name as an\n\ /* See if we were run as a command with the executable file name as an\n\
extra leading argument. If so, adjust the contents of the stack. */\n\ extra leading argument. If so, adjust the contents of the stack. */\n\
sethi %hi(_dl_skip_args), %g2\n\ " RTLD_GOT_ADDRESS(%l7, %g2, _dl_skip_args) "\n\
or %g2, %lo(_dl_skip_args), %g2\n\ ld [%g2], %i0\n\
ld [%l7+%g2], %i0\n\
ld [%i0], %i0\n\
tst %i0\n\ tst %i0\n\
beq 3f\n\ beq 3f\n\
ld [%sp+22*4], %i5 /* load argc */\n\ ld [%sp+22*4], %i5 /* load argc */\n\
/* Find out how far to shift. */\n\ /* Find out how far to shift. */\n\
sethi %hi(_dl_argv), %l3\n\ " RTLD_GOT_ADDRESS(%l7, %l3, _dl_argv) "\n\
or %l3, %lo(_dl_argv), %l3\n\
ld [%l7+%l3], %l3\n\
sub %i5, %i0, %i5\n\ sub %i5, %i0, %i5\n\
ld [%l3], %l4\n\ ld [%l3], %l4\n\
sll %i0, 2, %i2\n\ sll %i0, 2, %i2\n\
@ -283,20 +291,16 @@ _dl_start_user:\n\
bne 23b\n\ bne 23b\n\
add %i1, 8, %i1\n\ add %i1, 8, %i1\n\
/* %o0 = _dl_loaded, %o1 = argc, %o2 = argv, %o3 = envp. */\n\ /* %o0 = _dl_loaded, %o1 = argc, %o2 = argv, %o3 = envp. */\n\
3: sethi %hi(_rtld_local), %o0\n\ 3: " RTLD_GOT_ADDRESS(%l7, %o0, _rtld_local) "\n\
add %sp, 23*4, %o2\n\ add %sp, 23*4, %o2\n\
orcc %o0, %lo(_rtld_local), %o0\n\
sll %i5, 2, %o3\n\ sll %i5, 2, %o3\n\
ld [%l7+%o0], %o0\n\
add %o3, 4, %o3\n\ add %o3, 4, %o3\n\
mov %i5, %o1\n\ mov %i5, %o1\n\
add %o2, %o3, %o3\n\ add %o2, %o3, %o3\n\
call _dl_init_internal\n\ call _dl_init_internal\n\
ld [%o0], %o0\n\ ld [%o0], %o0\n\
/* Pass our finalizer function to the user in %g1. */\n\ /* Pass our finalizer function to the user in %g1. */\n\
sethi %hi(_dl_fini), %g1\n\ " RTLD_GOT_ADDRESS(%l7, %g1, _dl_fini) "\n\
or %g1, %lo(_dl_fini), %g1\n\
ld [%l7+%g1], %g1\n\
/* Jump to the user's entry point and deallocate the extra stack we got. */\n\ /* Jump to the user's entry point and deallocate the extra stack we got. */\n\
jmp %l0\n\ jmp %l0\n\
add %sp, 6*4, %sp\n\ add %sp, 6*4, %sp\n\

View File

@ -40,18 +40,11 @@
.section ".text" .section ".text"
.align 4 .align 4
#ifdef SHARED
.LLGETPC0:
retl
add %o7, %l7, %l7
#endif
.global _start .global _start
.type _start,#function .type _start,#function
_start: _start:
#ifdef SHARED #ifdef SHARED
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7 SETUP_PIC_REG(l7)
call .LLGETPC0
add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7
#endif #endif
/* Terminate the stack frame, and reserve space for functions to /* Terminate the stack frame, and reserve space for functions to
@ -65,16 +58,35 @@ _start:
add %sp, 23*4, %o2 add %sp, 23*4, %o2
/* Load the addresses of the user entry points. */ /* Load the addresses of the user entry points. */
#ifndef SHARED
sethi %hi(main), %o0
sethi %hi(__libc_csu_init), %o3
sethi %hi(__libc_csu_fini), %o4
or %o0, %lo(main), %o0
or %o3, %lo(__libc_csu_init), %o3
or %o4, %lo(__libc_csu_fini), %o4
#else
#ifdef HAVE_BINUTILS_GOTDATA
sethi %gdop_hix22(main), %o0
sethi %gdop_hix22(__libc_csu_init), %o3
sethi %gdop_hix22(__libc_csu_fini), %o4
xor %o0, %gdop_lox10(main), %o0
xor %o3, %gdop_lox10(__libc_csu_init), %o3
xor %o4, %gdop_lox10(__libc_csu_fini), %o4
ld [%l7 + %o0], %o0, %gdop(main)
ld [%l7 + %o3], %o3, %gdop(__libc_csu_init)
ld [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
#else
sethi %hi(main), %o0 sethi %hi(main), %o0
sethi %hi(__libc_csu_init), %o3 sethi %hi(__libc_csu_init), %o3
sethi %hi(__libc_csu_fini), %o4 sethi %hi(__libc_csu_fini), %o4
or %o0, %lo(main), %o0 or %o0, %lo(main), %o0
or %o3, %lo(__libc_csu_init), %o3 or %o3, %lo(__libc_csu_init), %o3
or %o4, %lo(__libc_csu_fini), %o4 or %o4, %lo(__libc_csu_fini), %o4
#ifdef SHARED
ld [%l7 + %o0], %o0 ld [%l7 + %o0], %o0
ld [%l7 + %o3], %o3 ld [%l7 + %o3], %o3
ld [%l7 + %o4], %o4 ld [%l7 + %o4], %o4
#endif
#endif #endif
/* When starting a binary via the dynamic linker, %g1 contains the /* When starting a binary via the dynamic linker, %g1 contains the

View File

@ -264,6 +264,18 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
The C function `_dl_start' is the real entry point; The C function `_dl_start' is the real entry point;
its return value is the user program's entry point. */ its return value is the user program's entry point. */
#ifdef HAVE_BINUTILS_GOTDATA
#define RTLD_GOT_ADDRESS(pic_reg, reg, symbol) \
"sethi %gdop_hix22(" #symbol "), " #reg "\n\t" \
"xor " #reg ", %gdop_lox10(" #symbol "), " #reg "\n\t" \
"ldx [" #pic_reg " + " #reg "], " #reg ", %gdop(" #symbol ")\n"
#else
#define RTLD_GOT_ADDRESS(pic_reg, reg, symbol) \
"sethi %hi(" #symbol "), " #reg "\n\t" \
"or " #reg ", %lo(" #symbol "), " #reg "\n\t" \
"ldx [" #pic_reg " + " #reg "], " #reg "\n"
#endif
#define __S1(x) #x #define __S1(x) #x
#define __S(x) __S1(x) #define __S(x) __S1(x)
@ -288,24 +300,20 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
"1: call 11f\n" \ "1: call 11f\n" \
" sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7\n" \ " sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7\n" \
"11: or %l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7\n" \ "11: or %l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7\n" \
" sethi %hi(_dl_skip_args), %g5\n" \
" add %l7, %o7, %l7\n" \ " add %l7, %o7, %l7\n" \
" or %g5, %lo(_dl_skip_args), %g5\n" \
" /* Save the user entry point address in %l0. */\n" \ " /* Save the user entry point address in %l0. */\n" \
" mov %o0, %l0\n" \ " mov %o0, %l0\n" \
" /* See if we were run as a command with the executable file name as an\n" \ " /* See if we were run as a command with the executable file name as an\n" \
" extra leading argument. If so, we must shift things around since we\n" \ " extra leading argument. If so, we must shift things around since we\n" \
" must keep the stack doubleword aligned. */\n" \ " must keep the stack doubleword aligned. */\n" \
" ldx [%l7 + %g5], %i0\n" \ RTLD_GOT_ADDRESS(%l7, %g5, _dl_skip_args) \
" ld [%i0], %i0\n" \ " ld [%g5], %i0\n" \
" brz,pt %i0, 2f\n" \ " brz,pt %i0, 2f\n" \
" ldx [%sp + " __S(STACK_BIAS) " + 22*8], %i5\n" \ " ldx [%sp + " __S(STACK_BIAS) " + 22*8], %i5\n" \
" /* Find out how far to shift. */\n" \ " /* Find out how far to shift. */\n" \
" sethi %hi(_dl_argv), %l4\n" \
" sub %i5, %i0, %i5\n" \ " sub %i5, %i0, %i5\n" \
" or %l4, %lo(_dl_argv), %l4\n" \
" sllx %i0, 3, %l6\n" \ " sllx %i0, 3, %l6\n" \
" ldx [%l7 + %l4], %l4\n" \ RTLD_GOT_ADDRESS(%l7, %l4, _dl_argv) \
" stx %i5, [%sp + " __S(STACK_BIAS) " + 22*8]\n" \ " stx %i5, [%sp + " __S(STACK_BIAS) " + 22*8]\n" \
" add %sp, " __S(STACK_BIAS) " + 23*8, %i1\n" \ " add %sp, " __S(STACK_BIAS) " + 23*8, %i1\n" \
" add %i1, %l6, %i2\n" \ " add %i1, %l6, %i2\n" \
@ -333,20 +341,16 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
" add %i1, 16, %i1\n" \ " add %i1, 16, %i1\n" \
" stx %l5, [%l4]\n" \ " stx %l5, [%l4]\n" \
" /* %o0 = _dl_loaded, %o1 = argc, %o2 = argv, %o3 = envp. */\n" \ " /* %o0 = _dl_loaded, %o1 = argc, %o2 = argv, %o3 = envp. */\n" \
"2: sethi %hi(_rtld_local), %o0\n" \ "2:\t" RTLD_GOT_ADDRESS(%l7, %o0, _rtld_local) \
" add %sp, " __S(STACK_BIAS) " + 23*8, %o2\n" \
" orcc %o0, %lo(_rtld_local), %o0\n" \
" sllx %i5, 3, %o3\n" \ " sllx %i5, 3, %o3\n" \
" ldx [%l7 + %o0], %o0\n" \ " add %sp, " __S(STACK_BIAS) " + 23*8, %o2\n" \
" add %o3, 8, %o3\n" \ " add %o3, 8, %o3\n" \
" mov %i5, %o1\n" \ " mov %i5, %o1\n" \
" add %o2, %o3, %o3\n" \ " add %o2, %o3, %o3\n" \
" call _dl_init_internal\n" \ " call _dl_init_internal\n" \
" ldx [%o0], %o0\n" \ " ldx [%o0], %o0\n" \
" /* Pass our finalizer function to the user in %g1. */\n" \ " /* Pass our finalizer function to the user in %g1. */\n" \
" sethi %hi(_dl_fini), %g1\n" \ RTLD_GOT_ADDRESS(%l7, %g1, _dl_fini) \
" or %g1, %lo(_dl_fini), %g1\n" \
" ldx [%l7 + %g1], %g1\n" \
" /* Jump to the user's entry point and deallocate the extra stack we got. */\n" \ " /* Jump to the user's entry point and deallocate the extra stack we got. */\n" \
" jmp %l0\n" \ " jmp %l0\n" \
" add %sp, 6*8, %sp\n" \ " add %sp, 6*8, %sp\n" \

View File

@ -40,18 +40,11 @@
.section ".text" .section ".text"
.align 4 .align 4
#ifdef SHARED
.LLGETPC0:
retl
add %o7, %l7, %l7
#endif
.global _start .global _start
.type _start,#function .type _start,#function
_start: _start:
#ifdef SHARED #ifdef SHARED
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7 SETUP_PIC_REG(l7)
call .LLGETPC0
add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7
#endif #endif
/* Terminate the stack frame, and reserve space for functions to /* Terminate the stack frame, and reserve space for functions to
@ -66,16 +59,35 @@ _start:
add %sp, STACK_BIAS+23*8, %o2 add %sp, STACK_BIAS+23*8, %o2
/* Load the addresses of the user entry points. */ /* Load the addresses of the user entry points. */
#ifndef SHARED
sethi %hi(main), %o0
sethi %hi(__libc_csu_init), %o3
sethi %hi(__libc_csu_fini), %o4
or %o0, %lo(main), %o0
or %o3, %lo(__libc_csu_init), %o3
or %o4, %lo(__libc_csu_fini), %o4
#else
#ifdef HAVE_BINUTILS_GOTDATA
sethi %gdop_hix22(main), %o0
sethi %gdop_hix22(__libc_csu_init), %o3
sethi %gdop_hix22(__libc_csu_fini), %o4
xor %o0, %gdop_lox10(main), %o0
xor %o3, %gdop_lox10(__libc_csu_init), %o3
xor %o4, %gdop_lox10(__libc_csu_fini), %o4
ldx [%l7 + %o0], %o0, %gdop(main)
ldx [%l7 + %o3], %o3, %gdop(__libc_csu_init)
ldx [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
#else
sethi %hi(main), %o0 sethi %hi(main), %o0
sethi %hi(__libc_csu_init), %o3 sethi %hi(__libc_csu_init), %o3
sethi %hi(__libc_csu_fini), %o4 sethi %hi(__libc_csu_fini), %o4
or %o0, %lo(main), %o0 or %o0, %lo(main), %o0
or %o3, %lo(__libc_csu_init), %o3 or %o3, %lo(__libc_csu_init), %o3
or %o4, %lo(__libc_csu_fini), %o4 or %o4, %lo(__libc_csu_fini), %o4
#ifdef SHARED
ldx [%l7 + %o0], %o0 ldx [%l7 + %o0], %o0
ldx [%l7 + %o3], %o3 ldx [%l7 + %o3], %o3
ldx [%l7 + %o4], %o4 ldx [%l7 + %o4], %o4
#endif
#endif #endif
/* When starting a binary via the dynamic linker, %g1 contains the /* When starting a binary via the dynamic linker, %g1 contains the

View File

@ -25,12 +25,7 @@
ENTRY(memcpy) ENTRY(memcpy)
.type memcpy, @gnu_indirect_function .type memcpy, @gnu_indirect_function
# ifdef SHARED # ifdef SHARED
mov %o7, %o5 SETUP_PIC_REG_LEAF(o3, o5)
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %o3
call 1f
or %o3, %lo(_GLOBAL_OFFSET_TABLE_+4), %o3
1: add %o7, %o3, %o3
mov %o5, %o7
# endif # endif
andcc %o0, HWCAP_SPARC_N2, %g0 andcc %o0, HWCAP_SPARC_N2, %g0
be 1f be 1f

View File

@ -25,12 +25,7 @@
ENTRY(memset) ENTRY(memset)
.type memset, @gnu_indirect_function .type memset, @gnu_indirect_function
# ifdef SHARED # ifdef SHARED
mov %o7, %o5 SETUP_PIC_REG_LEAF(o3, o5)
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %o3
call 1f
or %o3, %lo(_GLOBAL_OFFSET_TABLE_+4), %o3
1: add %o7, %o3, %o3
mov %o5, %o7
# endif # endif
andcc %o0, HWCAP_SPARC_BLKINIT, %g0 andcc %o0, HWCAP_SPARC_BLKINIT, %g0
be 9f be 9f
@ -61,12 +56,7 @@ END(memset)
ENTRY(__bzero) ENTRY(__bzero)
.type bzero, @gnu_indirect_function .type bzero, @gnu_indirect_function
# ifdef SHARED # ifdef SHARED
mov %o7, %o5 SETUP_PIC_REG_LEAF(o3, o5)
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %o3
call 1f
or %o3, %lo(_GLOBAL_OFFSET_TABLE_+4), %o3
1: add %o7, %o3, %o3
mov %o5, %o7
# endif # endif
andcc %o0, HWCAP_SPARC_BLKINIT, %g0 andcc %o0, HWCAP_SPARC_BLKINIT, %g0
be 9f be 9f

View File

@ -63,16 +63,20 @@ ENTRY (____longjmp_chk)
nop nop
.Lfail: .Lfail:
#ifdef PIC #ifndef PIC
1: call 2f sethi %hi(longjmp_msg), %o0
sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7 or %o0, %lo(longjmp_msg), %o0
2: or %l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7 #else
add %l7, %o7, %l7 SETUP_PIC_REG(l7)
#endif #ifdef HAVE_BINUTILS_GOTDATA
sethi %gdop_hix22(longjmp_msg), %o0
xor %o0, %gdop_lox10(longjmp_msg), %o0
ld [%l7 + %o0], %o0, %gdop(longjmp_msg)
#else
sethi %hi(longjmp_msg), %o0 sethi %hi(longjmp_msg), %o0
or %o0, %lo(longjmp_msg), %o0 or %o0, %lo(longjmp_msg), %o0
#ifdef PIC
ld [%l7 + %o0], %o0 ld [%l7 + %o0], %o0
#endif
#endif #endif
call HIDDEN_JUMPTARGET(__fortify_fail) call HIDDEN_JUMPTARGET(__fortify_fail)
nop nop

View File

@ -88,6 +88,16 @@ ENTRY(name); \
mov %g1, %o7; mov %g1, %o7;
#else #else
# if RTLD_PRIVATE_ERRNO # if RTLD_PRIVATE_ERRNO
# ifdef HAVE_BINUTILS_GOTDATA
# define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG_LEAF(o2,g1) \
sethi %gdop_hix22(rtld_errno), %g1; \
xor %g1, %gdop_lox10(rtld_errno), %g1;\
ld [%o2 + %g1], %g1, %gdop(rtld_errno); \
st %o0, [%g1]; \
jmp %o7 + 8; \
mov -1, %o0;
# else
# define SYSCALL_ERROR_HANDLER \ # define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG_LEAF(o2,g1) \ 0: SETUP_PIC_REG_LEAF(o2,g1) \
sethi %hi(rtld_errno), %g1; \ sethi %hi(rtld_errno), %g1; \
@ -96,6 +106,7 @@ ENTRY(name); \
st %o0, [%g1]; \ st %o0, [%g1]; \
jmp %o7 + 8; \ jmp %o7 + 8; \
mov -1, %o0; mov -1, %o0;
# endif
# elif defined _LIBC_REENTRANT # elif defined _LIBC_REENTRANT
# ifndef NOT_IN_libc # ifndef NOT_IN_libc
@ -112,6 +123,16 @@ ENTRY(name); \
jmp %o7 + 8; \ jmp %o7 + 8; \
mov -1, %o0; mov -1, %o0;
# else # else
# ifdef HAVE_BINUTILS_GOTDATA
# define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG_LEAF(o2,g1) \
sethi %gdop_hix22(errno), %g1;\
xor %g1, %gdop_lox10(errno), %g1;\
ld [%o2 + %g1], %g1, %gdop(errno);\
st %o0, [%g1]; \
jmp %o7 + 8; \
mov -1, %o0;
# else
# define SYSCALL_ERROR_HANDLER \ # define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG_LEAF(o2,g1) \ 0: SETUP_PIC_REG_LEAF(o2,g1) \
sethi %hi(errno), %g1; \ sethi %hi(errno), %g1; \
@ -120,6 +141,7 @@ ENTRY(name); \
st %o0, [%g1]; \ st %o0, [%g1]; \
jmp %o7 + 8; \ jmp %o7 + 8; \
mov -1, %o0; mov -1, %o0;
# endif
# endif /* _LIBC_REENTRANT */ # endif /* _LIBC_REENTRANT */
#endif /* PIC */ #endif /* PIC */

View File

@ -62,16 +62,20 @@ ENTRY (____longjmp_chk)
nop nop
.Lfail: .Lfail:
#ifdef PIC #ifndef PIC
1: call 2f sethi %hi(longjmp_msg), %o0
sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7 or %o0, %lo(longjmp_msg), %o0
2: or %l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7 #else
add %l7, %o7, %l7 SETUP_PIC_REG(l7)
#endif #ifdef HAVE_BINUTILS_GOTDATA
sethi %gdop_hix22(longjmp_msg), %o0
xor %o0, %gdop_lox10(longjmp_msg), %o0
ldx [%l7 + %o0], %o0, %gdop(longjmp_msg)
#else
sethi %hi(longjmp_msg), %o0 sethi %hi(longjmp_msg), %o0
or %o0, %lo(longjmp_msg), %o0 or %o0, %lo(longjmp_msg), %o0
#ifdef PIC
ldx [%l7 + %o0], %o0 ldx [%l7 + %o0], %o0
#endif
#endif #endif
call HIDDEN_JUMPTARGET(__fortify_fail) call HIDDEN_JUMPTARGET(__fortify_fail)
nop nop

View File

@ -42,10 +42,7 @@ ENTRY (__brk)
cfi_window_save cfi_window_save
cfi_register(%o7, %i7) cfi_register(%o7, %i7)
#ifdef PIC #ifdef PIC
1: call 2f SETUP_PIC_REG(l7)
sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7
2: or %l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7
add %l7, %o7, %l7
#endif #endif
LOADSYSCALL(brk) LOADSYSCALL(brk)
@ -62,10 +59,20 @@ ENTRY (__brk)
nop nop
/* Update __curbrk and return cleanly. */ /* Update __curbrk and return cleanly. */
.Lok: sethi %hi(__curbrk), %g1 .Lok:
#ifndef PIC
sethi %hi(__curbrk), %g1
or %g1, %lo(__curbrk), %g1
#else
#ifdef HAVE_BINUTILS_GOTDATA
sethi %gdop_hix22(__curbrk), %g1
xor %g1, %gdop_lox10(__curbrk), %g1
ldx [%l7 + %g1], %g1, %gdop(__curbrk)
#else
sethi %hi(__curbrk), %g1
or %g1, %lo(__curbrk), %g1 or %g1, %lo(__curbrk), %g1
#ifdef PIC
ldx [%l7 + %g1], %g1 ldx [%l7 + %g1], %g1
#endif
#endif #endif
stx %o0, [%g1] stx %o0, [%g1]
mov %g0, %i0 mov %g0, %i0
@ -78,10 +85,19 @@ ENTRY (__brk)
.Lerr0: set ENOMEM, %o0 .Lerr0: set ENOMEM, %o0
.Lerr1: .Lerr1:
#ifndef _LIBC_REENTRANT #ifndef _LIBC_REENTRANT
#ifndef PIC
sethi %hi(errno), %g1
or %g1, %lo(errno), %g1
#else
#ifdef HAVE_BINUTILS_GOTDATA
sethi %gdop_hix22(errno), %g1
xor %g1, %gdop_lox10(errno), %g1
ldx [%l7 + %g1], %g1, %gdop(errno)
#else
sethi %hi(errno), %g1 sethi %hi(errno), %g1
or %g1, %lo(errno), %g1 or %g1, %lo(errno), %g1
#ifdef PIC
ldx [%l7 + %g1], %g1 ldx [%l7 + %g1], %g1
#endif
#endif #endif
st %o0, [%g1] st %o0, [%g1]
#else #else

View File

@ -95,6 +95,16 @@ ENTRY(name); \
mov %g1, %o7; mov %g1, %o7;
#else #else
# if RTLD_PRIVATE_ERRNO # if RTLD_PRIVATE_ERRNO
# ifdef HAVE_BINUTILS_GOTDATA
# define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG_LEAF(o2,g1) \
sethi %gdop_hix22(rtld_errno), %g1; \
xor %g1, %gdop_lox10(rtld_errno), %g1;\
ldx [%o2 + %g1], %g1, %gdop(rtld_errno); \
st %o0, [%g1]; \
jmp %o7 + 8; \
mov -1, %o0;
# else
# define SYSCALL_ERROR_HANDLER \ # define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG_LEAF(o2,g1) \ 0: SETUP_PIC_REG_LEAF(o2,g1) \
sethi %hi(rtld_errno), %g1; \ sethi %hi(rtld_errno), %g1; \
@ -103,6 +113,7 @@ ENTRY(name); \
st %o0, [%g1]; \ st %o0, [%g1]; \
jmp %o7 + 8; \ jmp %o7 + 8; \
mov -1, %o0; mov -1, %o0;
# endif
# elif defined _LIBC_REENTRANT # elif defined _LIBC_REENTRANT
# ifndef NOT_IN_libc # ifndef NOT_IN_libc
@ -119,6 +130,16 @@ ENTRY(name); \
jmp %o7 + 8; \ jmp %o7 + 8; \
mov -1, %o0; mov -1, %o0;
# else # else
# ifdef HAVE_BINUTILS_GOTDATA
# define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG_LEAF(o2,g1) \
sethi %gdop_hix22(errno), %g1;\
xor %g1, %gdop_lox10(errno), %g1;\
ldx [%o2 + %g1], %g1, %gdop(errno);\
st %o0, [%g1]; \
jmp %o7 + 8; \
mov -1, %o0;
# else
# define SYSCALL_ERROR_HANDLER \ # define SYSCALL_ERROR_HANDLER \
0: SETUP_PIC_REG_LEAF(o2,g1) \ 0: SETUP_PIC_REG_LEAF(o2,g1) \
sethi %hi(errno), %g1; \ sethi %hi(errno), %g1; \
@ -127,6 +148,7 @@ ENTRY(name); \
st %o0, [%g1]; \ st %o0, [%g1]; \
jmp %o7 + 8; \ jmp %o7 + 8; \
mov -1, %o0; mov -1, %o0;
# endif
# endif /* _LIBC_REENTRANT */ # endif /* _LIBC_REENTRANT */
#endif /* PIC */ #endif /* PIC */