mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-08-09 17:49:45 +00:00
Fix for Official SDK and short relocs
This commit is contained in:
parent
b12a2f7ea5
commit
e66005149a
2 changed files with 82 additions and 19 deletions
|
@ -101,6 +101,9 @@ void WriteEhdr(const fs::file& f, Elf64_Ehdr& ehdr)
|
||||||
Write8(f, ehdr.e_os_abi);
|
Write8(f, ehdr.e_os_abi);
|
||||||
Write64(f, ehdr.e_abi_ver);
|
Write64(f, ehdr.e_abi_ver);
|
||||||
Write16(f, ehdr.e_type);
|
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);
|
Write32(f, ehdr.e_version);
|
||||||
Write64(f, ehdr.e_entry);
|
Write64(f, ehdr.e_entry);
|
||||||
|
@ -148,6 +151,25 @@ void WriteEhdr(const fs::file& f, Elf32_Ehdr& ehdr)
|
||||||
Write8(f, ehdr.e_data);
|
Write8(f, ehdr.e_data);
|
||||||
Write8(f, ehdr.e_curver);
|
Write8(f, ehdr.e_curver);
|
||||||
Write8(f, ehdr.e_os_abi);
|
Write8(f, ehdr.e_os_abi);
|
||||||
|
if (ehdr.e_data == 1)
|
||||||
|
{
|
||||||
|
Write64LE(f, ehdr.e_abi_ver);
|
||||||
|
Write16LE(f, ehdr.e_type);
|
||||||
|
Write16LE(f, ehdr.e_machine);
|
||||||
|
Write32LE(f, ehdr.e_version);
|
||||||
|
Write32LE(f, ehdr.e_entry);
|
||||||
|
Write32LE(f, ehdr.e_phoff);
|
||||||
|
Write32LE(f, ehdr.e_shoff);
|
||||||
|
Write32LE(f, ehdr.e_flags);
|
||||||
|
Write16LE(f, ehdr.e_ehsize);
|
||||||
|
Write16LE(f, ehdr.e_phentsize);
|
||||||
|
Write16LE(f, ehdr.e_phnum);
|
||||||
|
Write16LE(f, ehdr.e_shentsize);
|
||||||
|
Write16LE(f, ehdr.e_shnum);
|
||||||
|
Write16LE(f, ehdr.e_shstrndx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Write64(f, ehdr.e_abi_ver);
|
Write64(f, ehdr.e_abi_ver);
|
||||||
Write16(f, ehdr.e_type);
|
Write16(f, ehdr.e_type);
|
||||||
Write16(f, ehdr.e_machine);
|
Write16(f, ehdr.e_machine);
|
||||||
|
@ -162,6 +184,7 @@ void WriteEhdr(const fs::file& f, Elf32_Ehdr& ehdr)
|
||||||
Write16(f, ehdr.e_shentsize);
|
Write16(f, ehdr.e_shentsize);
|
||||||
Write16(f, ehdr.e_shnum);
|
Write16(f, ehdr.e_shnum);
|
||||||
Write16(f, ehdr.e_shstrndx);
|
Write16(f, ehdr.e_shstrndx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WritePhdr(const fs::file& f, Elf32_Phdr& phdr)
|
void WritePhdr(const fs::file& f, Elf32_Phdr& phdr)
|
||||||
|
@ -190,6 +213,32 @@ void WriteShdr(const fs::file& f, Elf32_Shdr& shdr)
|
||||||
Write32(f, shdr.sh_entsize);
|
Write32(f, shdr.sh_entsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WritePhdrLE(const fs::file& f, Elf32_Phdr& phdr)
|
||||||
|
{
|
||||||
|
Write32LE(f, phdr.p_type);
|
||||||
|
Write32LE(f, phdr.p_offset);
|
||||||
|
Write32LE(f, phdr.p_vaddr);
|
||||||
|
Write32LE(f, phdr.p_paddr);
|
||||||
|
Write32LE(f, phdr.p_filesz);
|
||||||
|
Write32LE(f, phdr.p_memsz);
|
||||||
|
Write32LE(f, phdr.p_flags);
|
||||||
|
Write32LE(f, phdr.p_align);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteShdrLE(const fs::file& f, Elf32_Shdr& shdr)
|
||||||
|
{
|
||||||
|
Write32LE(f, shdr.sh_name);
|
||||||
|
Write32LE(f, shdr.sh_type);
|
||||||
|
Write32LE(f, shdr.sh_flags);
|
||||||
|
Write32LE(f, shdr.sh_addr);
|
||||||
|
Write32LE(f, shdr.sh_offset);
|
||||||
|
Write32LE(f, shdr.sh_size);
|
||||||
|
Write32LE(f, shdr.sh_link);
|
||||||
|
Write32LE(f, shdr.sh_info);
|
||||||
|
Write32LE(f, shdr.sh_addralign);
|
||||||
|
Write32LE(f, shdr.sh_entsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AppInfo::Load(const fs::file& f)
|
void AppInfo::Load(const fs::file& f)
|
||||||
{
|
{
|
||||||
|
@ -1434,9 +1483,16 @@ fs::file SELFDecrypter::MakeElf(bool isElf32)
|
||||||
|
|
||||||
// Write program headers.
|
// Write program headers.
|
||||||
for (u32 i = 0; i < elf32_hdr.e_phnum; ++i)
|
for (u32 i = 0; i < elf32_hdr.e_phnum; ++i)
|
||||||
|
{
|
||||||
|
if (elf32_hdr.e_data == 1)
|
||||||
|
{
|
||||||
|
WritePhdrLE(e, phdr32_arr[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
WritePhdr(e, phdr32_arr[i]);
|
WritePhdr(e, phdr32_arr[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (meta_hdr.section_count != 0)
|
if (meta_hdr.section_count != 0)
|
||||||
{
|
{
|
||||||
|
@ -1505,11 +1561,18 @@ fs::file SELFDecrypter::MakeElf(bool isElf32)
|
||||||
e.seek(elf32_hdr.e_shoff);
|
e.seek(elf32_hdr.e_shoff);
|
||||||
|
|
||||||
for (u32 i = 0; i < elf32_hdr.e_shnum; ++i)
|
for (u32 i = 0; i < elf32_hdr.e_shnum; ++i)
|
||||||
|
{
|
||||||
|
if (elf32_hdr.e_data == 1)
|
||||||
|
{
|
||||||
|
WriteShdrLE(e, shdr32_arr[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
WriteShdr(e, shdr32_arr[i]);
|
WriteShdr(e, shdr32_arr[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Write ELF header.
|
// Write ELF header.
|
||||||
|
|
|
@ -277,8 +277,8 @@ struct psv_reloc
|
||||||
/** \name Macros to get SCE reloc values
|
/** \name Macros to get SCE reloc values
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define SCE_RELOC_SHORT_OFFSET(x) (((x).r_opt1 >> 20) | ((x).r_opt2 & 0xFFFFF) << 12)
|
#define SCE_RELOC_SHORT_OFFSET(x) (((x).r_opt1 >> 20) | ((x).r_opt2 & 0x3FF) << 12)
|
||||||
#define SCE_RELOC_SHORT_ADDEND(x) ((x).r_opt2 >> 20)
|
#define SCE_RELOC_SHORT_ADDEND(x) ((x).r_opt2 >> 10)
|
||||||
#define SCE_RELOC_LONG_OFFSET(x) ((x).r_offset)
|
#define SCE_RELOC_LONG_OFFSET(x) ((x).r_offset)
|
||||||
#define SCE_RELOC_LONG_ADDEND(x) ((x).r_addend)
|
#define SCE_RELOC_LONG_ADDEND(x) ((x).r_addend)
|
||||||
#define SCE_RELOC_LONG_CODE2(x) (((x).r_type >> 20) & 0xFF)
|
#define SCE_RELOC_LONG_CODE2(x) (((x).r_type >> 20) & 0xFF)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue