obliteration icon indicating copy to clipboard operation
obliteration copied to clipboard

Hack for running static elfs

Open mikusp opened this issue 1 year ago • 7 comments

To run a static elf, it needs to be loaded at 0x400000, and the execution is to be started at the entry address, not through libkernel. As an example, SceSysAvControl.elf defined _entry at 0x400080. This makes running static elfs incompatible with Windows IIRC, at least without further major hacks.

It is nowhere near ready to be merged, but I'm looking for any pointers and suggestions. If you could comment and suggest changes to make it more correct, I'd appreciate that.

mikusp avatar Jun 19 '24 22:06 mikusp

Very simple thing: Option to run from GUI? Maybe a way to just select a .elf file

SoffiMeower avatar Jun 19 '24 23:06 SoffiMeower

In general, this is possible, I have already tested this hack and modified it to something like:

 _PROC_AREA_START_0   =QWORD($00000400000);
 _PROC_AREA_START_1   =QWORD($00010000000); //(original:0x400000-0x80000000)    
  ET_SCE_DYNEXEC:
    begin
     reloc_base:=Pointer(PROC_IMAGE_AREA_START);
     //
     imgp^.reloc_base       :=reloc_base;
     imgp^.dyn_vaddr        :=reloc_base+QWORD(imgp^.dyn_vaddr        );
     imgp^.tls_init_addr    :=reloc_base+QWORD(imgp^.tls_init_addr    );
     imgp^.eh_frame_hdr_addr:=reloc_base+QWORD(imgp^.eh_frame_hdr_addr);
     imgp^.proc_param_addr  :=reloc_base+QWORD(imgp^.proc_param_addr  );
    end;

  ET_SCE_EXEC:
    if (PROC_IMAGE_AREA_START=_PROC_AREA_START_1) then
    begin
     //hack
     hdr^.e_type:=ET_SCE_DYNEXEC;
     //
     reloc_base:=Pointer(_PROC_AREA_START_1);
     //
     imgp^.reloc_base       :=reloc_base;
     imgp^.dyn_vaddr        :=reloc_base+QWORD(imgp^.dyn_vaddr        );
     imgp^.tls_init_addr    :=reloc_base+QWORD(imgp^.tls_init_addr    );
     imgp^.eh_frame_hdr_addr:=reloc_base+QWORD(imgp^.eh_frame_hdr_addr);
     imgp^.proc_param_addr  :=reloc_base+QWORD(imgp^.proc_param_addr  );
    end;  

red-prig avatar Jun 21 '24 19:06 red-prig

We probably need to wait for moving the game code to run inside a VM so we don't need a hack.

ultimaweapon avatar Jun 22 '24 06:06 ultimaweapon

We are closing this PR due to no any activities in the last 30 days. Feel free to re-open it if you would like to continue working on this.

github-actions[bot] avatar Jul 24 '24 01:07 github-actions[bot]

Shush, bot.

SoffiMeower avatar Jul 24 '24 01:07 SoffiMeower

We are closing this PR due to no any activities in the last 30 days. Feel free to re-open it if you would like to continue working on this.

github-actions[bot] avatar Aug 25 '24 01:08 github-actions[bot]

We are closing this PR due to no any activities in the last 30 days. Feel free to re-open it if you would like to continue working on this.

github-actions[bot] avatar Sep 26 '24 01:09 github-actions[bot]

Any progress on this?

Randomuser8219 avatar Oct 20 '24 14:10 Randomuser8219

We are currently working on a debugger to be able to debug our new kernel. Once we have a working debugger we will continue working on the new kernel. Not much progress on the new kernel since last update.

We will revisit this once we start moving the SELF loading code to the new kernel.

ultimaweapon avatar Oct 20 '24 14:10 ultimaweapon

We are closing this PR due to no any activities in the last 30 days. Feel free to re-open it if you would like to continue working on this.

github-actions[bot] avatar Nov 21 '24 01:11 github-actions[bot]