From 6380b272bd2b67862d855384d4478325c75444ae Mon Sep 17 00:00:00 2001 From: aerosoul94 Date: Tue, 2 May 2017 08:52:22 -0500 Subject: Bug fix in PS3 loader --- src/ps3/cell_loader.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/ps3/cell_loader.cpp') diff --git a/src/ps3/cell_loader.cpp b/src/ps3/cell_loader.cpp index f6be58a..0b64d94 100644 --- a/src/ps3/cell_loader.cpp +++ b/src/ps3/cell_loader.cpp @@ -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(section.data()); @@ -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); } -- cgit v1.3.1