mirror of
https://github.com/ps5-payload-dev/sdk.git
synced 2026-10-22 03:14:55 -05:00
crt: make sure stack is aligned (and restored on exit)
This commit is contained in:
1 parent
a9e742489a
commit
9d267a83fa
3 files changed
+42
-2
No files matched your search
+4
-1
@@ -23,7 +23,7 @@ CFLAGS += -fms-extensions -Wno-microsoft-anon-tag
|
||||
CFLAGS += -O1
|
||||
|
||||
OBJ := crt.o syscall.o klog.o nid.o kernel.o rtld.o rtld_so.o rtld_sprx.o \
|
||||
rtld_payload.o rtld_dlfcn.o mdbg.o patch.o kernel_procio.o
|
||||
rtld_payload.o rtld_dlfcn.o mdbg.o patch.o kernel_procio.o _start.o
|
||||
|
||||
.PHONY: all clean install
|
||||
|
||||
@@ -53,6 +53,9 @@ crt1.o: $(OBJ)
|
||||
%.o: %.c
|
||||
$(CC) -c $(CFLAGS) -o $@ $^
|
||||
|
||||
%.o: %.S
|
||||
$(CC) -c $(CFLAGS) -masm=intel -o $@ $^
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/* Copyright (C) 2026 John Törnblom
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 3, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
.data
|
||||
.local __crt_reg_backup
|
||||
.type __crt_reg_backup, @object
|
||||
__crt_reg_backup:
|
||||
.quad 0
|
||||
|
||||
.text
|
||||
.extern __crt_start
|
||||
.type __crt_start, @function
|
||||
|
||||
.text
|
||||
.global _start
|
||||
.type _start, @function
|
||||
_start:
|
||||
mov [__crt_reg_backup + rip], rsp
|
||||
and rsp, -16
|
||||
call __crt_start
|
||||
mov rsp, [__crt_reg_backup + rip]
|
||||
ret
|
||||
Reference in new issue
Block a user