OSDN Git Service

Add @plt if -fpic; Fix double->int conversions if stack > 32k; Redo t-* files; Fix...
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / tramp.asm
1 /* CYGNUS LOCAL -- waiting for FSF sources to be restored/meissner */
2 /*
3  * special support for trampolines
4  *
5  *   Copyright (C) 1996 Free Software Foundation, Inc.
6  *   Written By Michael Meissner
7  * 
8  * This file is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the
10  * Free Software Foundation; either version 2, or (at your option) any
11  * later version.
12  * 
13  * In addition to the permissions in the GNU General Public License, the
14  * Free Software Foundation gives you unlimited permission to link the
15  * compiled version of this file with other programs, and to distribute
16  * those programs without any restriction coming from the use of this
17  * file.  (The General Public License restrictions do apply in other
18  * respects; for example, they cover modification of the file, and
19  * distribution when not linked into another program.)
20  * 
21  * This file is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24  * General Public License for more details.
25  * 
26  * You should have received a copy of the GNU General Public License
27  * along with this program; see the file COPYING.  If not, write to
28  * the Free Software Foundation, 59 Temple Place - Suite 330,
29  * Boston, MA 02111-1307, USA.
30  * 
31  *    As a special exception, if you link this library with files
32  *    compiled with GCC to produce an executable, this does not cause
33  *    the resulting executable to be covered by the GNU General Public License.
34  *    This exception does not however invalidate any other reasons why
35  *    the executable file might be covered by the GNU General Public License.
36  */ 
37
38 /* Set up trampolines */
39
40         .file   "tramp.asm"
41         .section ".text"
42         #include "ppc-asm.h"
43
44         .globl  __trampoline_initial
45         .type   __trampoline_initial,@object
46         .align  2
47 __trampoline_initial:
48         mflr    r0
49         bl      1f
50 .Lfunc = .-__trampoline_initial
51         .long   0                       /* will be replaced with function address */
52 .Lchain = .-__trampoline_initial
53         .long   0                       /* will be replaced with static chain */
54 1:      mflr    r11
55         mtlr    r0
56         lwz     r0,0(r11)               /* function address */
57         lwz     r11,4(r11)              /* static chain */
58         mtctr   r0
59         bctr
60
61 __trampoline_size = .-__trampoline_initial
62         .size   __trampoline_initial,__trampoline_size
63
64         .section ".got2","aw"
65 .LCTOC1 = .+32768
66 .Ltramp = .-.LCTOC1
67         .long __trampoline_initial-4
68
69         .section ".text"
70 .LCL0:
71         .long .LCTOC1-.LCF0
72
73 /* R3 = stack address to store trampoline */
74 /* R4 = length of trampoline area */
75 /* R5 = function address */
76 /* R6 = static chain */
77
78 FUNC_START(__trampoline_setup)
79         mflr    r0                      /* save return address */
80         bl      .LCF0                   /* load up __trampoline_initial into r7 */
81 .LCF0:
82         mflr    r11
83         lwz     r12,(.LCL0-.LCF0)(r11)
84         add     r11,r12,r11
85         lwz     r7,.Ltramp(r11)         /* trampoline addres -4 */
86
87         li      r8,__trampoline_size    /* verify that the trampoline is big enough */
88         cmpw    cr1,r8,r4
89         srwi    r4,r4,2                 /* # words to move */
90         addi    r9,r3,-4                /* adjust pointer for lwzu */
91         mtctr   r4
92         blt     cr1,.Labort
93
94         mtlr    r0
95
96         /* Copy the instructions to the stack */
97 .Lmove:
98         lwzu    r10,4(r7)
99         stwu    r10,4(r9)
100         bdnz    .Lmove
101
102         /* Store correct function and static chain */
103         stw     r5,.Lfunc(r3)
104         stw     r6,.Lchain(r3)
105
106         /* Now flush both caches */
107         mtctr   r4
108 .Lcache:
109         icbi    0,r3
110         dcbf    0,r3
111         addi    r3,r3,4
112         bdnz    .Lcache
113
114         /* Finally synchronize things & return */
115         sync
116         isync
117         blr
118
119 .Labort:
120         bl      abort
121 FUNC_END(__trampoline_setup)
122 /* END CYGNUS LOCAL -- waiting for FSF sources to be restored/meissner */