9os

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit de83ed48ddddb6d5529adac0523b959a64638623
parent 669548208ba99fecb51a4620e79b6a67525ffeee
Author: Dimitris Papastamos <dimitris.papastamos@arm.com>
Date:   Wed, 17 Oct 2018 15:49:56 +0100

[amd64] Setup own fake stack for better control

Change-Id: I68dd4c95827c5a338fd06c4a32918055d5c8fcf1
Signed-off-by: Dimitris Papastamos <dimitris.papastamos@arm.com>

Diffstat:
March/amd64/crt-bsd.s | 19+++++++++++++------
March/amd64/crt-linux.s | 19+++++++++++++------
2 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/arch/amd64/crt-bsd.s b/arch/amd64/crt-bsd.s @@ -1,22 +1,29 @@ .file "crt-bsd.s" .bss - .globl _environ + .globl _environ _environ: .quad 0 .text - .align 8 - .globl _start + .global _start, _start: movq %rsp,%rbp /* load argc, argv, envp from stack */ - movq (%rbp),%rdi /* argc */ - leaq 8(%rbp),%rsi /* argv */ - leaq 16(%rbp,%rax,8),%rcx /* envp = argv + 8*argc + 8 */ + movq (%rbp),%rdi /* argc */ + leaq 8(%rbp),%rsi /* argv */ + leaq 16(%rbp,%rax,8),%rcx /* envp = argv + 8*argc + 8 */ movq %rdx,_environ + movq $stackend,%rsp /* setup fake stack */ + call main movl %eax,%edi jmp exit + + .data + .align 4096 +stack: .space 3072 +stackend: +bss: .space 4096 - (stackend - stack) diff --git a/arch/amd64/crt-linux.s b/arch/amd64/crt-linux.s @@ -1,22 +1,29 @@ .file "crt-linux.s" .bss - .globl _environ + .globl _environ _environ: .quad 0 .text - .align 8 - .globl _start + .global _start, _start: movq %rsp,%rbp /* load argc, argv, envp from stack */ - movq (%rbp),%rdi /* argc */ - leaq 8(%rbp),%rsi /* argv */ - leaq 16(%rbp,%rax,8),%rcx /* envp = argv + 8*argc + 8 */ + movq (%rbp),%rdi /* argc */ + leaq 8(%rbp),%rsi /* argv */ + leaq 16(%rbp,%rax,8),%rcx /* envp = argv + 8*argc + 8 */ movq %rdx,_environ + movq $stackend,%rsp /* setup fake stack */ + call main movl %eax,%edi jmp exit + + .data + .align 4096 +stack: .space 3072 +stackend: +bss: .space 4096 - (stackend - stack)