From dd54084dd9549ae15c12db248571ad76946b8712 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Sat, 18 Feb 2012 22:31:42 -0800 Subject: Rework sparc PIC macros so crt{i,n}.S can use them too. * 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. --- sysdeps/unix/sparc/sysdep.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'sysdeps/unix/sparc') diff --git a/sysdeps/unix/sparc/sysdep.h b/sysdeps/unix/sparc/sysdep.h index fe8b75a0e7..10d561e789 100644 --- a/sysdeps/unix/sparc/sysdep.h +++ b/sysdeps/unix/sparc/sysdep.h @@ -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; \ @@ -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); \ -- cgit v1.2.1