Sfoglia il codice sorgente

[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 anni fa
parent
commit
bb5b66b887
2 ha cambiato i file con 47 aggiunte e 0 eliminazioni
  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 Vedi File

@@ -0,0 +1,25 @@
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 Vedi File

@@ -0,0 +1,22 @@
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…
Annulla
Salva