This commit is contained in:
Pavel 2024-03-13 00:11:54 +03:00
parent 33e7aa2c61
commit aa953498c9
4 changed files with 48 additions and 4 deletions

View File

@ -59,10 +59,17 @@ begin
Assert(False,'jit_unknow_int');
end;
procedure jit_exit_proc;
procedure _jit_exit_proc;
begin
Writeln('TODO:jit_exit_proc');
//Assert(False);
jit_save_to_sys_save(curkthread);
print_error_td('TODO:jit_exit_proc');
Assert(False);
end;
procedure jit_exit_proc; assembler; nostackframe;
asm
call jit_save_ctx
jmp _jit_exit_proc
end;
//0x0
@ -864,6 +871,7 @@ end;
procedure op_ud2(var ctx:t_jit_context2);
begin
//exit proc?
ctx.builder.int3;
ctx.builder.call_far(@jit_exit_proc); //TODO exit dispatcher
trim_flow(ctx);
end;
@ -871,6 +879,7 @@ end;
procedure op_iretq(var ctx:t_jit_context2);
begin
//exit proc?
ctx.builder.int3;
ctx.builder.call_far(@jit_exit_proc); //TODO exit dispatcher
trim_flow(ctx);
end;
@ -878,6 +887,7 @@ end;
procedure op_hlt(var ctx:t_jit_context2);
begin
//stop thread?
ctx.builder.int3;
ctx.builder.call_far(@jit_exit_proc); //TODO exit dispatcher
end;
@ -1201,6 +1211,7 @@ begin
if (p_print_jit_preload<>0) then
begin
print_frame(stdout,ctx.ptr_curr);
Writeln('original------------------------':32,' ','0x',HexStr(ctx.ptr_curr));
print_disassemble(ctx.code,dis.CodeIdx);
Writeln('original------------------------':32,' ','0x',HexStr(ctx.ptr_next));
@ -1288,6 +1299,8 @@ begin
if (cb=nil) then
begin
print_error_td('Unhandled jit opcode!');
Writeln('original------------------------':32,' ','0x',HexStr(ctx.ptr_curr));
print_disassemble(ctx.code,dis.CodeIdx);
Writeln('original------------------------':32,' ','0x',HexStr(ctx.ptr_next));
@ -1302,6 +1315,7 @@ begin
'MIndex=',ctx.dis.ModRM.Index,' ',
'SimdOp=',ctx.dis.SimdOpcode,':',SCODES[ctx.dis.SimdOpcode],' ',
'mm=',ctx.dis.mm,':',MCODES[ctx.dis.mm and 3]);
Assert(false);
end;

View File

@ -46,6 +46,7 @@ uses
hamt,
errno,
systm,
kern_rtld,
elf_nid_utils,
kern_stub,
vm_patch_link,
@ -409,6 +410,7 @@ type
addr :QWORD;
nid :QWORD;
libname :PChar;
libfrom :PChar;
end;
const
@ -434,7 +436,7 @@ begin
str:=EncodeValue64(data^.nid);
end;
print_error_td('unresolve_symbol:0x'+HexStr(data^.nid,16)+':'+str+':'+data^.libname);
print_error_td('unresolve_symbol:0x'+HexStr(data^.nid,16)+':'+str+':'+data^.libname+' from '+data^.libfrom);
Assert(false);
end;
@ -448,6 +450,7 @@ begin
p_jmpq64_trampoline(@stub^.body)^.addr:=QWORD(@_unresolve_symbol);
p_jmpq64_trampoline(@stub^.body)^.nid:=nid;
p_jmpq64_trampoline(@stub^.body)^.libname:=libname;
p_jmpq64_trampoline(@stub^.body)^.libfrom:=dynlib_basename(refobj^.lib_path);
Result:=@stub^.body;

View File

@ -9,6 +9,8 @@ uses
mqueue,
kern_thr;
procedure print_frame(var f:text;frame:Pointer);
procedure print_backtrace(var f:text;rip,rbp:Pointer;skipframes:sizeint);
procedure print_backtrace_td(var f:text);
procedure print_error_td(const str:shortstring);
@ -181,6 +183,11 @@ begin
info.source:=Default(t_id_name);
md_copyin(@obj^.name,@info.source,SizeOf(t_id_name),nil);
if (info.source='') then
begin
md_copyin(obj^.lib_path,@info.source,SizeOf(t_id_name),nil);
end;
if (find_proc_obj(obj,r)<>0) then
begin
info.func:=ps4libdoc.GetFunctName(r.LastNid);

View File

@ -2851,6 +2851,7 @@ begin
fname:=ChangeFileExt(fname,'.prx');
if rtld_file_exists(pchar(fname)) then goto _do_load;
///
//try /system/*
fname:=pbase;
@ -2869,6 +2870,25 @@ begin
fname:=ChangeFileExt(fname,'.prx');
if rtld_file_exists(pchar(fname)) then goto _do_load;
//
//try /system/common/lib/*
fname:=pbase;
if (fname[1]<>'/') then
begin
fname:='/'+fname;
end;
fname:='/'+p_proc.p_randomized_path+'/common/lib'+fname;
if rtld_file_exists(pchar(fname)) then goto _do_load;
fname:=ChangeFileExt(fname,'.sprx');
if rtld_file_exists(pchar(fname)) then goto _do_load;
fname:=ChangeFileExt(fname,'.prx');
if rtld_file_exists(pchar(fname)) then goto _do_load;
//try internal postload
fname:=pbase;
fname:=ChangeFileExt(fname,'.prx');