mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
Merge remote-tracking branch
'origin/GP-751_ghizard_VarnodeContext_Needs_OverlayAddressSpace' (Closes #2785, Closes #2787)
This commit is contained in:
commit
79fce9b032
2 changed files with 63 additions and 36 deletions
|
@ -18,6 +18,7 @@ package ghidra.program.model.address;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import ghidra.program.model.lang.BasicCompilerSpec;
|
||||
import ghidra.util.datastruct.IntObjectHashtable;
|
||||
import ghidra.util.exception.DuplicateNameException;
|
||||
|
||||
|
@ -59,9 +60,9 @@ public class DefaultAddressFactory implements AddressFactory {
|
|||
*/
|
||||
public DefaultAddressFactory(AddressSpace[] addrSpaces, AddressSpace defaultSpace) {
|
||||
memoryAddressSet = new AddressSet();
|
||||
spaces = new ArrayList<AddressSpace>(addrSpaces.length);
|
||||
spaceLookup = new IntObjectHashtable<AddressSpace>();
|
||||
spaceNameTable = new HashMap<String, AddressSpace>();
|
||||
spaces = new ArrayList<>(addrSpaces.length);
|
||||
spaceLookup = new IntObjectHashtable<>();
|
||||
spaceNameTable = new HashMap<>();
|
||||
|
||||
for (AddressSpace space : addrSpaces) {
|
||||
checkReservedSpace(space);
|
||||
|
@ -78,9 +79,6 @@ public class DefaultAddressFactory implements AddressFactory {
|
|||
else if (space.getType() == AddressSpace.TYPE_UNIQUE) {
|
||||
uniqueSpace = space;
|
||||
}
|
||||
else if (space.getType() == AddressSpace.TYPE_STACK) {
|
||||
throw new IllegalArgumentException("Stack space should not be specified");
|
||||
}
|
||||
else if (space.getType() == AddressSpace.TYPE_REGISTER) {
|
||||
if (registerSpace != null || !space.getName().equalsIgnoreCase("register")) {
|
||||
// Ghidra address encoding only handles a single register space
|
||||
|
@ -89,9 +87,6 @@ public class DefaultAddressFactory implements AddressFactory {
|
|||
}
|
||||
registerSpace = space;
|
||||
}
|
||||
else if (space.getType() == AddressSpace.TYPE_VARIABLE) {
|
||||
throw new IllegalArgumentException("Variable space must be defined by language");
|
||||
}
|
||||
// build up an address set for all possible "real" addresses
|
||||
if (space.isMemorySpace()) {
|
||||
memoryAddressSet.addRange(space.getMinAddress(), space.getMaxAddress());
|
||||
|
@ -118,17 +113,40 @@ public class DefaultAddressFactory implements AddressFactory {
|
|||
}
|
||||
|
||||
private void checkReservedSpace(AddressSpace space) {
|
||||
checkReservedVariable(space);
|
||||
checkReservedJoin(space);
|
||||
checkReservedExternal(space);
|
||||
checkReservedStack(space);
|
||||
}
|
||||
|
||||
private void checkReservedVariable(AddressSpace space) {
|
||||
if (space.getType() == AddressSpace.TYPE_VARIABLE ||
|
||||
space.getName().equalsIgnoreCase(AddressSpace.VARIABLE_SPACE.getName()) ||
|
||||
space.getName().equals("join")) {
|
||||
space.getName().equalsIgnoreCase(AddressSpace.VARIABLE_SPACE.getName())) {
|
||||
throw new IllegalArgumentException("Variable space should not be specified");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkReservedJoin(AddressSpace space) {
|
||||
if (space.getType() == AddressSpace.TYPE_JOIN ||
|
||||
space.getName().equals(BasicCompilerSpec.JOIN_SPACE_NAME)) {
|
||||
throw new IllegalArgumentException("Join space should not be specified");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkReservedExternal(AddressSpace space) {
|
||||
if (space.getType() == AddressSpace.TYPE_EXTERNAL ||
|
||||
space.getName().equalsIgnoreCase(AddressSpace.EXTERNAL_SPACE.getName())) {
|
||||
throw new IllegalArgumentException("External space should not be specified");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void checkReservedStack(AddressSpace space) {
|
||||
if (space.getType() == AddressSpace.TYPE_STACK ||
|
||||
space.getName().equalsIgnoreCase(BasicCompilerSpec.STACK_SPACE_NAME)) {
|
||||
throw new IllegalArgumentException("Stack space should not be specified");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.program.model.address.AddressFactory#getAddress(java.lang.String)
|
||||
*/
|
||||
|
@ -141,6 +159,7 @@ public class DefaultAddressFactory implements AddressFactory {
|
|||
}
|
||||
}
|
||||
catch (AddressFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
for (AddressSpace space : spaces) {
|
||||
|
@ -155,11 +174,12 @@ public class DefaultAddressFactory implements AddressFactory {
|
|||
}
|
||||
}
|
||||
catch (AddressFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Address[] getAllAddresses(String addrString) {
|
||||
return getAllAddresses(addrString, true);
|
||||
|
@ -167,8 +187,8 @@ public class DefaultAddressFactory implements AddressFactory {
|
|||
|
||||
@Override
|
||||
public Address[] getAllAddresses(String addrString, boolean caseSensitive) {
|
||||
ArrayList<Address> loadedMemoryList = new ArrayList<Address>();
|
||||
ArrayList<Address> otherList = new ArrayList<Address>();
|
||||
ArrayList<Address> loadedMemoryList = new ArrayList<>();
|
||||
ArrayList<Address> otherList = new ArrayList<>();
|
||||
|
||||
for (AddressSpace space : spaces) {
|
||||
// Only parse against true physical spaces first
|
||||
|
@ -210,7 +230,6 @@ public class DefaultAddressFactory implements AddressFactory {
|
|||
return defaultSpace;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AddressSpace[] getAddressSpaces() {
|
||||
return getPhysicalSpaces();// we avoid returning analysis spaces here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue