mirror of
https://github.com/ipxe/ipxe
synced 2025-12-26 17:42:47 +03:00
[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>
This commit is contained in:
committed by
Michael Brown
parent
55187e8c4e
commit
bb5b66b887
25
src/arch/i386/prefix/linuxprefix.S
Normal file
25
src/arch/i386/prefix/linuxprefix.S
Normal file
@@ -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
|
||||||
22
src/arch/x86_64/prefix/linuxprefix.S
Normal file
22
src/arch/x86_64/prefix/linuxprefix.S
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user