1/* SPDX-License-Identifier: BSD-3-Clause */
2/*
3 * crt0-efi-ia32.S - x86 EFI startup code.
4 *
5 * Copyright (C) 1999 Hewlett-Packard Co.
6 * Contributed by David Mosberger <davidm@hpl.hp.com>.
7 * All rights reserved.
8 */
9
10	.text
11	.align 4
12
13	.globl _start
14_start:
15	pushl %ebp
16	movl %esp,%ebp
17
18	pushl 12(%ebp)			# copy "image" argument
19	pushl  8(%ebp)			# copy "systab" argument
20
21	call 0f
220:	popl %eax
23	movl %eax,%ebx
24
25	addl $image_base-0b,%eax	# %eax = ldbase
26	addl $_DYNAMIC-0b,%ebx		# %ebx = _DYNAMIC
27
28	pushl %ebx			# pass _DYNAMIC as second argument
29	pushl %eax			# pass ldbase as first argument
30	call _relocate
31	popl %ebx
32	popl %ebx
33	testl %eax,%eax
34	jne .exit
35	call efi_main		# call app with "image" and "systab" argument
36
37.exit:	leave
38	ret
39
40	/*
41	 * hand-craft a dummy .reloc section so EFI knows it's a relocatable
42	 * executable:
43	 */
44	.data
45dummy:	.long	0
46
47#define IMAGE_REL_ABSOLUTE	0
48	.section .reloc
49	.long	dummy					/* Page RVA */
50	.long	10					/* Block Size (2*4+2) */
51	.word	(IMAGE_REL_ABSOLUTE << 12) +  0		/* reloc for dummy */
52