Fix bootstrap/PR63632
[official-gcc.git] / libgo / go / reflect / makefunc_386.S
blob0e2e7646532447d9d3f8b2c0bf7a3aa679a8df5b
1 /* Copyright 2013 The Go Authors. All rights reserved.
2    Use of this source code is governed by a BSD-style
3    license that can be found in the LICENSE file.
5    MakeFunc 386 assembly code.  */
7 #include "config.h"
9         .globl reflect.makeFuncStub
11 #ifdef __ELF__
12         .type reflect.makeFuncStub,@function
13 #endif
15 reflect.makeFuncStub:
16 .LFB1:
18         /* Go does not provide any equivalent to the regparm function
19            attribute, so on Go we do not need to worry about passing
20            parameters in registers.  We just pass a pointer to the
21            arguments on the stack.
22         
23            We do need to pick up the return values, though, so we pass
24            a pointer to a struct that looks like this.
25            struct {
26              esp uint32         // 0x0
27              eax uint32         // 0x4
28              st0 float64        // 0x8
29              sr  bool           // 0x10
30              sf  bool           // 0x11
31            }
32            The sr field is set by the function to a non-zero value if
33            the function takes a struct hidden pointer that must be
34            popped off the stack.  */
36         pushl   %ebp
37 .LCFI0:
38         movl    %esp, %ebp
39 .LCFI1:
40         pushl   %ebx            /* In case this is PIC.  */
41         subl    $36, %esp       /* Enough for args and to align stack.  */
42 .LCFI2:
44 #ifdef __PIC__
45         call    __x86.get_pc_thunk.bx
46         addl    $_GLOBAL_OFFSET_TABLE_, %ebx
47 #endif
49         leal    8(%ebp), %eax   /* Set esp field in struct.  */
50         movl    %eax, -24(%ebp)
52         /* For MakeFunc functions that call recover.  */
53         movl    4(%ebp), %eax
54         movl    %eax, (%esp)
55 #ifdef __PIC__
56         call    __go_makefunc_can_recover@PLT
57 #else
58         call    __go_makefunc_can_recover
59 #endif
61 #ifdef __PIC__
62         call    __go_get_closure@PLT
63 #else
64         call    __go_get_closure
65 #endif
67         movl    %eax, 4(%esp)
69         leal    -24(%ebp), %eax
70         movl    %eax, (%esp)
72 #ifdef __PIC__
73         call    reflect.MakeFuncStubGo@PLT
74 #else
75         call    reflect.MakeFuncStubGo
76 #endif
78         /* MakeFunc functions can no longer call recover.  */
79 #ifdef __PIC__
80         call __go_makefunc_returning@PLT
81 #else
82         call __go_makefunc_returning
83 #endif
85         /* Set return registers.  */
87         movl    -20(%ebp), %eax
89         cmpb    $0, -7(%ebp)
90         je      2f
92         fldl    -16(%ebp)
94 #ifdef __SSE2__
95         /* In case we are compiling with -msseregparm.  This won't work
96            correctly if only SSE1 is supported, but that seems unlikely.  */
97         movsd   -16(%ebp), %xmm0
98 #endif
101         movb    -8(%ebp), %dl
103         addl    $36, %esp
104         popl    %ebx
105 .LCFI3:
106         popl    %ebp
107 .LCFI4:
109         testb   %dl,%dl
110         jne     1f
111         ret
113         ret     $4
114 .LFE1:
115 #ifdef __ELF__
116         .size   reflect.makeFuncStub, . - reflect.makeFuncStub
117 #endif
119 #ifdef __PIC__
120 #ifdef HAVE_AS_COMDAT_GAS
121         .section        .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
122 #else
123         /* Sun as needs a different syntax.  */
124         .section        .text.__x86.get_pc_thunk.bx%__x86.get_pc_thunk.bx,"ax",@progbits
125         .group          __x86.get_pc_thunk.bx,.text.__x86.get_pc_thunk.bx%__x86.get_pc_thunk.bx,#comdat
126 #endif
127         .globl  __x86.get_pc_thunk.bx
128         .hidden __x86.get_pc_thunk.bx
129 #ifdef __ELF__
130         .type   __x86.get_pc_thunk.bx, @function
131 #endif
132 __x86.get_pc_thunk.bx:
133 .LFB2:
134         movl    (%esp), %ebx
135         ret
136 .LFE2:
137 #ifdef __ELF__
138         .size   __x86.get_pc_thunk.bx, . - __x86.get_pc_thunk.bx
139 #endif
140 #endif
142 #ifdef __ELF__
143 #if defined __PIC__
144 # if defined __sun__ && defined __svr4__
145 /* 32-bit Solaris 2/x86 uses datarel encoding for PIC.  GNU ld before 2.22
146    doesn't correctly sort .eh_frame_hdr with mixed encodings, so match this.  */
147 #  define FDE_ENCODING          0x30    /* datarel */
148 #  define FDE_ENCODE(X)         X@GOTOFF
149 # else
150 #  define FDE_ENCODING          0x1b    /* pcrel sdata4 */
151 #  if defined HAVE_AS_X86_PCREL
152 #   define FDE_ENCODE(X)        X-.
153 #  else
154 #   define FDE_ENCODE(X)        X@rel
155 #  endif
156 # endif
157 #else
158 # define FDE_ENCODING           0       /* absolute */
159 # define FDE_ENCODE(X)          X
160 #endif
162         .section        .eh_frame,EH_FRAME_FLAGS,@progbits
163 .Lframe1:
164         .long   .LECIE1-.LSCIE1 /* Length of Common Information Entry */
165 .LSCIE1:
166         .long   0x0     /* CIE Identifier Tag */
167         .byte   0x1     /* CIE Version */
168         .ascii "zR\0"   /* CIE Augmentation */
169         .byte   0x1     /* .uleb128 0x1; CIE Code Alignment Factor */
170         .byte   0x7c    /* .sleb128 -4; CIE Data Alignment Factor */
171         .byte   0x8     /* CIE RA Column */
172         .byte   0x1     /* .uleb128 0x1; Augmentation size */
173         .byte   FDE_ENCODING
174         .byte   0xc     /* DW_CFA_def_cfa */
175         .byte   0x4     /* .uleb128 0x4 */
176         .byte   0x4     /* .uleb128 0x4 */
177         .byte   0x88    /* DW_CFA_offset, column 0x8 */
178         .byte   0x1     /* .uleb128 0x1 */
179         .align 4
180 .LECIE1:
181 .LSFDE1:
182         .long   .LEFDE1-.LASFDE1        /* FDE Length */
183 .LASFDE1:
184         .long   .LASFDE1-.Lframe1       /* FDE CIE offset */
185         .long   FDE_ENCODE(.LFB1)       /* FDE initial location */
186         .long   .LFE1-.LFB1             /* FDE address range */
187         .byte   0x0     /* .uleb128 0x0; Augmentation size */
188         .byte   0x4     /* DW_CFA_advance_loc4 */
189         .long   .LCFI0-.LFB1
190         .byte   0xe     /* DW_CFA_def_cfa_offset */
191         .byte   0x8     /* .uleb128 0x8 */
192         .byte   0x85    /* DW_CFA_offset, column 0x5 */
193         .byte   0x2     /* .uleb128 0x2 */
194         .byte   0x4     /* DW_CFA_advance_loc4 */
195         .long   .LCFI1-.LCFI0
196         .byte   0xd     /* DW_CFA_def_cfa_register */
197         .byte   0x5     /* .uleb128 0x5 */
198         .byte   0x4     /* DW_CFA_advance_loc4 */
199         .long   .LCFI2-.LCFI1
200         .byte   0x83    /* .DW_CFA_offset, column 0x3 */
201         .byte   0x3     /* .uleb128 0x3 */
202         .byte   0x4     /* DW_CFA_advance_loc4 */
203         .long   .LCFI3-.LCFI2
204         .byte   0xc3    /* DW_CFA_restore, column 0x3 */
205         .byte   0x4     /* DW_CFA_advance_loc4 */
206         .long   .LCFI4-.LCFI3
207         .byte   0xc5    /* DW_CFA_restore, column 0x5 */
208         .byte   0xc     /* DW_CFA_def_cfa */
209         .byte   0x4     /* .uleb128 0x4 */
210         .byte   0x4     /* .uleb128 0x4 */
211         .align 4
212 .LEFDE1:
213 #ifdef __PIC__
214 .LSFDE2:
215         .long   .LEFDE2-.LASFDE2        /* FDE Length */
216 .LASFDE2:
217         .long   .LASFDE2-.Lframe1       /* FDE CIE offset */
218         .long   FDE_ENCODE(.LFB2)       /* FDE initial location */
219         .long   .LFE2-.LFB2             /* FDE address range */
220         .byte   0x0     /* .uleb128 0x0; Augmentation size */
221         .align 4
222 .LEFDE2:
223 #endif /* __PIC__ */
224 #endif /* __ELF__ */
226 #if defined(__ELF__) && defined(__linux__)
227         .section        .note.GNU-stack,"",@progbits
228         .section        .note.GNU-split-stack,"",@progbits
229         .section        .note.GNU-no-split-stack,"",@progbits
230 #endif