Bug fix in PS3 loader

This commit is contained in:
aerosoul94 2017-05-02 08:52:22 -05:00
parent 592b0484b9
commit 6380b272bd
4 changed files with 16 additions and 3 deletions

View file

@ -248,6 +248,8 @@ void cell_loader::applySectionRelocations() {
// NOTE: the only SHT_RELA sections I see after 0.85 // NOTE: the only SHT_RELA sections I see after 0.85
// are non-allocatable so no reason to consider those // are non-allocatable so no reason to consider those
if ( section.sh_type == SHT_RELA ) { if ( section.sh_type == SHT_RELA ) {
if ( !(sections[ section.sh_info ].sh_flags & SHF_ALLOC) )
continue;
auto nrela = section.sh_size / sizeof(Elf64_Rela); auto nrela = section.sh_size / sizeof(Elf64_Rela);
auto relocations = reinterpret_cast<Elf64_Rela *>(section.data()); auto relocations = reinterpret_cast<Elf64_Rela *>(section.data());
@ -283,7 +285,6 @@ void cell_loader::applySectionRelocations() {
continue; continue;
} }
if ( symbols[ sym ].st_shndx > m_elf->getNumSections() ) { if ( symbols[ sym ].st_shndx > m_elf->getNumSections() ) {
if ( symbols[ sym ].st_shndx != SHN_ABS ) { if ( symbols[ sym ].st_shndx != SHN_ABS ) {
msg("Invalid symbol section index!\n"); msg("Invalid symbol section index!\n");
@ -291,10 +292,16 @@ void cell_loader::applySectionRelocations() {
} }
} }
uint32 symaddr;
if ( symbols[ sym ].st_shndx == SHN_ABS )
symaddr = symbols[ sym ].st_value;
else
symaddr = sections[ symbols[ sym ].st_shndx ].sh_addr;
uint32 addr = sections[ section.sh_info ].sh_addr + uint32 addr = sections[ section.sh_info ].sh_addr +
rela.r_offset; rela.r_offset;
uint32 saddr = sections[ symbols[ sym ].st_shndx ].sh_addr + uint32 saddr = symaddr + symbols[ sym ].st_value +
symbols[ sym ].st_value + rela.r_addend; rela.r_addend;
applyRelocation(type, addr, saddr); applyRelocation(type, addr, saddr);
} }

View file

@ -53,7 +53,9 @@ static void idaapi
cell_loader ldr(&elf, relocAddr, DATABASE_FILE); ldr.apply(); cell_loader ldr(&elf, relocAddr, DATABASE_FILE); ldr.apply();
} }
#ifdef _WIN32
__declspec(dllexport) __declspec(dllexport)
#endif
loader_t LDSC = loader_t LDSC =
{ {
IDP_INTERFACE_VERSION, IDP_INTERFACE_VERSION,

View file

@ -41,7 +41,9 @@ static void idaapi
psp2_loader ldr(&elf, "vita.txt"); ldr.apply(); psp2_loader ldr(&elf, "vita.txt"); ldr.apply();
} }
#ifdef _WIN32
__declspec(dllexport) __declspec(dllexport)
#endif
loader_t LDSC = loader_t LDSC =
{ {
IDP_INTERFACE_VERSION, IDP_INTERFACE_VERSION,

View file

@ -36,7 +36,9 @@ static void idaapi
cafe_loader ldr(&elf); ldr.apply(); cafe_loader ldr(&elf); ldr.apply();
} }
#ifdef _WIN32
__declspec(dllexport) __declspec(dllexport)
#endif
loader_t LDSC = loader_t LDSC =
{ {
IDP_INTERFACE_VERSION, IDP_INTERFACE_VERSION,