This commit is contained in:
Pavel 2022-12-12 15:32:28 +03:00
parent 67530f145d
commit baa12ac48b
3 changed files with 161 additions and 21 deletions

View File

@ -31,7 +31,7 @@
<PackageName Value="LCL"/> <PackageName Value="LCL"/>
</Item1> </Item1>
</RequiredPackages> </RequiredPackages>
<Units Count="99"> <Units Count="100">
<Unit0> <Unit0>
<Filename Value="fpPS4.lpr"/> <Filename Value="fpPS4.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
@ -454,6 +454,10 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ps4_libSceRandom"/> <UnitName Value="ps4_libSceRandom"/>
</Unit98> </Unit98>
<Unit99>
<Filename Value="kernel\ps4_pthread_key.pas"/>
<IsPartOfProject Value="True"/>
</Unit99>
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@ -1857,6 +1857,14 @@ Procedure OnLoadRelaExport(elf:Telf_file;Info:PRelaInfo;data:Pointer);
begin begin
Case Info^.sBind of
STB_LOCAL :;
STB_GLOBAL:;
STB_WEAK :;
else
Writeln(StdErr,'invalid sym bingding ',Info^.sBind);
end;
case Info^.rType of case Info^.rType of
//R_X86_64_NONE :Writeln('R_X86_64_NONE '); //R_X86_64_NONE :Writeln('R_X86_64_NONE ');
//R_X86_64_PC32 :Writeln('R_X86_64_PC32 '); //R_X86_64_PC32 :Writeln('R_X86_64_PC32 ');
@ -1867,45 +1875,69 @@ begin
R_X86_64_RELATIVE: R_X86_64_RELATIVE:
begin begin
_do_set(elf.mMap.pAddr+Info^.Addend); Case Info^.sBind of
STB_LOCAL:
begin
_do_set(elf.mMap.pAddr+Info^.Addend);
end;
else
begin
_do_load(elf.mMap.pAddr+Info^.Addend);
end;
end;
end; end;
R_X86_64_TPOFF64: R_X86_64_TPOFF64:
begin //tls_offset???? begin //tls_offset????
Assert(Info^.sBind=STB_LOCAL);
_do_load(Pointer(elf.pTls.offset+Info^.value+Info^.Addend)); _do_load(Pointer(elf.pTls.offset+Info^.value+Info^.Addend));
end; end;
R_X86_64_DTPMOD64: R_X86_64_DTPMOD64:
begin //tls_index???? begin //tls_index????
Assert(Info^.sBind=STB_LOCAL);
_do_set(Pointer(elf.pTls.index)); _do_set(Pointer(elf.pTls.index));
end; end;
R_X86_64_DTPOFF64: //tls R_X86_64_DTPOFF64: //tls
begin begin
Assert(Info^.sBind=STB_LOCAL);
_do_load(Pointer(Info^.value+Info^.Addend)); _do_load(Pointer(Info^.value+Info^.Addend));
end; end;
R_X86_64_JUMP_SLOT, R_X86_64_JUMP_SLOT,
R_X86_64_GLOB_DAT, R_X86_64_GLOB_DAT:
begin
Case Info^.sBind of
STB_LOCAL:
begin
_do_set(elf.mMap.pAddr+Info^.value);
end;
else
begin
_do_load(elf.mMap.pAddr+Info^.value);
end;
end;
end;
R_X86_64_64: R_X86_64_64:
begin begin
Case Info^.sBind of Case Info^.sBind of
STB_LOCAL: STB_LOCAL:
begin begin
_do_set(elf.mMap.pAddr+Info^.value+Info^.Addend); _do_set(elf.mMap.pAddr+Info^.value+Info^.Addend);
end; end;
STB_GLOBAL, else
STB_WEAK:
begin begin
_do_load(elf.mMap.pAddr+Info^.value+Info^.Addend); _do_load(elf.mMap.pAddr+Info^.value+Info^.Addend);
end; end;
else
Writeln(StdErr,'invalid sym bingding ',Info^.sBind);
end; end;
end; end;
else else
Writeln(StdErr,'rela type not handled ', HexStr(Info^.rType,8)); begin
Writeln(StdErr,'rela type not handled ', __rtype(Info^.rType));
end;
end; end;
@ -1932,6 +1964,7 @@ Procedure OnLoadRelaImport(elf:Telf_file;Info:PRelaInfo;data:Pointer);
Import:=(Info^.shndx=SHN_UNDEF); Import:=(Info^.shndx=SHN_UNDEF);
if not Import then Exit; if not Import then Exit;
Assert(Info^.value=0);
IInfo:=Default(TResolveImportInfo); IInfo:=Default(TResolveImportInfo);
@ -1970,38 +2003,92 @@ Procedure OnLoadRelaImport(elf:Telf_file;Info:PRelaInfo;data:Pointer);
IInfo.sBind :=Info^.sBind; IInfo.sBind :=Info^.sBind;
IInfo.sType :=Info^.sType; IInfo.sType :=Info^.sType;
nSymVal:=TResolveImportCb(PPointer(data)[0])(elf,@IInfo,PPointer(data)[1]); nSymVal:=TResolveImportCb(PPointer(data)[0])(elf,@IInfo,PPointer(data)[1]);
if nSymVal<>nil then nSymVal:=nSymVal+Info^.Addend;
if (nSymVal<>nil) then
if (Info^.rType=R_X86_64_64) then
begin
nSymVal:=nSymVal+Info^.Addend;
end;
_do_set(nSymVal); _do_set(nSymVal);
end; end;
end; end;
begin begin
Case Info^.sBind of
STB_LOCAL :;
STB_GLOBAL:;
STB_WEAK :;
else
Writeln(StdErr,'invalid sym bingding ',Info^.sBind);
end;
case Info^.rType of case Info^.rType of
R_X86_64_TPOFF64: R_X86_64_TPOFF64:
begin //tls_offset???? begin //tls_offset????
_do_load(Pointer(elf.pTls.offset+Info^.value+Info^.Addend)); Assert(Info^.sBind=STB_LOCAL);
end; end;
R_X86_64_DTPMOD64:; R_X86_64_RELATIVE:
begin
Case Info^.sBind of
STB_LOCAL:
begin
//
end;
else
begin
_do_load(elf.mMap.pAddr+Info^.Addend);
end;
end;
end;
R_X86_64_DTPMOD64:
begin //tls_index????
Assert(Info^.sBind=STB_LOCAL);
end;
R_X86_64_DTPOFF64: //tls R_X86_64_DTPOFF64: //tls
begin begin
_do_load(Pointer(Info^.value+Info^.Addend)); Assert(Info^.sBind=STB_LOCAL);
end; end;
R_X86_64_JUMP_SLOT, R_X86_64_JUMP_SLOT,
R_X86_64_GLOB_DAT, R_X86_64_GLOB_DAT:
begin
Case Info^.sBind of
STB_LOCAL:
begin
//
end;
else
begin
_do_load(elf.mMap.pAddr+Info^.value);
end;
end;
end;
R_X86_64_64: R_X86_64_64:
begin begin
Case Info^.sBind of Case Info^.sBind of
STB_GLOBAL, STB_LOCAL:
STB_WEAK: begin
//
end;
else
begin begin
_do_load(elf.mMap.pAddr+Info^.value+Info^.Addend); _do_load(elf.mMap.pAddr+Info^.value+Info^.Addend);
end; end;
end; end;
end; end;
else
begin
Writeln(StdErr,'rela type not handled ', __rtype(Info^.rType));
end;
end; end;
end; end;
@ -2097,6 +2184,14 @@ const
begin begin
Case Info^.sBind of
STB_LOCAL :;
STB_GLOBAL:;
STB_WEAK :;
else
FWriteln('invalid sym bingding '+__nBind(Info^.sBind));
end;
case Info^.rType of case Info^.rType of
//R_X86_64_NONE :FWriteln('R_X86_64_NONE'); //R_X86_64_NONE :FWriteln('R_X86_64_NONE');
//R_X86_64_PC32 :FWriteln('R_X86_64_PC32'); //R_X86_64_PC32 :FWriteln('R_X86_64_PC32');
@ -2139,13 +2234,12 @@ begin
begin begin
_do_load(Pointer(Info^.value)+Info^.Addend); _do_load(Pointer(Info^.value)+Info^.Addend);
end; end;
else else;
FWriteln('invalid sym bingding '+__nBind(Info^.sBind));
end; end;
end; end;
else else
FWriteln('rela type not handled '+HexStr(Info^.rType,8)); FWriteln('rela type not handled '+__rtype(Info^.rType));
end; end;

View File

@ -355,6 +355,46 @@ begin
Result:=0; Result:=0;
end; end;
function _get_sig_str(signum:Integer):RawByteString;
begin
case signum of
SIGHUP :Result:='SIGHUP';
SIGINT :Result:='SIGINT';
SIGQUIT :Result:='SIGQUIT';
SIGILL :Result:='SIGILL';
SIGTRAP :Result:='SIGTRAP';
SIGABRT :Result:='SIGABRT';
SIGEMT :Result:='SIGEMT';
SIGFPE :Result:='SIGFPE';
SIGKILL :Result:='SIGKILL';
SIGBUS :Result:='SIGBUS';
SIGSEGV :Result:='SIGSEGV';
SIGSYS :Result:='SIGSYS';
SIGPIPE :Result:='SIGPIPE';
SIGALRM :Result:='SIGALRM';
SIGTERM :Result:='SIGTERM';
SIGURG :Result:='SIGURG';
SIGSTOP :Result:='SIGSTOP';
SIGTSTP :Result:='SIGTSTP';
SIGCONT :Result:='SIGCONT';
SIGCHLD :Result:='SIGCHLD';
SIGTTIN :Result:='SIGTTIN';
SIGTTOU :Result:='SIGTTOU';
SIGIO :Result:='SIGIO';
SIGXCPU :Result:='SIGXCPU';
SIGXFSZ :Result:='SIGXFSZ';
SIGVTALRM:Result:='SIGVTALRM';
SIGPROF :Result:='SIGPROF';
SIGWINCH :Result:='SIGWINCH';
SIGINFO :Result:='SIGINFO';
SIGUSR1 :Result:='SIGUSR1';
SIGUSR2 :Result:='SIGUSR2';
SIGTHR :Result:='SIGTHR';
else
Str(signum,Result);
end;
end;
function __sigaction(signum:Integer;act,oldact:p_sigaction_t):Integer; function __sigaction(signum:Integer;act,oldact:p_sigaction_t):Integer;
var var
idx:DWORD; idx:DWORD;
@ -362,6 +402,8 @@ var
begin begin
if not _SIG_VALID_32(signum) then Exit(EINVAL); if not _SIG_VALID_32(signum) then Exit(EINVAL);
Writeln('sigaction:',_get_sig_str(signum));
if (act=nil) then if (act=nil) then
begin begin
tmp:=Default(sigaction_t); tmp:=Default(sigaction_t);