mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
0f36efa228
7 changed files with 38 additions and 43 deletions
|
@ -1057,7 +1057,7 @@ public class DBTraceProgramView implements TraceProgramView {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Address getImageBase() {
|
public Address getImageBase() {
|
||||||
return language.getAddressFactory().getAddressSet().getMinAddress();
|
return language.getDefaultSpace().getMinAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -126,38 +126,15 @@ public class CreateDataBackgroundCmd extends BackgroundCommand {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Address alignAddress(Address addr, int alignment) {
|
|
||||||
if (addr == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
long mod = addr.getOffset() % alignment;
|
|
||||||
if (mod == 0) {
|
|
||||||
return addr;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return addr.addNoWrap(alignment - mod);
|
|
||||||
}
|
|
||||||
catch (AddressOverflowException e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createData(Address start, Address end, DataType dataType, Program p,
|
private void createData(Address start, Address end, DataType dataType, Program p,
|
||||||
TaskMonitor monitor) throws CodeUnitInsertionException {
|
TaskMonitor monitor) throws CodeUnitInsertionException {
|
||||||
|
|
||||||
int alignment = 1;
|
Address nextAddr = start;
|
||||||
if (newDataType.getLength() != newDataType.getAlignedLength()) {
|
Listing listing = p.getListing();
|
||||||
// datatypes whose length does not match their aligned-length must
|
listing.clearCodeUnits(start, end, false);
|
||||||
// be properly aligned to account for padding (e.g., x86-32 80-bit floats)
|
|
||||||
alignment = newDataType.getAlignment();
|
|
||||||
}
|
|
||||||
|
|
||||||
int initialProgress = bytesApplied;
|
int initialProgress = bytesApplied;
|
||||||
|
|
||||||
Listing listing = p.getListing();
|
|
||||||
listing.clearCodeUnits(start, end, false);
|
|
||||||
Address nextAddr = alignAddress(start, alignment);
|
|
||||||
int length = (int) end.subtract(nextAddr) + 1;
|
int length = (int) end.subtract(nextAddr) + 1;
|
||||||
while (nextAddr != null && nextAddr.compareTo(end) <= 0) {
|
while (nextAddr != null && nextAddr.compareTo(end) <= 0) {
|
||||||
if (monitor.isCancelled()) {
|
if (monitor.isCancelled()) {
|
||||||
|
@ -165,19 +142,22 @@ public class CreateDataBackgroundCmd extends BackgroundCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
Data d = listing.createData(nextAddr, dataType, length);
|
Data d = listing.createData(nextAddr, dataType, length);
|
||||||
Address maxDataAddr = d.getMaxAddress();
|
int dataLength = d.getLength();
|
||||||
bytesApplied = initialProgress + (int) maxDataAddr.subtract(start) + 1;
|
bytesApplied = initialProgress + dataLength;
|
||||||
nextAddr = alignAddress(maxDataAddr.next(), alignment);
|
|
||||||
if (nextAddr != null) {
|
try {
|
||||||
length = (int) end.subtract(nextAddr) + 1;
|
nextAddr = nextAddr.addNoWrap(dataLength);
|
||||||
|
length -= dataLength;
|
||||||
|
}
|
||||||
|
catch (AddressOverflowException e) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
monitor.setProgress(bytesApplied);
|
monitor.setProgress(bytesApplied);
|
||||||
if (++numDataCreated % 10000 == 0) {
|
if (++numDataCreated % 10000 == 0) {
|
||||||
monitor.setMessage("Created " + numDataCreated);
|
monitor.setMessage("Created " + numDataCreated);
|
||||||
|
|
||||||
// Allow the Swing thread a chance to paint components that may require
|
// Allow the Swing thread a chance to paint components that may require lock
|
||||||
// a DB lock.
|
|
||||||
Swing.allowSwingToProcessEvents();
|
Swing.allowSwingToProcessEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,7 +212,7 @@ public abstract class CompositeEditorModel extends CompositeViewerModel implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
DataType resultDt = DataUtilities.reconcileAppliedDataType(currentDt, dt, true);
|
DataType resultDt = DataUtilities.reconcileAppliedDataType(currentDt, dt, true);
|
||||||
int resultLen = resultDt.getAlignedLength();
|
int resultLen = resultDt.getLength();
|
||||||
|
|
||||||
if (resultDt instanceof Dynamic) {
|
if (resultDt instanceof Dynamic) {
|
||||||
resultLen = DataTypeHelper.requestDtSize(getProvider(), resultDt.getDisplayName(),
|
resultLen = DataTypeHelper.requestDtSize(getProvider(), resultDt.getDisplayName(),
|
||||||
|
@ -222,7 +222,9 @@ public abstract class CompositeEditorModel extends CompositeViewerModel implemen
|
||||||
throw new InvalidDataTypeException("Data types of size 0 are not allowed.");
|
throw new InvalidDataTypeException("Data types of size 0 are not allowed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return DataTypeInstance.getDataTypeInstance(resultDt, resultLen, true);
|
// TODO: Need to handle proper placement for big-endian within a larger component (i.e., right-justified)
|
||||||
|
return DataTypeInstance.getDataTypeInstance(resultDt, resultLen,
|
||||||
|
viewComposite.isPackingEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -723,7 +723,8 @@ public class GhidraServer extends UnicastRemoteObject implements GhidraServerHan
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Application.initializeLogging(new File(serverRoot, "server.log"), null);
|
File serverLogFile = new File(serverRoot, "server.log");
|
||||||
|
Application.initializeLogging(serverLogFile, serverLogFile);
|
||||||
|
|
||||||
// In the absence of module initialization - we must invoke directly
|
// In the absence of module initialization - we must invoke directly
|
||||||
SSLContextInitializer.initialize();
|
SSLContextInitializer.initialize();
|
||||||
|
|
|
@ -57,8 +57,6 @@ public class GhidraServerApplicationLayout extends ApplicationLayout {
|
||||||
|
|
||||||
// User directories (don't let anything use the user home directory...there may not be one)
|
// User directories (don't let anything use the user home directory...there may not be one)
|
||||||
userTempDir = ApplicationUtilities.getDefaultUserTempDir(applicationProperties);
|
userTempDir = ApplicationUtilities.getDefaultUserTempDir(applicationProperties);
|
||||||
userSettingsDir = ApplicationUtilities.getDefaultUserSettingsDir(applicationProperties,
|
|
||||||
applicationInstallationDir);
|
|
||||||
|
|
||||||
// Modules - required to find module data files
|
// Modules - required to find module data files
|
||||||
modules = ModuleUtilities.findModules(applicationRootDirs,
|
modules = ModuleUtilities.findModules(applicationRootDirs,
|
||||||
|
|
|
@ -411,7 +411,9 @@ public class PcodeExecutor<T> {
|
||||||
* @param frame the frame to finish
|
* @param frame the frame to finish
|
||||||
*/
|
*/
|
||||||
protected void branchToOffset(T offset, PcodeFrame frame) {
|
protected void branchToOffset(T offset, PcodeFrame frame) {
|
||||||
state.setVar(pc, offset);
|
T truncOff = arithmetic.unaryOp(PcodeOp.COPY, pc.getMinimumByteSize(),
|
||||||
|
(int) arithmetic.sizeOf(offset), offset);
|
||||||
|
state.setVar(pc, truncOff);
|
||||||
frame.finishAsBranch();
|
frame.finishAsBranch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,11 @@ public class DataTypeInstance {
|
||||||
/**
|
/**
|
||||||
* Generate a data-type instance
|
* Generate a data-type instance
|
||||||
* Factory and Dynamic data-types are NOT handled.
|
* Factory and Dynamic data-types are NOT handled.
|
||||||
|
* <br>
|
||||||
|
* This container does not dictate the placement of a fixed-length type within this
|
||||||
|
* container. It is suggested that big-endian use should evaulate the datatype
|
||||||
|
* at the far end of the container.
|
||||||
|
*
|
||||||
* @param dataType data type
|
* @param dataType data type
|
||||||
* @param buf memory buffer
|
* @param buf memory buffer
|
||||||
* @param useAlignedLength if true a fixed-length primitive data type will use its
|
* @param useAlignedLength if true a fixed-length primitive data type will use its
|
||||||
|
@ -95,6 +100,11 @@ public class DataTypeInstance {
|
||||||
/**
|
/**
|
||||||
* Attempt to create a fixed-length data-type instance.
|
* Attempt to create a fixed-length data-type instance.
|
||||||
* Factory and non-sizable Dynamic data-types are NOT handled.
|
* Factory and non-sizable Dynamic data-types are NOT handled.
|
||||||
|
* <br>
|
||||||
|
* This container does not dictate the placement of a fixed-length type within this
|
||||||
|
* container. It is suggested that big-endian use should evaulate the datatype
|
||||||
|
* at the far end of the container.
|
||||||
|
*
|
||||||
* @param dataType data type
|
* @param dataType data type
|
||||||
* @param length length for sizable Dynamic data-types, otherwise ignored
|
* @param length length for sizable Dynamic data-types, otherwise ignored
|
||||||
* @param useAlignedLength if true a fixed-length primitive data type will use its
|
* @param useAlignedLength if true a fixed-length primitive data type will use its
|
||||||
|
@ -128,6 +138,7 @@ public class DataTypeInstance {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (useAlignedLength) {
|
else if (useAlignedLength) {
|
||||||
|
// TODO: big-endian should place type at end of this container
|
||||||
length = dataType.getAlignedLength();
|
length = dataType.getAlignedLength();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -145,10 +156,11 @@ public class DataTypeInstance {
|
||||||
* Attempt to create a data-type instance associated with a specific memory location.
|
* Attempt to create a data-type instance associated with a specific memory location.
|
||||||
* Factory and Dynamic data-types are handled.
|
* Factory and Dynamic data-types are handled.
|
||||||
* <br>
|
* <br>
|
||||||
* NOTE: fixed-length primitive datatypes assume {@link DataType#getLength() raw datatype length}
|
* This container does not dictate the placement of a fixed-length type within this
|
||||||
* intended for {@link Data} use.
|
* container. It is suggested that big-endian use should evaulate the datatype
|
||||||
|
* at the far end of the container.
|
||||||
*
|
*
|
||||||
* @param dataType
|
* @param dataType the data type
|
||||||
* @param buf memory location
|
* @param buf memory location
|
||||||
* @param length length for sizable Dynamic data-types, otherwise ignored
|
* @param length length for sizable Dynamic data-types, otherwise ignored
|
||||||
* @param useAlignedLength if true a fixed-length primitive data type will use its
|
* @param useAlignedLength if true a fixed-length primitive data type will use its
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue