Skip to content

Commit 0d14b90

Browse files
committed
Merge remote-tracking branch
'origin/GP-1777_ghizard_Improve_determination_of_segment_addresses_squashed_rebased_20220720--SQUASHED' (Closes NationalSecurityAgency#3993)
2 parents 75ae8b3 + 70e7ae6 commit 0d14b90

File tree

69 files changed

+3436
-1947
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+3436
-1947
lines changed

Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/dump/pagedump/Pagedump.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private void loadKernelPDB(String pdbLocation, TaskMonitor monitor) {
202202
try (AbstractPdb pdb = PdbParser.parse(pdbFile.getPath(), readerOptions, monitor)) {
203203
monitor.setMessage("PDB: Parsing " + pdbFile + "...");
204204
pdb.deserialize(monitor);
205-
PdbApplicator applicator = new PdbApplicator(pdbFile.getPath(), pdb);
205+
DefaultPdbApplicator applicator = new DefaultPdbApplicator(pdbFile.getPath(), pdb);
206206
applicator.applyTo(program, dtm, program.getImageBase(),
207207
applicatorOptions, monitor,
208208
(MessageLog) null);

Ghidra/Features/PDB/src/main/java/ghidra/app/plugin/core/analysis/PdbUniversalAnalyzer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import ghidra.app.util.bin.format.pdb2.pdbreader.*;
2424
import ghidra.app.util.importer.MessageLog;
2525
import ghidra.app.util.pdb.PdbProgramAttributes;
26-
import ghidra.app.util.pdb.pdbapplicator.PdbApplicator;
26+
import ghidra.app.util.pdb.pdbapplicator.DefaultPdbApplicator;
2727
import ghidra.app.util.pdb.pdbapplicator.PdbApplicatorOptions;
2828
import ghidra.framework.*;
2929
import ghidra.framework.options.OptionType;
@@ -181,7 +181,7 @@ public boolean added(Program program, AddressSetView set, TaskMonitor monitor, M
181181
try (AbstractPdb pdb = PdbParser.parse(pdbFile.getPath(), pdbReaderOptions, monitor)) {
182182
monitor.setMessage("PDB: Parsing " + pdbFile + "...");
183183
pdb.deserialize(monitor);
184-
PdbApplicator applicator = new PdbApplicator(pdbFile.getPath(), pdb);
184+
DefaultPdbApplicator applicator = new DefaultPdbApplicator(pdbFile.getPath(), pdb);
185185
applicator.applyTo(program, program.getDataTypeManager(), program.getImageBase(),
186186
pdbApplicatorOptions, monitor, log);
187187

@@ -251,7 +251,7 @@ private void logFailure(String msg, MessageLog log) {
251251
* Normally the analyzer would locate the PDB file on its own, but if a
252252
* headless script wishes to override the analyzer's behaivor, it can
253253
* use this method to specify a file.
254-
*
254+
*
255255
* @param program {@link Program}
256256
* @param pdbFile the pdb file
257257
*/
@@ -266,7 +266,7 @@ public static void setPdbFileOption(Program program, File pdbFile) {
266266
* Normally when the analyzer attempts to locate a matching PDB file it
267267
* will default to NOT searching remote symbol servers. A headless script could
268268
* use this method to allow the analyzer to search remote symbol servers.
269-
*
269+
*
270270
* @param program {@link Program}
271271
* @param allowRemote boolean flag, true means analyzer can search remote symbol
272272
* servers

Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/PdbOldDebugInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* <P>
2727
* This class uses {@link ModuleInformation500}.
2828
*/
29-
class PdbOldDebugInfo extends PdbDebugInfo {
29+
public class PdbOldDebugInfo extends PdbDebugInfo {
3030

3131
private static final int OLD_DBI_HEADER_LENGTH = 22;
3232

@@ -74,7 +74,7 @@ protected void deserializeInternalSubstreams(PdbByteReader reader, TaskMonitor m
7474
protected void deserializeAdditionalSubstreams(TaskMonitor monitor)
7575
throws IOException, PdbException, CancelledException {
7676
// TODO: evaluate. I don't think we need GlobalSymbolInformation (hash) or the
77-
// PublicSymbolInformation (hash), as they are both are search mechanisms.
77+
// PublicSymbolInformation (hash), as they are both are search mechanisms.
7878
symbolRecords.deserialize(monitor);
7979
globalSymbolInformation.deserialize(getGlobalSymbolsHashMaybeStreamNumber(), monitor);
8080
publicSymbolInformation.deserialize(getPublicStaticSymbolsHashMaybeStreamNumber(), monitor);

Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/SegmentMapDescription.java

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,62 @@ public class SegmentMapDescription {
3333
private long segOffset;
3434
private long segLength;
3535

36+
/**
37+
* Returns the {@link SegmentMapDescription} flags.
38+
* @return the flags.
39+
*/
40+
public int getFlags() {
41+
return flags;
42+
}
43+
44+
/**
45+
* Returns the {@link SegmentMapDescription} ovl (overlay?).
46+
* @return the ovl.
47+
*/
48+
public int getOvl() {
49+
return ovl;
50+
}
51+
52+
/**
53+
* Returns the {@link SegmentMapDescription} group.
54+
* @return the group.
55+
*/
56+
public int getGroup() {
57+
return group;
58+
}
59+
60+
/**
61+
* Returns the {@link SegmentMapDescription} frame.
62+
* @return the frame.
63+
*/
64+
public int getFrame() {
65+
return frame;
66+
}
67+
68+
/**
69+
* Returns the {@link SegmentMapDescription} segNameIndex.
70+
* @return the segNameIndex.
71+
*/
72+
public int getSegNameIndex() {
73+
return segNameIndex;
74+
}
75+
76+
/**
77+
* Returns the {@link SegmentMapDescription} classNameIndex.
78+
* @return the classNameIndex.
79+
*/
80+
public int getClassNameIndex() {
81+
return classNameIndex;
82+
}
83+
84+
/**
85+
* Returns the {@link SegmentMapDescription} segment offset.
86+
* @return the segment offset.
87+
*/
88+
public long getOffset() {
89+
return segOffset;
90+
}
91+
3692
/**
3793
* Returns the segment offset.
3894
* @return The offset of the segment.
@@ -42,7 +98,7 @@ public long getSegmentOffset() {
4298
}
4399

44100
/**
45-
* Returns the segment length.
101+
* Returns the {@link SegmentMapDescription} segment length.
46102
* @return The length of the segment.
47103
*/
48104
public long getLength() {
@@ -73,7 +129,7 @@ protected String dump() {
73129
StringBuilder builder = new StringBuilder();
74130
builder.append("SegmentMapDescription---------------------------------------");
75131
builder.append("\nflags: ");
76-
builder.append(flags);
132+
builder.append(String.format("0x%04x", flags));
77133
builder.append("\novl: ");
78134
builder.append(ovl);
79135
builder.append("\ngroup: ");
@@ -88,6 +144,7 @@ protected String dump() {
88144
builder.append(segOffset);
89145
builder.append("; segLength: ");
90146
builder.append(segLength);
147+
builder.append("\nEnd SegmentMapDescription-----------------------------------\n");
91148
return builder.toString();
92149
}
93150

Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/symbol/AbstractCompile2MsSymbol.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*/
2929
public abstract class AbstractCompile2MsSymbol extends AbstractMsSymbol {
3030

31+
protected long flags;
3132
protected LanguageName language;
3233
protected boolean compiledForEditAndContinue;
3334
protected boolean notCompiledWithDebugInfo;
@@ -59,7 +60,8 @@ public abstract class AbstractCompile2MsSymbol extends AbstractMsSymbol {
5960
public AbstractCompile2MsSymbol(AbstractPdb pdb, PdbByteReader reader, StringParseType strType)
6061
throws PdbException {
6162
super(pdb, reader);
62-
processFlags(reader.parseUnsignedIntVal());
63+
flags = reader.parseUnsignedIntVal();
64+
processFlags(flags);
6365
processor = Processor.fromValue(reader.parseUnsignedShortVal());
6466
frontEndMajorVersionNumber = reader.parseUnsignedShortVal();
6567
frontEndMinorVersionNumber = reader.parseUnsignedShortVal();
@@ -84,6 +86,14 @@ public AbstractCompile2MsSymbol(AbstractPdb pdb, PdbByteReader reader, StringPar
8486
pdb.setTargetProcessor(processor);
8587
}
8688

89+
/**
90+
* Returns the packed flags.
91+
* @return the packed flags.
92+
*/
93+
public long getFlags() {
94+
return flags;
95+
}
96+
8797
/**
8898
* Returns the language used.
8999
* @return Language.

Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/symbol/Compile3MsSymbol.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class Compile3MsSymbol extends AbstractMsSymbol {
2727

2828
public static final int PDB_ID = 0x113c;
2929

30+
protected long flags;
3031
protected LanguageName language;
3132
protected boolean compiledForEditAndContinue;
3233
protected boolean notCompiledWithDebugInfo;
@@ -60,7 +61,8 @@ public class Compile3MsSymbol extends AbstractMsSymbol {
6061
*/
6162
public Compile3MsSymbol(AbstractPdb pdb, PdbByteReader reader) throws PdbException {
6263
super(pdb, reader);
63-
processFlags(reader.parseUnsignedIntVal());
64+
flags = reader.parseUnsignedIntVal();
65+
processFlags(flags);
6466
processor = Processor.fromValue(reader.parseUnsignedShortVal());
6567
frontEndMajorVersionNumber = reader.parseUnsignedShortVal();
6668
frontEndMinorVersionNumber = reader.parseUnsignedShortVal();
@@ -82,6 +84,14 @@ public int getPdbId() {
8284
return PDB_ID;
8385
}
8486

87+
/**
88+
* Returns the packed flags.
89+
* @return the packed flags.
90+
*/
91+
public long getFlags() {
92+
return flags;
93+
}
94+
8595
/**
8696
* Returns the language.
8797
* @return Language.

Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/AbstractComplexTypeApplier.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ public abstract class AbstractComplexTypeApplier extends MsTypeApplier {
3434
protected AbstractComplexTypeApplier definitionApplier = null;
3535
protected AbstractComplexTypeApplier forwardReferenceApplier = null;
3636

37-
public static AbstractComplexTypeApplier getComplexApplier(PdbApplicator applicator,
37+
public static AbstractComplexTypeApplier getComplexApplier(DefaultPdbApplicator applicator,
3838
RecordNumber recordNumber) throws PdbException {
3939
return (AbstractComplexTypeApplier) applicator.getApplierSpec(recordNumber,
4040
AbstractComplexTypeApplier.class);
4141
}
4242

4343
/**
4444
* Constructor for complex type applier.
45-
* @param applicator {@link PdbApplicator} for which this class is working.
45+
* @param applicator {@link DefaultPdbApplicator} for which this class is working.
4646
* @param msType {@link AbstractComplexMsType} to process.
4747
*/
48-
public AbstractComplexTypeApplier(PdbApplicator applicator, AbstractComplexMsType msType) {
48+
public AbstractComplexTypeApplier(DefaultPdbApplicator applicator, AbstractComplexMsType msType) {
4949
super(applicator, msType);
5050
String fullPathName = msType.getName();
5151
symbolPath = new SymbolPath(SymbolPathParser.parse(fullPathName));

Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/AbstractFunctionTypeApplier.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public abstract class AbstractFunctionTypeApplier extends MsTypeApplier {
3838
/**
3939
* Constructor for the applicator that applies a "function" type, transforming it into a
4040
* Ghidra DataType.
41-
* @param applicator {@link PdbApplicator} for which this class is working.
41+
* @param applicator {@link DefaultPdbApplicator} for which this class is working.
4242
* @param msType {@link AbstractMsType} to processes
4343
*/
44-
public AbstractFunctionTypeApplier(PdbApplicator applicator, AbstractMsType msType) {
44+
public AbstractFunctionTypeApplier(DefaultPdbApplicator applicator, AbstractMsType msType) {
4545
super(applicator, msType);
4646
// String funcName = applicator.getNextAnonymousFunctionName();
4747
functionDefinition = new FunctionDefinitionDataType(
@@ -224,8 +224,8 @@ private boolean setReturnType() {
224224
return true;
225225
}
226226

227-
private void setCallingConvention(PdbApplicator applicator, CallingConvention callingConvention,
228-
boolean hasThisPointer) {
227+
private void setCallingConvention(DefaultPdbApplicator applicator,
228+
CallingConvention callingConvention, boolean hasThisPointer) {
229229
GenericCallingConvention convention;
230230
if (hasThisPointer) {
231231
convention = GenericCallingConvention.thiscall;

Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/ArgumentsListTypeApplier.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ public class ArgumentsListTypeApplier extends MsTypeApplier {
3232

3333
/**
3434
* Constructor for the applicator that applies a arguments list.
35-
* @param applicator {@link PdbApplicator} for which this class is working.
35+
* @param applicator {@link DefaultPdbApplicator} for which this class is working.
3636
* @param msType {@link AbstractArgumentsListMsType} to processes.
3737
* @throws IllegalArgumentException Upon invalid arguments.
3838
*/
39-
public ArgumentsListTypeApplier(PdbApplicator applicator, AbstractArgumentsListMsType msType)
40-
throws IllegalArgumentException {
39+
public ArgumentsListTypeApplier(DefaultPdbApplicator applicator,
40+
AbstractArgumentsListMsType msType) throws IllegalArgumentException {
4141
super(applicator, msType);
4242
}
4343

@@ -110,7 +110,7 @@ void checkForDependencies(AbstractFunctionTypeApplier functionApplier)
110110
}
111111

112112
/**
113-
* Apply this to function ({@link AbstractFunctionTypeApplier}).
113+
* Apply this to function ({@link AbstractFunctionTypeApplier}).
114114
* @param functionApplier the {@link AbstractFunctionTypeApplier} to which to apply the
115115
* arguments.
116116
* @throws CancelledException Upon user cancellation
@@ -172,7 +172,7 @@ void applyTo(AbstractFunctionTypeApplier functionApplier) throws CancelledExcept
172172
}
173173

174174
// /**
175-
// * Apply this to function ({@link AbstractFunctionTypeApplier}).
175+
// * Apply this to function ({@link AbstractFunctionTypeApplier}).
176176
// * @param functionApplier the {@link AbstractFunctionTypeApplier} to which to apply the
177177
// * arguments.
178178
// * @throws PdbException when unexpected function internals are found.
@@ -221,5 +221,5 @@ void applyTo(AbstractFunctionTypeApplier functionApplier) throws CancelledExcept
221221
// functionDefinition.setArguments(parameterDefinitionList.toArray(
222222
// new ParameterDefinition[parameterDefinitionList.size()]));
223223
// }
224-
//
224+
//
225225
}

Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/ArrayTypeApplier.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public class ArrayTypeApplier extends MsTypeApplier {
3434
/**
3535
* Constructor for the applicator that applies a "array" type, transforming it into a
3636
* Ghidra DataType.
37-
* @param applicator {@link PdbApplicator} for which this class is working.
37+
* @param applicator {@link DefaultPdbApplicator} for which this class is working.
3838
* @param msType {@link AbstractArrayMsType} to processes.
3939
*/
40-
public ArrayTypeApplier(PdbApplicator applicator, AbstractArrayMsType msType) {
40+
public ArrayTypeApplier(DefaultPdbApplicator applicator, AbstractArrayMsType msType) {
4141
super(applicator, msType);
4242
}
4343

@@ -117,7 +117,7 @@ private void applyArrayMsType(AbstractArrayMsType type) {
117117
}
118118

119119
long longUnderlyingSize =
120-
PdbApplicator.bigIntegerToLong(applicator, underlyingTypeApplier.getSize());
120+
DefaultPdbApplicator.bigIntegerToLong(applicator, underlyingTypeApplier.getSize());
121121
DataType underlyingDataType = underlyingTypeApplier.getDataType();
122122

123123
if (underlyingDataType == null) {

Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/BaseClassTypeApplier.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ public class BaseClassTypeApplier extends MsTypeApplier {
3030

3131
/**
3232
* Constructor for base class applier.
33-
* @param applicator {@link PdbApplicator} for which this class is working.
33+
* @param applicator {@link DefaultPdbApplicator} for which this class is working.
3434
* @param msType {@link AbstractBaseClassMsType}, {@link AbstractVirtualBaseClassMsType}, or
3535
* {@link AbstractIndirectVirtualBaseClassMsType} to processes.
3636
* @throws IllegalArgumentException Upon invalid arguments.
3737
*/
38-
public BaseClassTypeApplier(PdbApplicator applicator, AbstractMsType msType)
38+
public BaseClassTypeApplier(DefaultPdbApplicator applicator, AbstractMsType msType)
3939
throws IllegalArgumentException {
4040
super(applicator, validateType(msType));
4141
}

Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/BitfieldTypeApplier.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ public class BitfieldTypeApplier extends MsTypeApplier {
3232

3333
/**
3434
* Constructor for bitfield applier.
35-
* @param applicator {@link PdbApplicator} for which this class is working.
35+
* @param applicator {@link DefaultPdbApplicator} for which this class is working.
3636
* @param msType {@link AbstractBitfieldMsType} to processes
3737
*/
38-
public BitfieldTypeApplier(PdbApplicator applicator, AbstractBitfieldMsType msType) {
38+
public BitfieldTypeApplier(DefaultPdbApplicator applicator, AbstractBitfieldMsType msType) {
3939
super(applicator, msType);
4040
}
4141

Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/BlockSymbolApplier.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ public class BlockSymbolApplier extends MsSymbolApplier {
3232

3333
/**
3434
* Constructor
35-
* @param applicator the {@link PdbApplicator} for which we are working.
35+
* @param applicator the {@link DefaultPdbApplicator} for which we are working.
3636
* @param iter the Iterator containing the symbol sequence being processed
3737
*/
38-
public BlockSymbolApplier(PdbApplicator applicator, AbstractMsSymbolIterator iter) {
38+
public BlockSymbolApplier(DefaultPdbApplicator applicator, AbstractMsSymbolIterator iter) {
3939
super(applicator, iter);
4040
AbstractMsSymbol abstractSymbol = iter.next();
4141
if (!(abstractSymbol instanceof AbstractBlockMsSymbol)) {

Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/ComplexTypeApplierMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
// tried.
3434
public class ComplexTypeApplierMapper {
3535

36-
private PdbApplicator applicator;
36+
private DefaultPdbApplicator applicator;
3737

3838
// private Map<SymbolPath, AbstractComplexTypeApplier> complexTypeAppliersBySymbolPath;
3939
private Map<SymbolPath, LinkedList<AbstractComplexTypeApplier>> compositeAppliersQueueBySymbolPath;
4040
private Map<SymbolPath, LinkedList<AbstractComplexTypeApplier>> enumAppliersQueueBySymbolPath;
4141

4242
//==============================================================================================
43-
public ComplexTypeApplierMapper(PdbApplicator applicator) {
43+
public ComplexTypeApplierMapper(DefaultPdbApplicator applicator) {
4444
Objects.requireNonNull(applicator, "applicator cannot be null");
4545
this.applicator = applicator;
4646
// complexTypeAppliersBySymbolPath = new HashMap<>();

0 commit comments

Comments
 (0)