1 /* Special support for trampolines
3 * Copyright (C) 1996, 1997, 2000, 2004, 2005 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 2, or (at your option) any
11 * In addition to the permissions in the GNU General Public License, the
12 * Free Software Foundation gives you unlimited permission to link the
13 * compiled version of this file with other programs, and to distribute
14 * those programs without any restriction coming from the use of this
15 * file. (The General Public License restrictions do apply in other
16 * respects; for example, they cover modification of the file, and
17 * distribution when not linked into another program.)
19 * This file is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; see the file COPYING. If not, write to
26 * the Free Software Foundation, 59 Temple Place - Suite 330,
27 * Boston, MA 02111-1307, USA.
29 * As a special exception, if you link this library with files
30 * compiled with GCC to produce an executable, this does not cause the
31 * resulting executable to be covered by the GNU General Public License.
32 * This exception does not however invalidate any other reasons why the
33 * executable file might be covered by the GNU General Public License.
36 /* APPLE LOCAL mainline throughout this file */
38 #include "darwin-asm.h"
40 /* Set up trampolines. */
47 Lfunc = .-Ltrampoline_initial
48 .g_long 0 /* will be replaced with function address */
49 Lchain = .-Ltrampoline_initial
50 .g_long 0 /* will be replaced with static chain */
52 lg r12,0(r11) /* function address */
55 lg r11,GPR_BYTES(r11) /* static chain */
58 trampoline_size = .-Ltrampoline_initial
60 /* R3 = stack address to store trampoline */
61 /* R4 = length of trampoline area */
62 /* R5 = function address */
63 /* R6 = static chain */
65 .globl ___trampoline_setup
67 mflr r0 /* save return address */
68 bcl 20,31,LCF0 /* load up __trampoline_initial into r7 */
71 addis r7,r11,ha16(LTRAMP-LCF0)
72 lg r7,lo16(LTRAMP-LCF0)(r7)
74 li r8,trampoline_size /* verify trampoline big enough */
76 srwi r4,r4,2 /* # words to move (insns always 4-byte) */
77 addi r9,r3,-4 /* adjust pointer for lgu */
83 /* Copy the instructions to the stack */
89 /* Store correct function and static chain */
93 /* Now flush both caches */
101 /* Finally synchronize things & return */
110 .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
113 .indirect_symbol _abort
118 addis r11,r11,ha16(L_abort$lazy_ptr-L0$_abort)
120 lgu r12,lo16(L_abort$lazy_ptr-L0$_abort)(r11)
126 .indirect_symbol _abort
127 .g_long dyld_stub_binding_helper
132 .align LOG2_GPR_BYTES
134 .g_long Ltrampoline_initial