GP-348 Added ELF RELR relocation support

This commit is contained in:
ghidra1 2020-10-29 17:29:06 -04:00
parent 6d56553d72
commit 021fbf8025
13 changed files with 334 additions and 36 deletions

View file

@ -34,11 +34,13 @@ public abstract class FactoryStructureDataType extends BuiltIn implements Factor
super(null, name, dtm);
}
@Override
public abstract DataType clone(DataTypeManager dtm);
/**
* @see ghidra.program.model.data.DataType#getLength()
*/
@Override
public int getLength() {
return -1;
}
@ -46,6 +48,7 @@ public abstract class FactoryStructureDataType extends BuiltIn implements Factor
/**
* @see ghidra.program.model.data.DataType#getValue(ghidra.program.model.mem.MemBuffer, ghidra.docking.settings.Settings, int)
*/
@Override
public Object getValue(MemBuffer buf, Settings settings, int length) {
return null;
}
@ -53,6 +56,7 @@ public abstract class FactoryStructureDataType extends BuiltIn implements Factor
/**
* @see ghidra.program.model.data.DataType#getRepresentation(ghidra.program.model.mem.MemBuffer, ghidra.docking.settings.Settings, int)
*/
@Override
public String getRepresentation(MemBuffer buf, Settings settings, int length) {
return null;
}
@ -60,10 +64,12 @@ public abstract class FactoryStructureDataType extends BuiltIn implements Factor
/**
* @see ghidra.program.model.data.DataType#getDescription()
*/
@Override
public String getDescription() {
return "Dynamic Data Type should not be instantiated directly";
}
@Override
public DataType getDataType(MemBuffer buf) {
Structure struct = new StructureDataType(getName(), 0);
if (buf != null) {
@ -80,7 +86,7 @@ public abstract class FactoryStructureDataType extends BuiltIn implements Factor
* @param buf
* @return Returns a new structure with the correct category.
*/
private Structure setCategoryPath(Structure struct, MemBuffer buf) {
protected Structure setCategoryPath(Structure struct, MemBuffer buf) {
CategoryPath path = CategoryPath.ROOT;
try {
path =
@ -94,8 +100,9 @@ public abstract class FactoryStructureDataType extends BuiltIn implements Factor
}
private void setCategory(DataType dt, CategoryPath path) {
if (dt == null)
if (dt == null) {
return;
}
try {
dt.setCategoryPath(path);
@ -105,15 +112,15 @@ public abstract class FactoryStructureDataType extends BuiltIn implements Factor
if (dt instanceof Structure) {
Structure struct = (Structure) dt;
DataTypeComponent[] comps = struct.getDefinedComponents();
for (int i = 0; i < comps.length; i++) {
setCategory(comps[i].getDataType(), path);
for (DataTypeComponent comp : comps) {
setCategory(comp.getDataType(), path);
}
}
else if (dt instanceof Union) {
Union union = (Union) dt;
DataTypeComponent[] comps = union.getComponents();
for (int i = 0; i < comps.length; i++) {
setCategory(comps[i].getDataType(), path);
for (DataTypeComponent comp : comps) {
setCategory(comp.getDataType(), path);
}
}
else if (dt instanceof TypeDef) {