1 /* PLT trampolines. hppa version.
2 Copyright (C) 2005-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
21 /* This code gets called via the .plt stub, and is used in
22 dl-runtime.c to call the `_dl_fixup' function and then redirect
23 to the address it returns. `_dl_fixup' takes two arguments, however
24 `_dl_profile_fixup' takes a number of parameters for use with
25 library auditing (LA).
27 WARNING: This template is also used by gcc's __cffc, and expects
28 that the "bl" for _dl_runtime_resolve exist at a particular offset.
29 Do not change this template without changing gcc, while the prefix
30 "bl" should fix everything so gcc finds the right spot, it will
31 slow down __cffc when it attempts to call fixup to resolve function
32 descriptor references. Please refer to gcc/gcc/config/pa/fptr.c
34 Enter with r19 = reloc offset, r20 = got-8, r21 = fixup ltp. */
36 /* RELOCATION MARKER: bl to provide gcc's __cffc with fixup loc. */
38 /* THIS CODE DOES NOT EXECUTE */
41 .global _dl_runtime_resolve
42 .type _dl_runtime_resolve,@function
47 .CALLINFO FRAME=128,CALLS,SAVE_RP,ENTRY_GR=3
49 /* SAVE_RP says we do */
52 /* Save static link register */
54 /* Save argument registers */
60 /* Build a call frame, and save structure pointer. */
61 copy %sp, %r1 /* Copy previous sp */
62 /* Save function result address (on entry) */
64 /* Fillin some frame info to follow ABI */
65 stw %r1,-4(%sp) /* Previous sp */
66 stw %r21,-32(%sp) /* PIC register value */
68 /* Save input floating point registers. This must be done
69 in the new frame since the previous frame doesn't have
77 /* Set up args to fixup func, needs only two arguments */
78 ldw 8+4(%r20),%r26 /* (1) got[1] == struct link_map */
79 copy %r19,%r25 /* (2) reloc offset */
81 /* Call the real address resolver. */
83 copy %r21,%r19 /* set fixup func ltp */
85 /* Load up the returned func descriptor */
89 /* Reload arguments fp args */
96 /* Adjust sp, and restore function result address*/
99 /* Reload static link register */
101 /* Reload general args */
107 /* Jump to new function, but return to previous function */
113 .size _dl_runtime_resolve, . - _dl_runtime_resolve
116 .global _dl_runtime_profile
117 .type _dl_runtime_profile,@function
122 .CALLINFO FRAME=192,CALLS,SAVE_RP,ENTRY_GR=3
125 /* SAVE_RP says we do */
127 /* Save static link register */
130 /* Build a call frame, and save structure pointer. */
131 copy %sp, %r1 /* Copy previous sp */
132 /* Save function result address (on entry) */
134 /* Fillin some frame info to follow ABI */
135 stw %r1,-4(%sp) /* Previous sp */
136 stw %r21,-32(%sp) /* PIC register value */
138 /* Create La_hppa_retval */
142 -128, lr_fr4 (8 bytes) */
144 /* Create save space for _dl_profile_fixup arguments
145 -120, Saved reloc offset
146 -116, Saved struct link_map
149 /* Create La_hppa_regs */
150 /* 32-bit registers */
155 /* -92, 4 byte pad */
156 /* 64-bit floating point registers */
162 /* 32-bit stack pointer and return register */
167 /* Set up args to fixup func, needs five arguments */
168 ldw 8+4(%r20),%r26 /* (1) got[1] == struct link_map */
169 stw %r26,-116(%sp) /* Save struct link_map */
170 copy %r19,%r25 /* (2) reloc offset */
171 stw %r25,-120(%sp) /* Save reloc offset */
172 copy %rp,%r24 /* (3) profile_fixup needs rp */
173 ldo -56(%sp),%r23 /* (4) La_hppa_regs */
175 stw %r1, -52(%sp) /* (5) long int *framesizep */
177 /* Call the real address resolver. */
178 bl _dl_profile_fixup,%rp
179 copy %r21,%r19 /* set fixup func ltp */
181 /* Load up the returned function descriptor */
185 /* Restore gr/fr/sp/rp */
190 /* -92, 4 byte pad, skip */
198 /* Reload static link register -(192+16) without adjusting stack */
201 /* *framesizep is >= 0 if we have to run pltexit */
203 cmpb,>>=,N %r0,%r28,L(cpe)
205 /* Adjust sp, and restore function result address*/
207 /* Jump to new function, but return to previous function */
213 /* Call the returned function descriptor */
219 /* We are going to call the resolved function, but we have a
220 stack frame in the middle. We use the value of framesize to
221 guess how much extra frame we need, and how much frame to
224 /* Round to nearest multiple of 64 */
228 /* Calcualte start of stack copy */
231 /* Increate the stack by *framesizep */
234 /* Save stack pointer */
237 /* Single byte copy of prevous stack onto newly allocated stack */
238 1: ldb %r28(%r2), %r1
244 /* Retore r28 and r27 and r2 already points at -192(%sp) */
248 /* Calculate address of L(cont) */
252 /* Undo fake stack */
256 /* Arguments to _dl_call_pltexit */
257 ldw -116(%sp), %r26 /* (1) got[1] == struct link_map */
258 ldw -120(%sp), %r25 /* (2) reloc offsets */
259 ldo -56(%sp), %r24 /* (3) *La_hppa_regs */
260 ldo -124(%sp), %r23 /* (4) *La_hppa_retval */
262 /* Fill *La_hppa_retval */
268 /* Call _dl_call_pltexit */
269 bl _dl_call_pltexit,%rp
272 /* Restore *La_hppa_retval */
278 /* Unwind the stack */
280 /* Retore callers rp */
287 .size _dl_runtime_profile, . - _dl_runtime_profile