1 /* Special support for trampolines
3 * Copyright (C) 1996-2013 Free Software Foundation, Inc.
4 * Written By Michael Meissner
6 * This file is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 3, or (at your option) any
11 * This file is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * Under Section 7 of GPL version 3, you are granted additional
17 * permissions described in the GCC Runtime Library Exception, version
18 * 3.1, as published by the Free Software Foundation.
20 * You should have received a copy of the GNU General Public License and
21 * a copy of the GCC Runtime Library Exception along with this program;
22 * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 * <http://www.gnu.org/licenses/>.
26 #include "darwin-asm.h"
28 /* Set up trampolines. */
35 Lfunc = .-Ltrampoline_initial
36 .g_long 0 /* will be replaced with function address */
37 Lchain = .-Ltrampoline_initial
38 .g_long 0 /* will be replaced with static chain */
40 lg r12,0(r11) /* function address */
43 lg r11,GPR_BYTES(r11) /* static chain */
46 trampoline_size = .-Ltrampoline_initial
48 /* R3 = stack address to store trampoline */
49 /* R4 = length of trampoline area */
50 /* R5 = function address */
51 /* R6 = static chain */
53 .globl ___trampoline_setup
55 mflr r0 /* save return address */
56 bcl 20,31,LCF0 /* load up __trampoline_initial into r7 */
59 addis r7,r11,ha16(LTRAMP-LCF0)
60 lg r7,lo16(LTRAMP-LCF0)(r7)
62 li r8,trampoline_size /* verify trampoline big enough */
64 srwi r4,r4,2 /* # words to move (insns always 4-byte) */
65 addi r9,r3,-4 /* adjust pointer for lgu */
71 /* Copy the instructions to the stack */
77 /* Store correct function and static chain */
81 /* Now flush both caches */
89 /* Ensure cache-flushing has finished. */
93 /* Make stack writeable. */
94 b ___enable_execute_stack
100 .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
103 .indirect_symbol _abort
108 addis r11,r11,ha16(L_abort$lazy_ptr-L0$_abort)
110 lgu r12,lo16(L_abort$lazy_ptr-L0$_abort)(r11)
116 .indirect_symbol _abort
117 .g_long dyld_stub_binding_helper
122 .align LOG2_GPR_BYTES
124 .g_long Ltrampoline_initial