summaryrefslogtreecommitdiffstats
path: root/src/arch/i386/core/linux
diff options
context:
space:
mode:
authorMichael Brown2011-04-27 01:07:42 +0200
committerMichael Brown2011-04-27 01:26:38 +0200
commita9dbc943aeb73d9267bfbefc95106974a3c94ea0 (patch)
tree15b6cc23a5f289d182a950e329adfedd4f459626 /src/arch/i386/core/linux
parent[sanboot] Add "sanhook" and "sanunhook" commands (diff)
downloadipxe-a9dbc943aeb73d9267bfbefc95106974a3c94ea0.tar.gz
ipxe-a9dbc943aeb73d9267bfbefc95106974a3c94ea0.tar.xz
ipxe-a9dbc943aeb73d9267bfbefc95106974a3c94ea0.zip
[linux] Avoid building Linux-specific prefix on non-Linux builds
Reported-by: David Yeske <dyeske@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/i386/core/linux')
-rw-r--r--src/arch/i386/core/linux/linuxprefix.S28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/arch/i386/core/linux/linuxprefix.S b/src/arch/i386/core/linux/linuxprefix.S
new file mode 100644
index 000000000..398d3cb21
--- /dev/null
+++ b/src/arch/i386/core/linux/linuxprefix.S
@@ -0,0 +1,28 @@
+#include <linux/unistd.h>
+
+ .section ".text"
+ .code32
+ .globl _linux_start
+ .type _linux_start, @function
+
+_linux_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 save_args
+
+ /* Our main doesn't use any arguments */
+ call main
+
+ movl %eax, %ebx // rc -> syscall arg1
+ movl $__NR_exit, %eax
+ int $0x80
+
+ .size _linux_start, . - _linux_start