mirror of
https://github.com/cemu-project/GhidraRPXLoader.git
synced 2024-11-22 01:09:17 +01:00
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:
parent
0005907547
commit
fb3ec7fe28
@ -44,40 +44,43 @@ 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.
|
||||||
*/
|
*/
|
||||||
ElfSectionHeader symbolSection = elf.getSections()[sym.getSectionHeaderIndex()];
|
|
||||||
if (symbolSection.getType() == Cafe_ElfExtension.SHT_RPL_IMPORTS.value) {
|
if (sym.getSectionHeaderIndex() > 0) {
|
||||||
String symbolSectionName = symbolSection.getNameAsString();
|
ElfSectionHeader symbolSection = elf.getSections()[sym.getSectionHeaderIndex()];
|
||||||
boolean isDataImport = false;
|
if (symbolSection.getType() == Cafe_ElfExtension.SHT_RPL_IMPORTS.value) {
|
||||||
if (symbolSectionName.startsWith(".dimport_")) {
|
String symbolSectionName = symbolSection.getNameAsString();
|
||||||
program.getReferenceManager().addMemoryReference(relocationAddress,
|
boolean isDataImport = false;
|
||||||
elfRelocationContext.getSymbolAddress(sym), RefType.DATA, SourceType.IMPORTED, 0);
|
if (symbolSectionName.startsWith(".dimport_")) {
|
||||||
isDataImport = true;
|
program.getReferenceManager().addMemoryReference(relocationAddress,
|
||||||
} else if (symbolSectionName.startsWith(".fimport_")) {
|
elfRelocationContext.getSymbolAddress(sym), RefType.DATA, SourceType.IMPORTED, 0);
|
||||||
program.getReferenceManager().addMemoryReference(relocationAddress,
|
isDataImport = true;
|
||||||
elfRelocationContext.getSymbolAddress(sym), RefType.UNCONDITIONAL_CALL, SourceType.IMPORTED, 0);
|
} else if (symbolSectionName.startsWith(".fimport_")) {
|
||||||
}
|
program.getReferenceManager().addMemoryReference(relocationAddress,
|
||||||
|
elfRelocationContext.getSymbolAddress(sym), RefType.UNCONDITIONAL_CALL, SourceType.IMPORTED, 0);
|
||||||
String rplName = symbolSectionName.split("import_")[1];
|
}
|
||||||
if (!rplName.endsWith(".rpl")) {
|
|
||||||
rplName += ".rpl";
|
String rplName = symbolSectionName.split("import_")[1];
|
||||||
}
|
if (!rplName.endsWith(".rpl")) {
|
||||||
|
rplName += ".rpl";
|
||||||
ExternalLocation location = program.getExternalManager().getUniqueExternalLocation(rplName, sym.getNameAsString());
|
}
|
||||||
if (location != null) {
|
|
||||||
try {
|
ExternalLocation location = program.getExternalManager().getUniqueExternalLocation(rplName, sym.getNameAsString());
|
||||||
if (isDataImport) {
|
if (location != null) {
|
||||||
program.getReferenceManager().addExternalReference(relocationAddress, 1,
|
try {
|
||||||
location, SourceType.IMPORTED, RefType.DATA);
|
if (isDataImport) {
|
||||||
} else {
|
program.getReferenceManager().addExternalReference(relocationAddress, 1,
|
||||||
program.getReferenceManager().addExternalReference(relocationAddress, 1,
|
location, SourceType.IMPORTED, RefType.DATA);
|
||||||
location, SourceType.IMPORTED, RefType.UNCONDITIONAL_CALL);
|
} else {
|
||||||
}
|
program.getReferenceManager().addExternalReference(relocationAddress, 1,
|
||||||
} catch (InvalidInputException e) {
|
location, SourceType.IMPORTED, RefType.UNCONDITIONAL_CALL);
|
||||||
Msg.warn(this, "addExternalReference failed with " + e);
|
}
|
||||||
}
|
} catch (InvalidInputException e) {
|
||||||
} else {
|
Msg.warn(this, "addExternalReference failed with " + e);
|
||||||
Msg.warn(this, "Failed to find location for " + sym.getNameAsString());
|
}
|
||||||
}
|
} else {
|
||||||
|
Msg.warn(this, "Failed to find location for " + sym.getNameAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
Loading…
Reference in New Issue
Block a user