mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
Added direct references to MemoryBlock.EXTERNAL_BLOCK_NAME instead of
hard-coded string
This commit is contained in:
parent
e4f61fa06d
commit
b83f327e47
10 changed files with 19 additions and 14 deletions
|
@ -192,7 +192,7 @@ public class OperandReferenceAnalyzer extends AbstractAnalyzer {
|
||||||
|
|
||||||
processorAlignment = program.getLanguage().getInstructionAlignment();
|
processorAlignment = program.getLanguage().getInstructionAlignment();
|
||||||
|
|
||||||
externalBlock = program.getMemory().getBlock("EXTERNAL");
|
externalBlock = program.getMemory().getBlock(MemoryBlock.EXTERNAL_BLOCK_NAME);
|
||||||
|
|
||||||
newCodeFound = false;
|
newCodeFound = false;
|
||||||
int count = NOTIFICATION_INTERVAL;
|
int count = NOTIFICATION_INTERVAL;
|
||||||
|
|
|
@ -363,7 +363,8 @@ public class CoffLoader extends AbstractLibrarySupportLoader {
|
||||||
if (!externalAddressStart.equals(externalAddress)) {
|
if (!externalAddressStart.equals(externalAddress)) {
|
||||||
long size = externalAddress.subtract(externalAddressStart);
|
long size = externalAddress.subtract(externalAddressStart);
|
||||||
try {
|
try {
|
||||||
MemoryBlock block = program.getMemory().createUninitializedBlock("EXTERNAL",
|
MemoryBlock block = program.getMemory()
|
||||||
|
.createUninitializedBlock(MemoryBlock.EXTERNAL_BLOCK_NAME,
|
||||||
externalAddressStart, size, false);
|
externalAddressStart, size, false);
|
||||||
|
|
||||||
// assume any value in external is writable.
|
// assume any value in external is writable.
|
||||||
|
|
|
@ -1133,8 +1133,8 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create EXTERNAL memory block based upon start of {@link #freeAddressRange} and the
|
* Create EXTERNAL memory block based upon {@link #externalBlockLimits} and
|
||||||
* current {@link #nextFreeAddress}.
|
* {@link #lastExternalBlockEntryAddress}.
|
||||||
*/
|
*/
|
||||||
private void createExternalBlock() {
|
private void createExternalBlock() {
|
||||||
if (lastExternalBlockEntryAddress == null) {
|
if (lastExternalBlockEntryAddress == null) {
|
||||||
|
@ -1144,7 +1144,8 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
||||||
long size = lastExternalBlockEntryAddress.subtract(externalBlockAddress) + 1;
|
long size = lastExternalBlockEntryAddress.subtract(externalBlockAddress) + 1;
|
||||||
try {
|
try {
|
||||||
MemoryBlock block =
|
MemoryBlock block =
|
||||||
memory.createUninitializedBlock("EXTERNAL", externalBlockAddress, size, false);
|
memory.createUninitializedBlock(MemoryBlock.EXTERNAL_BLOCK_NAME,
|
||||||
|
externalBlockAddress, size, false);
|
||||||
|
|
||||||
// assume any value in external is writable.
|
// assume any value in external is writable.
|
||||||
block.setWrite(true);
|
block.setWrite(true);
|
||||||
|
|
|
@ -607,8 +607,8 @@ public class MachoProgramBuilder {
|
||||||
}
|
}
|
||||||
Address start = getAddress();
|
Address start = getAddress();
|
||||||
try {
|
try {
|
||||||
MemoryBlock block = memory.createUninitializedBlock("EXTERNAL", start,
|
MemoryBlock block = memory.createUninitializedBlock(MemoryBlock.EXTERNAL_BLOCK_NAME,
|
||||||
undefinedSymbols.size() * machoHeader.getAddressSize(), false);
|
start, undefinedSymbols.size() * machoHeader.getAddressSize(), false);
|
||||||
// assume any value in external is writable.
|
// assume any value in external is writable.
|
||||||
block.setWrite(true);
|
block.setWrite(true);
|
||||||
block.setSourceName(BLOCK_SOURCE_NAME);
|
block.setSourceName(BLOCK_SOURCE_NAME);
|
||||||
|
|
|
@ -524,8 +524,9 @@ public class OmfLoader extends AbstractLibrarySupportLoader {
|
||||||
if (!externalAddressStart.equals(externalAddress)) {
|
if (!externalAddressStart.equals(externalAddress)) {
|
||||||
long size = externalAddress.subtract(externalAddressStart);
|
long size = externalAddress.subtract(externalAddressStart);
|
||||||
try {
|
try {
|
||||||
MemoryBlock block = program.getMemory().createUninitializedBlock("EXTERNAL",
|
MemoryBlock block = program.getMemory()
|
||||||
externalAddressStart, size, false);
|
.createUninitializedBlock(MemoryBlock.EXTERNAL_BLOCK_NAME,
|
||||||
|
externalAddressStart, size, false);
|
||||||
|
|
||||||
// assume any value in external is writable.
|
// assume any value in external is writable.
|
||||||
block.setWrite(true);
|
block.setWrite(true);
|
||||||
|
|
|
@ -25,6 +25,7 @@ import ghidra.program.model.lang.CompilerSpec;
|
||||||
import ghidra.program.model.lang.PrototypeModel;
|
import ghidra.program.model.lang.PrototypeModel;
|
||||||
import ghidra.program.model.listing.Function;
|
import ghidra.program.model.listing.Function;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
|
import ghidra.program.model.mem.MemoryBlock;
|
||||||
import ghidra.program.model.pcode.HighFunction;
|
import ghidra.program.model.pcode.HighFunction;
|
||||||
import ghidra.program.model.symbol.*;
|
import ghidra.program.model.symbol.*;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
|
@ -111,7 +112,7 @@ public class DecompilerParallelConventionAnalysisCmd extends BackgroundCommand {
|
||||||
*/
|
*/
|
||||||
private boolean funcIsExternalGlue(Function func) {
|
private boolean funcIsExternalGlue(Function func) {
|
||||||
String blockName = program.getMemory().getBlock(func.getEntryPoint()).getName();
|
String blockName = program.getMemory().getBlock(func.getEntryPoint()).getName();
|
||||||
return (blockName.equals("EXTERNAL") || blockName.equals(".plt") ||
|
return (blockName.equals(MemoryBlock.EXTERNAL_BLOCK_NAME) || blockName.equals(".plt") ||
|
||||||
blockName.equals("__stub_helper"));
|
blockName.equals("__stub_helper"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ import ghidra.program.model.data.DataType;
|
||||||
import ghidra.program.model.data.VoidDataType;
|
import ghidra.program.model.data.VoidDataType;
|
||||||
import ghidra.program.model.lang.CompilerSpec;
|
import ghidra.program.model.lang.CompilerSpec;
|
||||||
import ghidra.program.model.listing.*;
|
import ghidra.program.model.listing.*;
|
||||||
|
import ghidra.program.model.mem.MemoryBlock;
|
||||||
import ghidra.program.model.pcode.*;
|
import ghidra.program.model.pcode.*;
|
||||||
import ghidra.program.model.symbol.SourceType;
|
import ghidra.program.model.symbol.SourceType;
|
||||||
import ghidra.program.model.util.AcyclicCallGraphBuilder;
|
import ghidra.program.model.util.AcyclicCallGraphBuilder;
|
||||||
|
@ -116,7 +117,7 @@ public class DecompilerParameterIdCmd extends BackgroundCommand {
|
||||||
*/
|
*/
|
||||||
private boolean funcIsExternalGlue(Function func) {
|
private boolean funcIsExternalGlue(Function func) {
|
||||||
String blockName = program.getMemory().getBlock(func.getEntryPoint()).getName();
|
String blockName = program.getMemory().getBlock(func.getEntryPoint()).getName();
|
||||||
return (blockName.equals("EXTERNAL") || blockName.equals(".plt") ||
|
return (blockName.equals(MemoryBlock.EXTERNAL_BLOCK_NAME) || blockName.equals(".plt") ||
|
||||||
blockName.equals("__stub_helper"));
|
blockName.equals("__stub_helper"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -629,7 +629,7 @@ public class PseudoDisassembler {
|
||||||
// it is probably a JUMP to an external function.
|
// it is probably a JUMP to an external function.
|
||||||
MemoryBlock block = memory.getBlock(target);
|
MemoryBlock block = memory.getBlock(target);
|
||||||
if (block == null || block.isInitialized() ||
|
if (block == null || block.isInitialized() ||
|
||||||
!block.getName().equals("EXTERNAL")) {
|
!block.getName().equals(MemoryBlock.EXTERNAL_BLOCK_NAME)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
targetList.remove(target);
|
targetList.remove(target);
|
||||||
|
|
|
@ -810,7 +810,7 @@ public class ArmAnalyzer extends ConstantPropagationAnalyzer {
|
||||||
// something computed it into the memory
|
// something computed it into the memory
|
||||||
MemoryBlock block = program.getMemory().getBlock(target);
|
MemoryBlock block = program.getMemory().getBlock(target);
|
||||||
if (block == null || !block.isExecute() || !block.isInitialized() ||
|
if (block == null || !block.isExecute() || !block.isInitialized() ||
|
||||||
block.getName().equals("EXTERNAL")) {
|
block.getName().equals(MemoryBlock.EXTERNAL_BLOCK_NAME)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -505,7 +505,7 @@ public class MipsAddressAnalyzer extends ConstantPropagationAnalyzer {
|
||||||
if (addr != null) {
|
if (addr != null) {
|
||||||
MemoryBlock block = program.getMemory().getBlock(addr);
|
MemoryBlock block = program.getMemory().getBlock(addr);
|
||||||
if (block == null || !block.isExecute() || !block.isInitialized() ||
|
if (block == null || !block.isExecute() || !block.isInitialized() ||
|
||||||
block.getName().equals("EXTERNAL")) {
|
block.getName().equals(MemoryBlock.EXTERNAL_BLOCK_NAME)) {
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue