mirror of
https://github.com/Maschell/GhidraRPXLoader.git
synced 2024-11-14 20:35:11 +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;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -47,9 +47,11 @@ public class Cafe_ElfRelocationHandler extends ElfRelocationHandler {
|
||||
ElfSectionHeader symbolSection = elf.getSections()[sym.getSectionHeaderIndex()];
|
||||
if (symbolSection.getType() == Cafe_ElfExtension.SHT_RPL_IMPORTS.value) {
|
||||
String symbolSectionName = symbolSection.getNameAsString();
|
||||
boolean isDataImport = false;
|
||||
if (symbolSectionName.startsWith(".dimport_")) {
|
||||
program.getReferenceManager().addMemoryReference(relocationAddress,
|
||||
elfRelocationContext.getSymbolAddress(sym), RefType.DATA, SourceType.IMPORTED, 0);
|
||||
isDataImport = true;
|
||||
} else if (symbolSectionName.startsWith(".fimport_")) {
|
||||
program.getReferenceManager().addMemoryReference(relocationAddress,
|
||||
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());
|
||||
if (location != null) {
|
||||
try {
|
||||
program.getReferenceManager().addExternalReference(relocationAddress, 1,
|
||||
location, SourceType.IMPORTED, RefType.UNCONDITIONAL_CALL);
|
||||
if (isDataImport) {
|
||||
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) {
|
||||
Msg.warn(this, "addExternalReference failed with " + e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user