linux32_locore.s revision 293516
1/* $FreeBSD: stable/10/sys/amd64/linux32/linux32_locore.s 293516 2016-01-09 15:48:11Z dchagin $ */
2
3#include "linux32_assym.h"			/* system definitions */
4#include <machine/asmacros.h>			/* miscellaneous asm macros */
5
6#include <amd64/linux32/linux32_syscall.h>	/* system call numbers */
7
8.data
9
10	.globl linux_platform
11linux_platform:
12	.asciz "i686"
13
14.text
15.code32
16
17/*
18 * To avoid excess stack frame the signal trampoline code emulates
19 * the 'call' instruction.
20 */
21NON_GPROF_ENTRY(linux32_sigcode)
22	movl	%esp, %ebx			/* preserve sigframe */
23	call .getip0
24.getip0:
25	popl	%eax
26	add	$.startsigcode-.getip0, %eax	/* ret address */
27	push	%eax
28	jmp	*LINUX_SIGF_HANDLER(%ebx)
29.startsigcode:
30	popl	%eax
31	movl	$LINUX_SYS_linux_sigreturn,%eax	/* linux_sigreturn() */
32	int	$0x80				/* enter kernel with args */
33.endsigcode:
340:	jmp	0b
35
36NON_GPROF_ENTRY(linux32_rt_sigcode)
37	leal	LINUX_RT_SIGF_UC(%esp),%ebx	/* linux ucp */
38	leal	LINUX_RT_SIGF_SC(%ebx),%ecx	/* linux sigcontext */
39	movl	%esp, %edi
40	call	.getip1
41.getip1:
42	popl	%eax
43	add	$.startrtsigcode-.getip1, %eax	/* ret address */
44	push	%eax
45	jmp	*LINUX_RT_SIGF_HANDLER(%edi)
46.startrtsigcode:
47	movl	$LINUX_SYS_linux_rt_sigreturn,%eax   /* linux_rt_sigreturn() */
48	int	$0x80				/* enter kernel with args */
49.endrtsigcode:
500:	jmp	0b
51
52NON_GPROF_ENTRY(linux32_vsyscall)
53.startvsyscall:
54	int $0x80
55	ret
56.endvsyscall:
57
58
59	.section .note.Linux, "a",@note
60	.long 2f - 1f		/* namesz */
61	.balign 4
62	.long 4f - 3f		/* descsz */
63	.long 0
641:
65	.asciz "Linux"
662:
67	.balign 4
683:
69	.long LINUX_VERSION_CODE
704:
71	.balign 4
72	.previous
73
74
75#define do_cfa_expr(offset)                                             \
76	.byte 0x0f;			/* DW_CFA_def_cfa_expression */ \
77	.uleb128 11f-10f;		/*   length */                  \
7810:	.byte 0x74;			/*     DW_OP_breg4 */           \
79	.sleb128 offset;		/*      offset */               \
80	.byte 0x06;			/*     DW_OP_deref */           \
8111:
82
83
84	/* CIE */
85	.section .eh_frame,"a",@progbits
86.LSTARTFRAMEDLSI1:
87	.long .LENDCIEDLSI1-.LSTARTCIEDLSI1
88.LSTARTCIEDLSI1:
89	.long 0					/* CIE ID */
90	.byte 1					/* Version number */
91	.string "zRS"				/* NULL-terminated
92						 * augmentation string
93						 */
94	.uleb128 1				/* Code alignment factor */
95	.sleb128 -4				/* Data alignment factor */
96	.byte 8					/* Return address
97						 * register column
98						 */
99	.uleb128 1				/* Augmentation value length */
100	.byte 0x1b				/* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
101	.byte 0					/* DW_CFA_nop */
102	.align 4
103.LENDCIEDLSI1:
104
105	/* FDE */
106	.long .LENDFDEDLSI1-.LSTARTFDEDLSI1	/* Length FDE */
107.LSTARTFDEDLSI1:
108	.long .LSTARTFDEDLSI1-.LSTARTFRAMEDLSI1 /* CIE pointer */
109	.long .startsigcode-.			/* PC-relative start address */
110	.long .endsigcode-.startsigcode
111	.uleb128 0				/* Augmentation */
112	do_cfa_expr(LINUX_SIGF_SC-8)
113	.align 4
114.LENDFDEDLSI1:
115
116	.long .LENDFDEDLSI2-.LSTARTFDEDLSI2	/* Length FDE */
117.LSTARTFDEDLSI2:
118	.long .LSTARTFDEDLSI2-.LSTARTFRAMEDLSI1	/* CIE pointer */
119	.long .startrtsigcode-.			/* PC-relative start address */
120	.long .endrtsigcode-.startrtsigcode
121	.uleb128 0				/* Augmentation */
122	do_cfa_expr(LINUX_RT_SIGF_SC-4+LINUX_SC_ESP)
123	.align 4
124.LENDFDEDLSI2:
125	.previous
126
127	.section .eh_frame,"a",@progbits
128.LSTARTFRAMEDLSI2:
129	.long .LENDCIEDLSI2-.LSTARTCIEDLSI2
130.LSTARTCIEDLSI2:
131	.long 0					/* CIE ID */
132	.byte 1					/* Version number */
133	.string "zR"				/* NULL-terminated
134						 * augmentation string
135						 */
136	.uleb128 1				/* Code alignment factor */
137	.sleb128 -4				/* Data alignment factor */
138	.byte 8					/* Return address register column */
139	.uleb128 1				/* Augmentation value length */
140	.byte 0x1b				/* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
141	.byte 0x0c				/* DW_CFA_def_cfa */
142	.uleb128 4
143	.uleb128 4
144	.byte 0x88				/* DW_CFA_offset, column 0x8 */
145	.uleb128 1
146	.align 4
147.LENDCIEDLSI2:
148	.long .LENDFDEDLSI3-.LSTARTFDEDLSI3 /* Length FDE */
149.LSTARTFDEDLSI3:
150	.long .LSTARTFDEDLSI3-.LSTARTFRAMEDLSI2 /* CIE pointer */
151	.long .startvsyscall-.			/* PC-relative start address */
152	.long .endvsyscall-.startvsyscall
153	.uleb128 0
154	.align 4
155.LENDFDEDLSI3:
156	.previous
157