Merge remote-tracking branch

'origin/GP-3236_ghidra1_PeMingwRelocs--SQUASHED' (Closes #5155)
This commit is contained in:
Ryan Kurtz 2023-04-20 07:50:04 -04:00
commit 9dcc504965
7 changed files with 752 additions and 18 deletions

View file

@ -31,6 +31,7 @@ import ghidra.program.model.mem.Memory;
import ghidra.program.model.reloc.Relocation;
import ghidra.program.model.reloc.Relocation.Status;
import ghidra.program.model.reloc.RelocationTable;
import ghidra.program.util.ChangeManager;
import ghidra.util.Lock;
import ghidra.util.exception.CancelledException;
import ghidra.util.exception.VersionException;
@ -147,9 +148,15 @@ public class RelocationManager implements RelocationTable, ManagerDB {
try {
byte flags = RelocationDBAdapter.getFlags(status, 0);
adapter.add(addr, flags, type, values, bytes, symbolName);
return new Relocation(addr, status, type, values,
Relocation reloc = new Relocation(addr, status, type, values,
getOriginalBytes(addr, status, bytes, 0),
symbolName);
// fire event
// TODO: full change support is missing
program.setChanged(ChangeManager.DOCR_RELOCATION_ADDED, null, reloc);
return reloc;
}
catch (IOException e) {
program.dbError(e);
@ -167,9 +174,15 @@ public class RelocationManager implements RelocationTable, ManagerDB {
try {
byte flags = RelocationDBAdapter.getFlags(status, byteLength);
adapter.add(addr, flags, type, values, null, symbolName);
return new Relocation(addr, status, type, values,
Relocation reloc = new Relocation(addr, status, type, values,
getOriginalBytes(addr, status, null, byteLength),
symbolName);
// fire event
// TODO: full change support is missing
program.setChanged(ChangeManager.DOCR_RELOCATION_ADDED, null, reloc);
return reloc;
}
catch (IOException e) {
program.dbError(e);

View file

@ -179,16 +179,25 @@ public abstract class AbstractPointerTypedefBuiltIn extends BuiltIn implements T
@Override
public Class<?> getValueClass(Settings settings) {
if (settings == null) {
settings = getDefaultSettings();
}
return modelTypedef.getValueClass(settings);
}
@Override
public Object getValue(MemBuffer buf, Settings settings, int length) {
if (settings == null) {
settings = getDefaultSettings();
}
return modelTypedef.getValue(buf, settings, length);
}
@Override
public String getRepresentation(MemBuffer buf, Settings settings, int length) {
if (settings == null) {
settings = getDefaultSettings();
}
return modelTypedef.getRepresentation(buf, settings, length);
}

View file

@ -724,6 +724,17 @@ public interface ChangeManager {
*/
public static final int DOCR_USER_DATA_CHANGED = 201;
////////////////////////////////////////////////////////////////////////////
//
// RELOCATIONS
//
////////////////////////////////////////////////////////////////////////////
/**
* A relocation entry was added
*/
public static final int DOCR_RELOCATION_ADDED = 210;
////////////////////////////////////////////////////////////////////////////
/**
* Mark the state of a Program as having changed and generate