Browse Source

[linux] Add linuxprefix

Add a minimal _start required to run main.

Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Piotr Jaroszyński 14 years ago
parent
commit
bb5b66b887
2 changed files with 47 additions and 0 deletions
  1. 25
    0
      src/arch/i386/prefix/linuxprefix.S
  2. 22
    0
      src/arch/x86_64/prefix/linuxprefix.S

+ 25
- 0
src/arch/i386/prefix/linuxprefix.S View File

1
+#include <linux/unistd.h>
2
+
3
+	.section ".text"
4
+	.code32
5
+	.globl _start
6
+	.type _start, @function
7
+
8
+_start:
9
+	xorl	%ebp, %ebp
10
+
11
+	popl	%esi       // save argc
12
+	movl	%esp, %edi // save argv
13
+
14
+	andl	$~15, %esp // 16-byte align the stack
15
+
16
+	pushl	%edi // argv -> C arg2
17
+	pushl	%esi // argc -> C arg1
18
+
19
+	call	main
20
+
21
+	movl	%eax, %ebx // rc -> syscall arg1
22
+	movl	$__NR_exit, %eax
23
+	int	$0x80
24
+
25
+	.size _start, . - _start

+ 22
- 0
src/arch/x86_64/prefix/linuxprefix.S View File

1
+#include <linux/unistd.h>
2
+
3
+	.section ".text"
4
+	.code64
5
+	.globl _start
6
+	.type _start, @function
7
+
8
+_start:
9
+	xorq	%rbp, %rbp
10
+
11
+	popq	%rdi       // argc -> C arg1
12
+	movq	%rsp, %rsi // argv -> C arg2
13
+
14
+	andq	$~15, %rsp // 16-byte align the stack
15
+
16
+	call	main
17
+
18
+	movq	%rax, %rdi // rc -> syscall arg1
19
+	movq	$__NR_exit, %rax
20
+	syscall
21
+
22
+	.size _start, . - _start

Loading…
Cancel
Save