1 /* Copyright (C) 2011-2021 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 3 4 The GNU C Library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 The GNU C Library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with the GNU C Library; if not, see 16 <https://www.gnu.org/licenses/>. */ 17 18 #define _SYSDEPS_SYSDEP_H 1 19 #include <bits/hwcap.h> 20 21 #ifdef __ASSEMBLER__ 22 23 #define SPARC_PIC_THUNK(reg) \ 24 .ifndef __sparc_get_pc_thunk.reg; \ 25 .section .text.__sparc_get_pc_thunk.reg,"axG",@progbits,__sparc_get_pc_thunk.reg,comdat; \ 26 .align 32; \ 27 .weak __sparc_get_pc_thunk.reg; \ 28 .hidden __sparc_get_pc_thunk.reg; \ 29 .type __sparc_get_pc_thunk.reg, #function; \ 30 __sparc_get_pc_thunk.reg: \ 31 jmp %o7 + 8; \ 32 add %o7, %reg, %##reg; \ 33 .previous; \ 34 .endif; 35 36 /* The "-4" and "+4" offsets against _GLOBAL_OFFSET_TABLE_ are 37 critical since they represent the offset from the thunk call to the 38 instruction containing the _GLOBAL_OFFSET_TABLE_ reference. 39 Therefore these instructions cannot be moved around without 40 appropriate adjustments to those offsets. 41 42 Furthermore, these expressions are special in another regard. When 43 the assembler sees a reference to _GLOBAL_OFFSET_TABLE_ inside of 44 a %hi() or %lo(), it emits a PC-relative relocation. This causes 45 R_SPARC_HI22 to turn into R_SPARC_PC22, and R_SPARC_LO10 to turn into 46 R_SPARC_PC10, respectively. 47 48 Even when v9 we use a call sequence instead of using "rd %pc" because 49 RDPC is extremely expensive and incurs a full pipeline flush. */ 50 51 #define SPARC_PIC_THUNK_CALL(reg) \ 52 sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %##reg; \ 53 call __sparc_get_pc_thunk.reg; \ 54 or %##reg, %lo(_GLOBAL_OFFSET_TABLE_+4), %##reg; 55 56 #define SETUP_PIC_REG(reg) \ 57 SPARC_PIC_THUNK(reg) \ 58 SPARC_PIC_THUNK_CALL(reg) 59 60 #define SETUP_PIC_REG_LEAF(reg, tmp) \ 61 SPARC_PIC_THUNK(reg) \ 62 mov %o7, %##tmp; \ 63 SPARC_PIC_THUNK_CALL(reg); \ 64 mov %##tmp, %o7; 65 66 #undef ENTRY 67 #define ENTRY(name) \ 68 .align 4; \ 69 .global C_SYMBOL_NAME(name); \ 70 .type name, @function; \ 71 C_LABEL(name) \ 72 cfi_startproc; 73 74 #undef END 75 #define END(name) \ 76 cfi_endproc; \ 77 .size name, . - name 78 79 #undef LOC 80 #define LOC(name) .L##name 81 82 #endif /* __ASSEMBLER__ */ 83