mirror of
https://github.com/Maschell/GhidraRPXLoader.git
synced 2024-11-16 13:19:18 +01:00
Improve data references.
This commit is contained in:
parent
3eda80f7c5
commit
3275fe9c7f
@ -113,6 +113,15 @@ public class Cafe_ElfExtension extends ElfExtension {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force .dimport section to writeable so compiler does not inline
|
||||||
|
// the value... even though its external...
|
||||||
|
// TODO: Maybe there is a better way to define .dimport/.fimport
|
||||||
|
// sections as not real loaded in memory sections so that the
|
||||||
|
// compiler does not inline it's values?
|
||||||
|
if (name != null && name.startsWith(".dimport")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return (section.getFlags() & ElfSectionHeaderConstants.SHF_WRITE) != 0;
|
return (section.getFlags() & ElfSectionHeaderConstants.SHF_WRITE) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,9 +47,11 @@ public class Cafe_ElfRelocationHandler extends ElfRelocationHandler {
|
|||||||
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();
|
||||||
|
boolean isDataImport = false;
|
||||||
if (symbolSectionName.startsWith(".dimport_")) {
|
if (symbolSectionName.startsWith(".dimport_")) {
|
||||||
program.getReferenceManager().addMemoryReference(relocationAddress,
|
program.getReferenceManager().addMemoryReference(relocationAddress,
|
||||||
elfRelocationContext.getSymbolAddress(sym), RefType.DATA, SourceType.IMPORTED, 0);
|
elfRelocationContext.getSymbolAddress(sym), RefType.DATA, SourceType.IMPORTED, 0);
|
||||||
|
isDataImport = true;
|
||||||
} else if (symbolSectionName.startsWith(".fimport_")) {
|
} else if (symbolSectionName.startsWith(".fimport_")) {
|
||||||
program.getReferenceManager().addMemoryReference(relocationAddress,
|
program.getReferenceManager().addMemoryReference(relocationAddress,
|
||||||
elfRelocationContext.getSymbolAddress(sym), RefType.UNCONDITIONAL_CALL, SourceType.IMPORTED, 0);
|
elfRelocationContext.getSymbolAddress(sym), RefType.UNCONDITIONAL_CALL, SourceType.IMPORTED, 0);
|
||||||
@ -63,8 +65,13 @@ public class Cafe_ElfRelocationHandler extends ElfRelocationHandler {
|
|||||||
ExternalLocation location = program.getExternalManager().getUniqueExternalLocation(rplName, sym.getNameAsString());
|
ExternalLocation location = program.getExternalManager().getUniqueExternalLocation(rplName, sym.getNameAsString());
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
try {
|
try {
|
||||||
program.getReferenceManager().addExternalReference(relocationAddress, 1,
|
if (isDataImport) {
|
||||||
location, SourceType.IMPORTED, RefType.UNCONDITIONAL_CALL);
|
program.getReferenceManager().addExternalReference(relocationAddress, 1,
|
||||||
|
location, SourceType.IMPORTED, RefType.DATA);
|
||||||
|
} else {
|
||||||
|
program.getReferenceManager().addExternalReference(relocationAddress, 1,
|
||||||
|
location, SourceType.IMPORTED, RefType.UNCONDITIONAL_CALL);
|
||||||
|
}
|
||||||
} catch (InvalidInputException e) {
|
} catch (InvalidInputException e) {
|
||||||
Msg.warn(this, "addExternalReference failed with " + e);
|
Msg.warn(this, "addExternalReference failed with " + e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user