This commit is contained in:
Pavel 2022-11-29 14:23:01 +03:00
parent 8dc5cbb6c9
commit 44e0fb7529
2 changed files with 28 additions and 1 deletions

View File

@ -474,6 +474,17 @@ begin
wait_until_equal(data^.handle,0);
//init static tls in stack top
begin
asm
movq %gs:(8) ,%rax //-> StackTop
lea -0x8(%rax),%rax //-> StackTop[-1]
movq %rax ,%gs:(8) //<- StackTop
end;
PPointer(StackTop)^:=Telf_file(ps4_program.ps4_app.prog)._get_tls;
end;
//init static tls in stack top
//data^.arg:=Tps4entry(data^.entry)(data^.arg);
data^.arg:=sysv_wrapper(data^.arg,data^.entry);
ReadWriteBarrier;

View File

@ -278,8 +278,8 @@ type
procedure mapCodeInit;
Procedure ClearElfFile;
function _init_tls(is_static:QWORD):Ptls_tcb;
function _get_tls:Ptls_tcb;
public
function _get_tls:Ptls_tcb;
Procedure Clean; override;
function SavePs4ElfToFile(Const name:RawByteString):Boolean;
function Prepare:Boolean; override;
@ -2552,6 +2552,7 @@ begin
end;
end;
{
function _static_get_tls_adr:Pointer; MS_ABI_Default;
var
elf:Telf_file;
@ -2561,9 +2562,23 @@ begin
if (elf=nil) then Exit;
Result:=elf._get_tls;
end;
}
{
[oob page] <- old Stack guard
[tls link] <- new Stack guard
[Stack]
[Stack]
[Stack]
}
function __static_get_tls_adr:Pointer; assembler; nostackframe;
asm
//new idea, no stack save, only %rax used
movq %gs:(8),%rax //-> StackTop
movq (%rax) ,%rax //-> StackTop^
{
push %rcx
push %rdx
push %r8
@ -2579,6 +2594,7 @@ asm
pop %r8
pop %rdx
pop %rcx
}
end;
//-not need: