summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRainer Schuetze <r.sagitario@gmx.de>2015-06-01 07:35:16 (GMT)
committerRainer Schuetze <r.sagitario@gmx.de>2015-06-01 07:35:16 (GMT)
commit750dcfdf2dcd38cad1bfead1a74a91f769b44a97 (patch)
treed87ecc43ce84bc176a6d913243636b0660f18201 /src
parent8d7dd82f227407fa2ee4e071f95e03a65962c3f3 (diff)
downloadcv2pdb-750dcfdf2dcd38cad1bfead1a74a91f769b44a97.zip
cv2pdb-750dcfdf2dcd38cad1bfead1a74a91f769b44a97.tar.gz
cv2pdb-750dcfdf2dcd38cad1bfead1a74a91f769b44a97.tar.bz2
fix regression https://github.com/rainers/cv2pdb/issues/5: do not ignore virtual size of sections
avoid assertions for DW_AT_ranges with constant data
Diffstat (limited to 'src')
-rw-r--r--src/PEImage.cpp27
-rw-r--r--src/readDwarf.cpp9
-rw-r--r--src/readDwarf.h1
3 files changed, 25 insertions, 12 deletions
diff --git a/src/PEImage.cpp b/src/PEImage.cpp
index fa1e615..707cc7e 100644
--- a/src/PEImage.cpp
+++ b/src/PEImage.cpp
@@ -371,6 +371,11 @@ bool PEImage::initDWARFObject()
return true;
}
+static DWORD sizeInImage(const IMAGE_SECTION_HEADER& sec)
+{
+ return sec.SizeOfRawData < sec.Misc.VirtualSize ? sec.SizeOfRawData : sec.Misc.VirtualSize;
+}
+
void PEImage::initDWARFSegments()
{
for(int s = 0; s < nsec; s++)
@@ -382,27 +387,27 @@ void PEImage::initDWARFSegments()
name = strtable + off;
}
if(strcmp(name, ".debug_aranges") == 0)
- debug_aranges = DPV<char>(sec[s].PointerToRawData, sec[s].SizeOfRawData);
+ debug_aranges = DPV<char>(sec[s].PointerToRawData, sizeInImage(sec[s]));
if(strcmp(name, ".debug_pubnames") == 0)
- debug_pubnames = DPV<char>(sec[s].PointerToRawData, sec[s].SizeOfRawData);
+ debug_pubnames = DPV<char>(sec[s].PointerToRawData, sizeInImage(sec[s]));
if(strcmp(name, ".debug_pubtypes") == 0)
- debug_pubtypes = DPV<char>(sec[s].PointerToRawData, sec[s].SizeOfRawData);
+ debug_pubtypes = DPV<char>(sec[s].PointerToRawData, sizeInImage(sec[s]));
if(strcmp(name, ".debug_info") == 0)
- debug_info = DPV<char>(sec[s].PointerToRawData, debug_info_length = sec[s].SizeOfRawData);
+ debug_info = DPV<char>(sec[s].PointerToRawData, debug_info_length = sizeInImage(sec[s]));
if(strcmp(name, ".debug_abbrev") == 0)
- debug_abbrev = DPV<char>(sec[s].PointerToRawData, debug_abbrev_length = sec[s].SizeOfRawData);
+ debug_abbrev = DPV<char>(sec[s].PointerToRawData, debug_abbrev_length = sizeInImage(sec[s]));
if(strcmp(name, ".debug_line") == 0)
- debug_line = DPV<char>(sec[linesSegment = s].PointerToRawData, debug_line_length = sec[s].SizeOfRawData);
+ debug_line = DPV<char>(sec[linesSegment = s].PointerToRawData, debug_line_length = sizeInImage(sec[s]));
if(strcmp(name, ".debug_frame") == 0)
- debug_frame = DPV<char>(sec[s].PointerToRawData, sec[s].SizeOfRawData);
+ debug_frame = DPV<char>(sec[s].PointerToRawData, sizeInImage(sec[s]));
if(strcmp(name, ".debug_str") == 0)
- debug_str = DPV<char>(sec[s].PointerToRawData, sec[s].SizeOfRawData);
+ debug_str = DPV<char>(sec[s].PointerToRawData, sizeInImage(sec[s]));
if(strcmp(name, ".debug_loc") == 0)
- debug_loc = DPV<char>(sec[s].PointerToRawData, sec[s].SizeOfRawData);
+ debug_loc = DPV<char>(sec[s].PointerToRawData, sizeInImage(sec[s]));
if(strcmp(name, ".debug_ranges") == 0)
- debug_ranges = DPV<char>(sec[s].PointerToRawData, debug_ranges_length = sec[s].SizeOfRawData);
+ debug_ranges = DPV<char>(sec[s].PointerToRawData, debug_ranges_length = sizeInImage(sec[s]));
if(strcmp(name, ".reloc") == 0)
- reloc = DPV<char>(sec[s].PointerToRawData, reloc_length = sec[s].SizeOfRawData);
+ reloc = DPV<char>(sec[s].PointerToRawData, reloc_length = sizeInImage(sec[s]));
if(strcmp(name, ".text") == 0)
codeSegment = s;
}
diff --git a/src/readDwarf.cpp b/src/readDwarf.cpp
index d7a9dc0..2184038 100644
--- a/src/readDwarf.cpp
+++ b/src/readDwarf.cpp
@@ -463,7 +463,14 @@ bool DIECursor::readNext(DWARF_InfoData& id, bool stopAtNull)
else
assert(false);
break;
- case DW_AT_ranges: assert(a.type == SecOffset); id.ranges = a.sec_offset; break;
+ case DW_AT_ranges:
+ if (a.type == SecOffset)
+ id.ranges = a.sec_offset;
+ else if (a.type == Const)
+ id.ranges = a.cons;
+ else
+ assert(false);
+ break;
case DW_AT_type: assert(a.type == Ref); id.type = a.ref; break;
case DW_AT_inline: assert(a.type == Const); id.inlined = a.cons; break;
case DW_AT_external: assert(a.type == Flag); id.external = a.flag; break;
diff --git a/src/readDwarf.h b/src/readDwarf.h
index 3c4ded5..813c1fd 100644
--- a/src/readDwarf.h
+++ b/src/readDwarf.h
@@ -180,6 +180,7 @@ struct DWARF_InfoData
encoding = 0;
pclo = 0;
pchi = 0;
+ ranges = 0;
type = 0;
containing_type = 0;
specification = 0;