1 /* PLT trampolines. ARM version.
2 Copyright (C) 2005 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 #include <libc-symbols.h>
23 #if defined(__USE_BX__)
26 #define BX(x) mov pc, x
30 .globl _dl_runtime_resolve
31 .type _dl_runtime_resolve, #function
35 cfi_adjust_cfa_offset (4)
36 cfi_rel_offset (lr, 0)
39 @ stack[0] contains the return address from this call
40 @ ip contains &GOT[n+3] (pointer to function)
41 @ lr points to &GOT[2]
43 @ Save arguments. We save r4 to realign the stack.
45 cfi_adjust_cfa_offset (20)
46 cfi_rel_offset (r0, 0)
47 cfi_rel_offset (r1, 4)
48 cfi_rel_offset (r2, 8)
49 cfi_rel_offset (r3, 12)
51 @ get pointer to linker struct
54 @ prepare to call _dl_fixup()
55 @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each
66 @ get arguments and return address back. We restore r4
67 @ only to realign the stack.
69 cfi_adjust_cfa_offset (-24)
71 @ jump to the newly found address
75 .size _dl_runtime_resolve, .-_dl_runtime_resolve
78 .globl _dl_runtime_profile
79 .type _dl_runtime_profile, #function
83 cfi_adjust_cfa_offset (4)
84 cfi_rel_offset (lr, 0)
87 @ stack[0] contains the return address from this call
88 @ ip contains &GOT[n+3] (pointer to function)
89 @ lr points to &GOT[2]
93 @ 208 - framesize returned from pltenter
95 @ 8 - Saved two arguments to _dl_profile_fixup
96 @ 4 - Saved result of _dl_profile_fixup
97 @ 0 - outgoing argument to _dl_profile_fixup
98 @ For now, we only save the general purpose registers.
101 cfi_adjust_cfa_offset (196)
103 cfi_rel_offset (r0, 0)
104 cfi_rel_offset (r1, 4)
105 cfi_rel_offset (r2, 8)
106 cfi_rel_offset (r3, 12)
109 cfi_adjust_cfa_offset (16)
117 @ get pointer to linker struct
120 @ prepare to call _dl_profile_fixup()
121 @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each
126 @ Save these two arguments for pltexit.
130 @ Set up extra args for _dl_profile_fixup.
131 @ r2 and r3 are already loaded.
135 @ call profiling fixup routine
138 @ The address to call is now in r0.
140 @ Check whether we're wrapping this function.
149 @ get arguments and return address back
151 cfi_adjust_cfa_offset (-16)
152 ldmia sp, {r0-r3,sp,lr}
153 cfi_adjust_cfa_offset (-200)
155 @ jump to the newly found address
160 @ The new frame size is in ip.
164 @ 264 - saved result of _dl_profile_fixup
166 @ 64 - Saved two arguments to _dl_profile_fixup
168 @ For now, we only save the general purpose registers.
170 @ Build the new frame.
172 cfi_rel_offset (r7, 212)
174 cfi_def_cfa_register (r7)
175 cfi_adjust_cfa_offset (56)
179 @ Save the _dl_profile_fixup result around the call to memcpy.
182 @ Copy the stack arguments.
206 cfi_def_cfa_register (sp)
210 cfi_adjust_cfa_offset (-272)
214 .size _dl_runtime_profile, .-_dl_runtime_profile