Skip to content

Commit

Permalink
Bug fix in PS3 loader
Browse files Browse the repository at this point in the history
  • Loading branch information
aerosoul94 committed May 2, 2017
1 parent 592b048 commit 6380b27
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/ps3/cell_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ void cell_loader::applySectionRelocations() {
// NOTE: the only SHT_RELA sections I see after 0.85
// are non-allocatable so no reason to consider those
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 relocations = reinterpret_cast<Elf64_Rela *>(section.data());
Expand Down Expand Up @@ -283,18 +285,23 @@ void cell_loader::applySectionRelocations() {
continue;
}


if ( symbols[ sym ].st_shndx > m_elf->getNumSections() ) {
if ( symbols[ sym ].st_shndx != SHN_ABS ) {
msg("Invalid symbol section index!\n");
continue;
}
}

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 +
rela.r_offset;
uint32 saddr = sections[ symbols[ sym ].st_shndx ].sh_addr +
symbols[ sym ].st_value + rela.r_addend;
uint32 saddr = symaddr + symbols[ sym ].st_value +
rela.r_addend;

applyRelocation(type, addr, saddr);
}
Expand Down
2 changes: 2 additions & 0 deletions src/ps3/ps3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ static void idaapi
cell_loader ldr(&elf, relocAddr, DATABASE_FILE); ldr.apply();
}

#ifdef _WIN32
__declspec(dllexport)
#endif
loader_t LDSC =
{
IDP_INTERFACE_VERSION,
Expand Down
2 changes: 2 additions & 0 deletions src/vita/vita.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ static void idaapi
psp2_loader ldr(&elf, "vita.txt"); ldr.apply();
}

#ifdef _WIN32
__declspec(dllexport)
#endif
loader_t LDSC =
{
IDP_INTERFACE_VERSION,
Expand Down
2 changes: 2 additions & 0 deletions src/wiiu/wiiu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ static void idaapi
cafe_loader ldr(&elf); ldr.apply();
}

#ifdef _WIN32
__declspec(dllexport)
#endif
loader_t LDSC =
{
IDP_INTERFACE_VERSION,
Expand Down

0 comments on commit 6380b27

Please sign in to comment.