mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
Merge remote-tracking branch
'origin/GP-751_ghizard_OffsetAddressFactory_fixup--SQUASHED'
This commit is contained in:
commit
cbe83dcd78
2 changed files with 22 additions and 20 deletions
|
@ -34,8 +34,7 @@ import ghidra.program.model.scalar.Scalar;
|
||||||
import ghidra.program.model.symbol.Reference;
|
import ghidra.program.model.symbol.Reference;
|
||||||
import ghidra.program.model.symbol.ReferenceIterator;
|
import ghidra.program.model.symbol.ReferenceIterator;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
import ghidra.util.exception.DuplicateNameException;
|
import ghidra.util.exception.*;
|
||||||
import ghidra.util.exception.NotFoundException;
|
|
||||||
|
|
||||||
public class VarnodeContext implements ProcessorContext {
|
public class VarnodeContext implements ProcessorContext {
|
||||||
|
|
||||||
|
@ -88,7 +87,7 @@ public class VarnodeContext implements ProcessorContext {
|
||||||
this.program = program;
|
this.program = program;
|
||||||
|
|
||||||
// make a copy, because we could be making new spaces.
|
// make a copy, because we could be making new spaces.
|
||||||
this.addrFactory = new OffsetAddressFactory(program.getAddressFactory());
|
this.addrFactory = new OffsetAddressFactory(program);
|
||||||
|
|
||||||
BAD_ADDRESS = addrFactory.getAddress(getAddressSpace("BAD_ADDRESS_SPACE"), 0);
|
BAD_ADDRESS = addrFactory.getAddress(getAddressSpace("BAD_ADDRESS_SPACE"), 0);
|
||||||
|
|
||||||
|
@ -1435,8 +1434,24 @@ public class VarnodeContext implements ProcessorContext {
|
||||||
|
|
||||||
class OffsetAddressFactory extends DefaultAddressFactory {
|
class OffsetAddressFactory extends DefaultAddressFactory {
|
||||||
|
|
||||||
OffsetAddressFactory(AddressFactory baseFactory) {
|
OffsetAddressFactory(Program program) {
|
||||||
super(filterSpaces(baseFactory.getAllAddressSpaces()));
|
// We are only calling super with the address spaces from the language first, and then
|
||||||
|
// following up to explicitly add more spaces due to the treatment of memory address
|
||||||
|
// spaces by DefaultAddressFactory when constructed vs. when added later.
|
||||||
|
// If there is more than one memory address space (e.g., TYPE_RAM, TYPE_CODE, or
|
||||||
|
// TYPE_OTHER), then addresses are output with the space name prefix, which we do not want.
|
||||||
|
super(program.getLanguage().getAddressFactory().getAllAddressSpaces(),
|
||||||
|
program.getLanguage().getAddressFactory().getDefaultAddressSpace());
|
||||||
|
for (AddressSpace space : program.getAddressFactory().getAllAddressSpaces()) {
|
||||||
|
if (space.isLoadedMemorySpace() && getAddressSpace(space.getName()) == null) {
|
||||||
|
try {
|
||||||
|
addAddressSpace(space);
|
||||||
|
}
|
||||||
|
catch (DuplicateNameException e) {
|
||||||
|
throw new AssertException("Duplicate name should not occur.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getNextUniqueID() {
|
private int getNextUniqueID() {
|
||||||
|
@ -1466,17 +1481,4 @@ class OffsetAddressFactory extends DefaultAddressFactory {
|
||||||
return (type == AddressSpace.TYPE_SYMBOL);
|
return (type == AddressSpace.TYPE_SYMBOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AddressSpace[] filterSpaces(AddressSpace[] allSpaces) {
|
|
||||||
List<AddressSpace> spaces = new ArrayList<>();
|
|
||||||
for (AddressSpace space : allSpaces) {
|
|
||||||
int type = space.getType();
|
|
||||||
if (type == AddressSpace.TYPE_VARIABLE || type == AddressSpace.TYPE_STACK ||
|
|
||||||
type == AddressSpace.TYPE_EXTERNAL || type == AddressSpace.TYPE_JOIN) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
spaces.add(space);
|
|
||||||
}
|
|
||||||
return spaces.toArray(new AddressSpace[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue