mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GP-1029 Detect and mark unsupported EXTERNAL data relocation and correct MIPS compound relocation processing bug.
This commit is contained in:
parent
066b285446
commit
e89a8dcde3
9 changed files with 102 additions and 14 deletions
|
@ -22,6 +22,7 @@ import ghidra.app.util.importer.MessageLog;
|
|||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.program.model.mem.MemoryBlock;
|
||||
import ghidra.util.classfinder.ExtensionPoint;
|
||||
import ghidra.util.exception.NotFoundException;
|
||||
|
||||
|
@ -69,6 +70,48 @@ abstract public class ElfRelocationHandler implements ExtensionPoint {
|
|||
ElfRelocation relocation, Address relocationAddress)
|
||||
throws MemoryAccessException, NotFoundException;
|
||||
|
||||
/**
|
||||
* Determine if symbolAddr is contained within the EXTERNAL block. If so, relocationAddress will be marked
|
||||
* with a <code<Unsupported EXTERNAL Data Elf Relocation</code> error bookmark.
|
||||
* NOTE: This method should only be invoked when the symbol offset will be adjust with a non-zero
|
||||
* value (i.e., addend).
|
||||
* @param program
|
||||
* @param relocationAddress relocation address to be bookmarked if EXTERNAL block relocation
|
||||
* @param symbolAddr symbol address correspondng to relocation (may be null)
|
||||
* @param symbolName symbol name (may not be null if symbolAddr is not null)
|
||||
* @param adjustment relocation symbol offset adjustment/addend
|
||||
* @param log import log
|
||||
* @return true if symbolAddress contained within EXTERNAL block.
|
||||
*/
|
||||
public static boolean isUnsupportedExternalRelocation(Program program,
|
||||
Address relocationAddress, Address symbolAddr, String symbolName, long adjustment,
|
||||
MessageLog log) {
|
||||
|
||||
if (symbolAddr == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MemoryBlock block = program.getMemory().getBlock(symbolAddr);
|
||||
if (block == null || !MemoryBlock.EXTERNAL_BLOCK_NAME.equals(block.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String sign = "+";
|
||||
if (adjustment < 0) {
|
||||
adjustment = -adjustment;
|
||||
sign = "-";
|
||||
}
|
||||
String adjStr = sign + "0x" + Long.toHexString(adjustment);
|
||||
|
||||
symbolName = symbolName == null ? "<no name>" : symbolName;
|
||||
log.appendMsg("Unsupported EXTERNAL Data Elf Relocation: at " + relocationAddress +
|
||||
" (External Location = " + symbolName + adjStr + ")");
|
||||
BookmarkManager bookmarkManager = program.getBookmarkManager();
|
||||
bookmarkManager.setBookmark(relocationAddress, BookmarkType.ERROR, "EXTERNAL Relocation",
|
||||
"Unsupported EXTERNAL Data Elf Relocation: External Location = " + symbolName + adjStr);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate error log entry and bookmark at relocationAddress indicating
|
||||
* an unhandled relocation.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue