Only get the ElfSectionHeader in the RelocationHandler if it's not a special section header index to avoid a ArrayIndexOutOfBoundsException

This commit is contained in:
Maschell 2019-10-11 14:47:48 +02:00
parent 0005907547
commit fb3ec7fe28

View File

@ -44,6 +44,8 @@ public class Cafe_ElfRelocationHandler extends ElfRelocationHandler {
* reference because it will be too far away for the actual relocation to * reference because it will be too far away for the actual relocation to
* be valid itself. * be valid itself.
*/ */
if (sym.getSectionHeaderIndex() > 0) {
ElfSectionHeader symbolSection = elf.getSections()[sym.getSectionHeaderIndex()]; ElfSectionHeader symbolSection = elf.getSections()[sym.getSectionHeaderIndex()];
if (symbolSection.getType() == Cafe_ElfExtension.SHT_RPL_IMPORTS.value) { if (symbolSection.getType() == Cafe_ElfExtension.SHT_RPL_IMPORTS.value) {
String symbolSectionName = symbolSection.getNameAsString(); String symbolSectionName = symbolSection.getNameAsString();
@ -79,6 +81,7 @@ public class Cafe_ElfRelocationHandler extends ElfRelocationHandler {
Msg.warn(this, "Failed to find location for " + sym.getNameAsString()); Msg.warn(this, "Failed to find location for " + sym.getNameAsString());
} }
} }
}
switch (type) { switch (type) {
case Cafe_ElfRelocationConstants.R_PPC_ADDR32: case Cafe_ElfRelocationConstants.R_PPC_ADDR32: