summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Jaroszyński2010-06-09 19:55:09 +0200
committerMichael Brown2010-08-19 13:28:21 +0200
commitbb5b66b8878d48c505fe1a653d5a59e21d3d9380 (patch)
tree4d186520cb238ed8080df07dd0ff877f400da366
parent[dhcp] Use i386-pcbios DHCP options on linux (diff)
downloadipxe-bb5b66b8878d48c505fe1a653d5a59e21d3d9380.tar.gz
ipxe-bb5b66b8878d48c505fe1a653d5a59e21d3d9380.tar.xz
ipxe-bb5b66b8878d48c505fe1a653d5a59e21d3d9380.zip
[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>
-rw-r--r--src/arch/i386/prefix/linuxprefix.S25
-rw-r--r--src/arch/x86_64/prefix/linuxprefix.S22
2 files changed, 47 insertions, 0 deletions
diff --git a/src/arch/i386/prefix/linuxprefix.S b/src/arch/i386/prefix/linuxprefix.S
new file mode 100644
index 000000000..881c61df0
--- /dev/null
+++ b/src/arch/i386/prefix/linuxprefix.S
@@ -0,0 +1,25 @@
+#include <linux/unistd.h>
+
+ .section ".text"
+ .code32
+ .globl _start
+ .type _start, @function
+
+_start:
+ xorl %ebp, %ebp
+
+ popl %esi // save argc
+ movl %esp, %edi // save argv
+
+ andl $~15, %esp // 16-byte align the stack
+
+ pushl %edi // argv -> C arg2
+ pushl %esi // argc -> C arg1
+
+ call main
+
+ movl %eax, %ebx // rc -> syscall arg1
+ movl $__NR_exit, %eax
+ int $0x80
+
+ .size _start, . - _start
diff --git a/src/arch/x86_64/prefix/linuxprefix.S b/src/arch/x86_64/prefix/linuxprefix.S
new file mode 100644
index 000000000..20163b8a4
--- /dev/null
+++ b/src/arch/x86_64/prefix/linuxprefix.S
@@ -0,0 +1,22 @@
+#include <linux/unistd.h>
+
+ .section ".text"
+ .code64
+ .globl _start
+ .type _start, @function
+
+_start:
+ xorq %rbp, %rbp
+
+ popq %rdi // argc -> C arg1
+ movq %rsp, %rsi // argv -> C arg2
+
+ andq $~15, %rsp // 16-byte align the stack
+
+ call main
+
+ movq %rax, %rdi // rc -> syscall arg1
+ movq $__NR_exit, %rax
+ syscall
+
+ .size _start, . - _start