mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
Fix elf64 unself and style nits
This commit is contained in:
parent
e66005149a
commit
97c6d8407a
3 changed files with 95 additions and 58 deletions
|
@ -101,10 +101,7 @@ void WriteEhdr(const fs::file& f, Elf64_Ehdr& ehdr)
|
|||
Write8(f, ehdr.e_os_abi);
|
||||
Write64(f, ehdr.e_abi_ver);
|
||||
Write16(f, ehdr.e_type);
|
||||
if(ehdr.e_data==1)
|
||||
Write16LE(f, ehdr.e_machine);
|
||||
else
|
||||
Write16(f, ehdr.e_machine);
|
||||
Write16(f, ehdr.e_machine);
|
||||
Write32(f, ehdr.e_version);
|
||||
Write64(f, ehdr.e_entry);
|
||||
Write64(f, ehdr.e_phoff);
|
||||
|
@ -423,7 +420,6 @@ void ControlInfo::LoadLE(const fs::file& f)
|
|||
{
|
||||
f.read(type7.unk, 0x40);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ControlInfo::Show()
|
||||
|
@ -1039,14 +1035,19 @@ SELFDecrypter::SELFDecrypter(const fs::file& s)
|
|||
{
|
||||
}
|
||||
|
||||
static bool isVita(const SceHeader hdr)
|
||||
{
|
||||
return (hdr.se_hver == 3);
|
||||
}
|
||||
|
||||
bool SELFDecrypter::LoadHeaders(bool isElf32)
|
||||
{
|
||||
// Read SCE header.
|
||||
self_f.seek(0);
|
||||
sce_hdr.LoadLE(self_f);
|
||||
const bool isVita = sce_hdr.se_hver == 3;
|
||||
|
||||
if (!isVita) {
|
||||
if (!isVita(sce_hdr))
|
||||
{
|
||||
self_f.seek(0);
|
||||
sce_hdr.Load(self_f);
|
||||
}
|
||||
|
@ -1059,18 +1060,26 @@ bool SELFDecrypter::LoadHeaders(bool isElf32)
|
|||
}
|
||||
|
||||
// Read SELF header.
|
||||
if(!isVita)
|
||||
if (!isVita(sce_hdr))
|
||||
{
|
||||
self_hdr.Load(self_f);
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
self_hdr.LoadLE(self_f);
|
||||
}
|
||||
|
||||
// Read the APP INFO.
|
||||
self_f.seek(self_hdr.se_appinfooff);
|
||||
|
||||
if(!isVita)
|
||||
if (!isVita(sce_hdr))
|
||||
{
|
||||
app_info.Load(self_f);
|
||||
}
|
||||
else
|
||||
{
|
||||
app_info.LoadLE(self_f);
|
||||
}
|
||||
|
||||
// Read ELF header.
|
||||
self_f.seek(self_hdr.se_elfoff);
|
||||
|
@ -1093,10 +1102,14 @@ bool SELFDecrypter::LoadHeaders(bool isElf32)
|
|||
for(u32 i = 0; i < elf32_hdr.e_phnum; ++i)
|
||||
{
|
||||
phdr32_arr.emplace_back();
|
||||
if(!isVita)
|
||||
if (!isVita(sce_hdr))
|
||||
{
|
||||
phdr32_arr.back().Load(self_f);
|
||||
}
|
||||
else
|
||||
{
|
||||
phdr32_arr.back().LoadLE(self_f);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1126,18 +1139,27 @@ bool SELFDecrypter::LoadHeaders(bool isElf32)
|
|||
for(u32 i = 0; i < ((isElf32) ? elf32_hdr.e_phnum : elf64_hdr.e_phnum); ++i)
|
||||
{
|
||||
secinfo_arr.emplace_back();
|
||||
if(!isVita)
|
||||
if (!isVita(sce_hdr))
|
||||
{
|
||||
secinfo_arr.back().Load(self_f);
|
||||
}
|
||||
else
|
||||
{
|
||||
secinfo_arr.back().LoadLE(self_f);
|
||||
}
|
||||
}
|
||||
|
||||
// Read SCE version info.
|
||||
self_f.seek(self_hdr.se_sceveroff);
|
||||
if(!isVita)
|
||||
if (!isVita(sce_hdr))
|
||||
{
|
||||
scev_info.Load(self_f);
|
||||
}
|
||||
else
|
||||
{
|
||||
scev_info.LoadLE(self_f);
|
||||
}
|
||||
|
||||
// Read control info.
|
||||
ctrlinfo_arr.clear();
|
||||
self_f.seek(self_hdr.se_controloff);
|
||||
|
@ -1147,10 +1169,14 @@ bool SELFDecrypter::LoadHeaders(bool isElf32)
|
|||
{
|
||||
ctrlinfo_arr.emplace_back();
|
||||
ControlInfo &cinfo = ctrlinfo_arr.back();
|
||||
if(!isVita)
|
||||
if (!isVita(sce_hdr))
|
||||
{
|
||||
cinfo.Load(self_f);
|
||||
}
|
||||
else
|
||||
{
|
||||
cinfo.LoadLE(self_f);
|
||||
}
|
||||
i += cinfo.size;
|
||||
}
|
||||
|
||||
|
@ -1170,10 +1196,14 @@ bool SELFDecrypter::LoadHeaders(bool isElf32)
|
|||
for(u32 i = 0; i < elf32_hdr.e_shnum; ++i)
|
||||
{
|
||||
shdr32_arr.emplace_back();
|
||||
if (!isVita)
|
||||
if (!isVita(sce_hdr))
|
||||
{
|
||||
shdr32_arr.back().Load(self_f);
|
||||
}
|
||||
else
|
||||
{
|
||||
shdr32_arr.back().LoadLE(self_f);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1402,7 +1432,8 @@ bool SELFDecrypter::DecryptData()
|
|||
}
|
||||
}
|
||||
|
||||
if (meta_hdr.section_count == 0) {
|
||||
if (meta_hdr.section_count == 0)
|
||||
{
|
||||
for (unsigned int i = 0; i < secinfo_arr.size(); i++)
|
||||
{
|
||||
data_buf_length += secinfo_arr[i].size;
|
||||
|
@ -1456,7 +1487,8 @@ bool SELFDecrypter::DecryptData()
|
|||
}
|
||||
}
|
||||
|
||||
if (meta_hdr.section_count == 0) {
|
||||
if (meta_hdr.section_count == 0)
|
||||
{
|
||||
for (unsigned int i = 0; i < secinfo_arr.size(); i++)
|
||||
{
|
||||
self_f.seek(secinfo_arr[i].offset);
|
||||
|
@ -1686,13 +1718,15 @@ static bool IsSelfElf32(const fs::file& f)
|
|||
SelfHeader sh;
|
||||
|
||||
hdr.LoadLE(f);
|
||||
const bool isVita = hdr.se_hver == 3;
|
||||
|
||||
if (!isVita) {
|
||||
if (!isVita(hdr))
|
||||
{
|
||||
f.seek(0);
|
||||
hdr.Load(f);
|
||||
sh.Load(f);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
sh.LoadLE(f);
|
||||
}
|
||||
|
||||
|
@ -1726,7 +1760,9 @@ static bool CheckDebugSelf(fs::file& s)
|
|||
const u16 version = s.read<le_t<u16>>();
|
||||
|
||||
if (version == 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG_WARNING(LOADER, "Debug SELF detected! Removing fake header...");
|
||||
|
||||
|
|
|
@ -208,24 +208,24 @@ struct psv_libent_t
|
|||
le_t<u32> unk2;
|
||||
le_t<u32> module_nid;
|
||||
le_t<u32> module_name; /* Pointer to name of this module */
|
||||
le_t<u32> nid_table; /* Pointer to array of 32-bit NIDs to export */
|
||||
le_t<u32> nid_table; /* Pointer to array of 32-bit NIDs to export */
|
||||
le_t<u32> entry_table; /* Pointer to array of data pointers for each NID */
|
||||
};
|
||||
|
||||
struct psv_libstub_t
|
||||
{
|
||||
le_t<u16> size; // 0x2C, 0x34
|
||||
le_t<u16> version; // (usually 1, 5 for sceLibKernel)
|
||||
le_t<u16> flags; // (usually 0)
|
||||
le_t<u16> size; // 0x2C, 0x34
|
||||
le_t<u16> version; // (usually 1, 5 for sceLibKernel)
|
||||
le_t<u16> flags; // (usually 0)
|
||||
le_t<u16> fcount;
|
||||
le_t<u16> vcount;
|
||||
le_t<u16> unk2;
|
||||
le_t<u32> unk3;
|
||||
le_t<u32> module_nid; /* NID of module to import */
|
||||
le_t<u32> module_nid; /* NID of module to import */
|
||||
le_t<u32> module_name; /* Pointer to name of imported module, for debugging */
|
||||
le_t<u32> reserved2;
|
||||
le_t<u32> func_nid_table; /* Pointer to array of function NIDs to import */
|
||||
le_t<u32> func_entry_table;/* Pointer to array of stub functions to fill */
|
||||
le_t<u32> func_entry_table; /* Pointer to array of stub functions to fill */
|
||||
le_t<u32> var_nid_table; /* Pointer to array of variable NIDs to import */
|
||||
le_t<u32> var_entry_table; /* Pointer to array of data pointers to write to */
|
||||
le_t<u32> unk_nid_table;
|
||||
|
@ -652,15 +652,15 @@ void arm_load_exec(const arm_exec_object& elf)
|
|||
else
|
||||
{
|
||||
LOG_NOTICE(LOADER, "Loading libent at *0x%x", libent);
|
||||
LOG_NOTICE(LOADER, "** 0x%x, 0x%x", libent->version, libent->flags);
|
||||
LOG_NOTICE(LOADER, "** Version: 0x%x, Flags: 0x%x", libent->version, libent->flags);
|
||||
LOG_NOTICE(LOADER, "** Functions: %u", libent->fcount);
|
||||
LOG_NOTICE(LOADER, "** Variables: %u", libent->vcount);
|
||||
LOG_NOTICE(LOADER, "** 0x%x, 0x%08x", libent->unk2, libent->module_nid);
|
||||
LOG_NOTICE(LOADER, "** 0x%x, Module NID: 0x%08x", libent->unk2, libent->module_nid);
|
||||
|
||||
const auto export_nids = vm::cptr<u32>::make(libent->nid_table);
|
||||
const auto export_data = vm::cptr<u32>::make(libent->entry_table);
|
||||
|
||||
LOG_NOTICE(LOADER, "** 0x%x, 0x%08x", export_data, export_nids);
|
||||
LOG_NOTICE(LOADER, "** Export Data: 0x%x, Export NIDs: 0x%08x", export_data, export_nids);
|
||||
|
||||
for (u32 i = 0, count = export_data - export_nids; i < count; i++)
|
||||
{
|
||||
|
@ -670,28 +670,28 @@ void arm_load_exec(const arm_exec_object& elf)
|
|||
// Known exports
|
||||
switch (nid)
|
||||
{
|
||||
case 0x935cd196: // set entry point
|
||||
{
|
||||
entry_point = addr;
|
||||
break;
|
||||
}
|
||||
case 0x935cd196: // set entry point
|
||||
{
|
||||
entry_point = addr;
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x6c2224ba: // __sce_moduleinfo
|
||||
{
|
||||
verify(HERE), addr == module_info.addr();
|
||||
break;
|
||||
}
|
||||
case 0x6c2224ba: // __sce_moduleinfo
|
||||
{
|
||||
verify(HERE), addr == module_info.addr();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x70fba1e7: // __sce_process_param
|
||||
{
|
||||
proc_param.set(addr);
|
||||
break;
|
||||
}
|
||||
case 0x70fba1e7: // __sce_process_param
|
||||
{
|
||||
proc_param.set(addr);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
LOG_ERROR(LOADER, "** Unknown export '0x%08X' (*0x%x)", nid, addr);
|
||||
}
|
||||
default:
|
||||
{
|
||||
LOG_ERROR(LOADER, "** Unknown export '0x%08X' (*0x%x)", nid, addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -738,7 +738,7 @@ void arm_load_exec(const arm_exec_object& elf)
|
|||
}
|
||||
}
|
||||
|
||||
LOG_NOTICE(LOADER, "** 0x%x, 0x%x", libstub->version, libstub->flags);
|
||||
LOG_NOTICE(LOADER, "** Version: 0x%x, Flags: 0x%x", libstub->version, libstub->flags);
|
||||
LOG_NOTICE(LOADER, "** Functions: %u", libstub->fcount);
|
||||
LOG_NOTICE(LOADER, "** Variables: %u", libstub->vcount);
|
||||
LOG_NOTICE(LOADER, "** 0x%x, 0x%08x", libstub->unk2, libstub->unk3);
|
||||
|
@ -829,18 +829,19 @@ void arm_load_exec(const arm_exec_object& elf)
|
|||
|
||||
const auto libc_param = proc_param->sce_libcparam;
|
||||
|
||||
if (libc_param) {
|
||||
if (libc_param)
|
||||
{
|
||||
|
||||
LOG_NOTICE(LOADER, "__sce_libcparam(*0x%x) analysis...", libc_param);
|
||||
LOG_NOTICE(LOADER, "__sce_libcparam(*0x%x) analysis...", libc_param);
|
||||
|
||||
verify(HERE), libc_param->size >= 0x1c;
|
||||
verify(HERE), libc_param->size >= 0x1c;
|
||||
|
||||
LOG_NOTICE(LOADER, "*** size=0x%x; 0x%x, 0x%x, 0x%x", libc_param->size, libc_param->unk0, libc_param->unk1, libc_param->unk2);
|
||||
LOG_NOTICE(LOADER, "*** size=0x%x; 0x%x, 0x%x, 0x%x", libc_param->size, libc_param->unk0, libc_param->unk1, libc_param->unk2);
|
||||
|
||||
LOG_NOTICE(LOADER, "*** &sceLibcHeapSize = 0x%x", libc_param->sceLibcHeapSize);
|
||||
LOG_NOTICE(LOADER, "*** &sceLibcHeapSizeDefault = 0x%x", libc_param->sceLibcHeapSizeDefault);
|
||||
LOG_NOTICE(LOADER, "*** &sceLibcHeapExtendedAlloc = 0x%x", libc_param->sceLibcHeapExtendedAlloc);
|
||||
LOG_NOTICE(LOADER, "*** &sceLibcHeapDelayedAlloc = 0x%x", libc_param->sceLibcHeapDelayedAlloc);
|
||||
LOG_NOTICE(LOADER, "*** &sceLibcHeapSize = 0x%x", libc_param->sceLibcHeapSize);
|
||||
LOG_NOTICE(LOADER, "*** &sceLibcHeapSizeDefault = 0x%x", libc_param->sceLibcHeapSizeDefault);
|
||||
LOG_NOTICE(LOADER, "*** &sceLibcHeapExtendedAlloc = 0x%x", libc_param->sceLibcHeapExtendedAlloc);
|
||||
LOG_NOTICE(LOADER, "*** &sceLibcHeapDelayedAlloc = 0x%x", libc_param->sceLibcHeapDelayedAlloc);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -729,7 +729,7 @@ void Emulator::Load(bool add_only)
|
|||
vm::ps3::init();
|
||||
spu_load_exec(spu_exec);
|
||||
}
|
||||
else if (arm_exec.open(elf_file, 0, elf_opt::no_sections + elf_opt::no_sections) == elf_error::ok)
|
||||
else if (arm_exec.open(elf_file, 0, + elf_opt::no_sections) == elf_error::ok)
|
||||
{
|
||||
// ARMv7 executable
|
||||
g_system = system_type::psv;
|
||||
|
|
Loading…
Add table
Reference in a new issue