mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-18 16:40:08 +00:00
GP-3963: Fixed an exception that could sometimes occur when parsing PE
files with debug line number information
This commit is contained in:
parent
10cc91bd8e
commit
dee7e7599f
@ -78,7 +78,7 @@ public class OMFSrcModule {
|
||||
}
|
||||
|
||||
for (int i = 0; i < Conv.shortToInt(cFile); ++i) {
|
||||
moduleFileList.add(new OMFSrcModuleFile(reader, ptr + baseSrcFile[i]));
|
||||
moduleFileList.add(new OMFSrcModuleFile(reader, ptr, ptr + baseSrcFile[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class OMFSrcModuleFile {
|
||||
|
||||
private ArrayList<OMFSrcModuleLine> moduleLineList = new ArrayList<OMFSrcModuleLine>();
|
||||
|
||||
OMFSrcModuleFile(BinaryReader reader, int ptr) throws IOException {
|
||||
OMFSrcModuleFile(BinaryReader reader, int moduleBase, int ptr) throws IOException {
|
||||
int index = ptr;
|
||||
|
||||
cSeg = reader.readShort(index);
|
||||
@ -86,7 +86,7 @@ public class OMFSrcModuleFile {
|
||||
|
||||
for (int i = 0; i < Conv.shortToInt(cSeg); ++i) {
|
||||
//OMFSrcModuleLine line = new OMFSrcModuleLine(reader, index);
|
||||
OMFSrcModuleLine line = new OMFSrcModuleLine(reader, ptr + baseSrcLn[i]);
|
||||
OMFSrcModuleLine line = new OMFSrcModuleLine(reader, moduleBase + baseSrcLn[i]);
|
||||
moduleLineList.add(line);
|
||||
index += line.getByteCount();
|
||||
}
|
||||
|
@ -38,8 +38,6 @@ class S_CONSTANT32 extends DebugSymbol {
|
||||
ptr += BinaryReader.SIZEOF_BYTE;
|
||||
|
||||
name = reader.readAsciiString(ptr, Conv.byteToInt(nameLen));
|
||||
|
||||
Msg.debug(this, "S_CONSTANT32: " + unknown1 + " - " + unknown2);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -177,12 +177,9 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
|
||||
FileHeader fileHeader = ntHeader.getFileHeader();
|
||||
List<OMFSrcModule> srcModules = dcvst.getOMFSrcModules();
|
||||
for (OMFSrcModule module : srcModules) {
|
||||
short[] segs = module.getSegments();
|
||||
int segIndex = 0;
|
||||
|
||||
OMFSrcModuleFile[] files = module.getOMFSrcModuleFiles();
|
||||
for (OMFSrcModuleFile file : files) {
|
||||
processFiles(file, segs[segIndex++], fileHeader, sectionToAddress, monitor);
|
||||
processFiles(file, module.getSegments(), fileHeader, sectionToAddress, monitor);
|
||||
processLineNumbers(fileHeader, sectionToAddress, file.getOMFSrcModuleLines(),
|
||||
options, monitor);
|
||||
|
||||
@ -274,18 +271,18 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
|
||||
}
|
||||
}
|
||||
|
||||
private void processFiles(OMFSrcModuleFile file, short segment, FileHeader fileHeader,
|
||||
private void processFiles(OMFSrcModuleFile file, short[] segments, FileHeader fileHeader,
|
||||
Map<SectionHeader, Address> sectionToAddress, TaskMonitor monitor) {
|
||||
|
||||
int[] starts = file.getStarts();
|
||||
int[] ends = file.getEnds();
|
||||
|
||||
for (int k = 0; k < starts.length; ++k) {
|
||||
if (starts[k] == 0 || ends[k] == 0) {
|
||||
if (starts[k] == 0 || ends[k] == 0 || k >= segments.length) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Address addr = sectionToAddress.get(fileHeader.getSectionHeader(segment - 1));
|
||||
Address addr = sectionToAddress.get(fileHeader.getSectionHeader(segments[k] - 1));
|
||||
if (addr == null) {
|
||||
continue;
|
||||
}
|
||||
@ -323,12 +320,6 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
|
||||
if (monitor.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (offsets[j] == 0) {
|
||||
System.out.println("");
|
||||
}
|
||||
if (offsets[j] == 1) {
|
||||
System.out.println("");
|
||||
}
|
||||
if (offsets[j] > 0) {
|
||||
addLineComment(addr.add(Conv.intToLong(offsets[j])),
|
||||
Conv.shortToInt(lineNumbers[j]));
|
||||
|
Loading…
Reference in New Issue
Block a user