1 /* Copyright (C) 2011-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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/>. */
18 #define _SYSDEPS_SYSDEP_H 1
19 #include <bits/hwcap.h>
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; \
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: \
32 add %o7, %reg, %##reg; \
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.
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.
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. */
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;
56 #define SETUP_PIC_REG(reg) \
57 SPARC_PIC_THUNK(reg) \
58 SPARC_PIC_THUNK_CALL(reg)
60 #define SETUP_PIC_REG_LEAF(reg, tmp) \
61 SPARC_PIC_THUNK(reg) \
63 SPARC_PIC_THUNK_CALL(reg); \
69 .global C_SYMBOL_NAME(name); \
70 .type name, @function; \
79 #define ENTRY_NOCFI(name) \
81 .global C_SYMBOL_NAME(name); \
82 .type name, @function; \
85 #define END_NOCFI(name) \
89 #define LOC(name) .L##name
91 #endif /* __ASSEMBLER__ */