From d8e95a3785f6b0d5979c411053260e452166ba78 Mon Sep 17 00:00:00 2001 From: red-prig Date: Wed, 25 Jan 2023 22:19:42 +0300 Subject: [PATCH] fix SELF loading --- ps4_elf.pas | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ps4_elf.pas b/ps4_elf.pas index d0fccf8a..a22da253 100644 --- a/ps4_elf.pas +++ b/ps4_elf.pas @@ -361,6 +361,16 @@ begin if (flags and SF_BFLG)<>0 then Result:=Result+' SF_BFLG'; end; +function maxInt64(a,b:Int64):Int64; inline; +begin + if (a>b) then Result:=a else Result:=b; +end; + +function minInt64(a,b:Int64):Int64; inline; +begin + if (a0) then - if (self.mElf.nSize then elf.mElf.nSize:=s; + begin + LowSeg:=MinInt64(s,LowSeg); + end; + s:=s+MaxInt64(elf_phdr[i].p_filesz,elf_phdr[i].p_memsz); + elf.mElf.nSize:=MaxInt64(s,elf.mElf.nSize); end; if (LowSeg=High(Int64)) then begin - Writeln(StdErr,'Error LowSeg'); - FreeMem(SELF_MEM); - elf.Free; - Exit; + LowSeg:=0; end; elf.mElf.pAddr:=AllocMem(elf.mElf.nSize); Writeln('Elf with LowSeg:',LowSeg,' Size:',elf.mElf.nSize);